State

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

This extension does not take an extension level config and is focused on interfaces.


Trigger Interface

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

OptionTypeRequiredDescription
key[String]YesUnique slug id for the component
source[String]YesComponent key to check for new state.
nested_source[String]NoIf the data is an object this is the key from that object to fetch.
frequency[String]NoNumber of times to trigger actions once trigger is active. Options: once, many. Default: once
thresholds[Array]NoArray of threshold configuration objects to evaluate the reading data to.
name[String]NoFriendly display name of component. Useful for UI.
actions[List]NoList of registered actions to fire.

Config

Here is a config of a complete trigger.

"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.