Skip to main content

Automation

With the automation module, simple rules can be executed. A rule consists of an action to be executed and a condition that must be met for the action to be executed.

automation/state

The state of the automation. Indicates which conditions and actions are supported by this firmware and which of the supported conditions and actions can currently be executed. Depending on the configuration, certain conditions and actions cannot be executed, for example, MQTT messages cannot be responded to if no MQTT connection is configured.

Example
# $HOST e.g. warp-AbCd

Read

curl http://$HOST/automation/state
{
"registered_triggers": [1, 2, 3, 5, 6, 9, 10, 11, 18],
"registered_actions": [1, 2, 3, 4, 5, 6, 7, 8],
"enabled_triggers": [1, 2, 6, 11, 18, 10, 5],
"enabled_actions": [1, 3, 4, 5, 6, 8, 7]
}
NameDescription
registered_triggers
int[19]

Conditions known to this firmware (union tags of the trigger of a rule from automation/config).

  • [0..18] - A known condition.
registered_actions
int[16]

Actions known to this firmware (union tags of the action of a rule from automation/config)

  • [0..15] - A known action.
enabled_triggers
int[19]

Currently executable conditions (union tags of the trigger of a rule from automation/config). Is always a subset of registered_triggers.

  • [0..18] - An executable condition.
enabled_actions
int[16]

Currently executable actions (union tags of the action of a rule from automation/config). Is always a subset of registered_actions.

  • [0..15] - An executable action.



automation/config

The configuration of the automation.

Example
# $HOST e.g. warp-AbCd

Read

curl http://$HOST/automation/config
{
"tasks": [
{
"trigger": [1, { "mday": -1, "wday": 9, "hour": -1, "minute": 10 }],
"action": [1, { "message": "Hello World!" }]
},
{
"trigger": [
18,
{ "method": 4, "url_suffix": "garage_door", "payload": "open" }
],
"action": [
2,
{
"topic": "door/control",
"payload": "1",
"retain": false,
"use_prefix": false
}
]
}
]
}

Configure two tasks:

  • (Trigger 1) On weekends (wday 9), 10 minutes (minute 10) after each full hour,
    (Action 1) show Hello World! in the event log.
  • (Trigger 18) When an HTTP-GET, POST or PUT request (method 4) with content "open" is received at URL http://$HOST/automation_trigger/garage_door,
    (Action 2) send MQTT message 1 to topic door/control.

Write

curl http://$HOST/automation/config -d '{
"tasks": [
{
"trigger": [1, { "mday": -1, "wday": 9, "hour": -1, "minute": 10 }],
"action": [1, { "message": "Hallo Welt!" }]
},
{
"trigger": [
18,
{ "method": 4, "url_suffix": "garage_door", "payload": "open" }
],
"action": [
2,
{
"topic": "door/control",
"payload": "1",
"retain": false,
"use_prefix": false
}
]
}
]
}'

or abbreviated:

curl http://$HOST/automation/config -d '[
{
"trigger": [1, { "mday": -1, "wday": 9, "hour": -1, "minute": 10 }],
"action": [1, { "message": "Hallo Welt!" }]
},
{
"trigger": [
18,
{ "method": 4, "url_suffix": "garage_door", "payload": "open" }
],
"action": [
2,
{
"topic": "door/control",
"payload": "1",
"retain": false,
"use_prefix": false
}
]
}
]'
NameDescription
tasks
object[14]

Configured rules

  • [0..13] - An automation rule
NameDescription
trigger
Union

Condition that must be met for the action to be executed

null: No condition configured.

action
Union

Action to be executed

null: No action configured.