Documentation

State Extension

The State extension provides state-based triggers that respond to component state changes in MudPi.

Overview

The state extension works with the MudPi state manager to offer state-based triggers. The state trigger is the recommended way to respond to new state from components.

This extension does not require extension-level configuration and is focused on interfaces.

Trigger Interface

Provides a trigger that listens for a StateUpdated event on the state topic.

Option Type Required Description
key String Yes Unique slug identifier for the component
source String Yes Component key to check for new state
nested_source String No Key from the data object to fetch if the data is nested
frequency String No How many times to trigger: once or many. Default: once
thresholds Array No Array of threshold objects to evaluate reading data against
name String No Friendly display name for the component
actions List No List of registered actions to fire
mudpi.config.json
{
  "trigger": [
    {
      "key": "temperature_trigger",
      "interface": "state",
      "source": "dht_1",
      "nested_source": "temperature",
      "name": "Temperature too Hot",
      "frequency": "many",
      "thresholds": [
        {
          "comparison": "gte",
          "value": 74
        }
      ],
      "actions": ["toggle.turn_on"]
    }
  ]
}

The configuration above would turn_on all toggles if the temperature was above 74.

Tip

The state trigger is the most commonly used trigger in MudPi. Use it to respond to changes from any component that stores state, including sensors, toggles, and custom extensions.