Documentation

Redis Extension

The Redis extension allows you to connect to a Redis server and gather data from local or remote instances.

Overview

The redis extension connects to a Redis server to read data from the memory store or listen for events. You can connect to a local or remote server. The connection is configured at the extension level and shared by all interfaces, reducing unnecessary connections.

Extension Configuration

Configure the Redis connection with a key that interfaces will reference:

Option Type Required Description
key String Yes Unique slug identifier for the connection, referenced by interfaces
host String No Host address of the Redis server. Default: 127.0.0.1
port Integer No Port of the Redis server. Default: 6379
mudpi.config.json
{
  "redis": [
    {
      "key": "localhost_redis",
      "host": "127.0.0.1",
      "port": 6379
    }
  ]
}

Sensor Interface

Provides a sensor to read data from the memory store or listen for events.

Option Type Required Description
key String Yes Unique slug identifier for the component
connection String Yes The key from the Redis connection config
type String No Sensor mode: state (read from memory) or event (listen for events). Default: state
name String No Friendly display name for the component
classifier String No Sensor classifier to change frontend formatting. Default: general

Event Sensor

An event sensor listens on a topic and has an optional expires key for stale state handling:

Option Type Required Description
topic String No Topic for the sensor to listen on. Default: sensor/{key}
expires Integer No Time in seconds before state is considered invalid. 0 = disabled. Default: 0
Event Sensor Config
{
  "sensor": [
    {
      "key": "redis_event_sensor",
      "interface": "redis",
      "connection": "local_redis",
      "type": "event",
      "topic": "mudpi/example/topic",
      "expires": 3600,
      "classifier": "general"
    }
  ]
}

State Sensor

A state sensor pulls data from the Redis memory store based on a state_key:

Option Type Required Description
state_key String Yes The key to pull from the Redis memory store
State Sensor Config
{
  "sensor": [
    {
      "key": "redis_state_sensor",
      "interface": "redis",
      "connection": "local_redis",
      "type": "state",
      "state_key": "example_component.state",
      "classifier": "general"
    }
  ]
}

Tip

Use the Redis extension to pull data from other MudPi instances or external services that publish to Redis, enabling distributed garden monitoring setups.