Skip to content
Snippets Groups Projects
Commit d87770d9 authored by Ellis Percival's avatar Ellis Percival
Browse files

Publish initial output value. #125

parent 283d9ad5
Branches
Tags 18.3.0
No related merge requests found
......@@ -275,6 +275,10 @@ digital_outputs:
type: boolean
required: no
default: no
publish_initial:
type: boolean
required: no
default: no
sensor_inputs:
type: list
......@@ -306,6 +310,9 @@ sensor_inputs:
required: no
default: 2
min: 0
unit_of_measurement:
type: string
required: no
stream_reads:
type: list
......
......@@ -279,6 +279,10 @@ digital_outputs:
type: boolean
required: no
default: no
publish_initial:
type: boolean
required: no
default: no
sensor_inputs:
type: list
......
......@@ -1110,6 +1110,15 @@ def main(args):
for out_conf in digital_outputs:
initialise_digital_output(out_conf, GPIO_MODULES[out_conf["module"]])
# If configured to do so, publish the initial states of the outputs
initial_setting = out_conf.get("initial")
if initial_setting is not None and out_conf.get("publish_initial", False):
payload = out_conf["on_payload" if initial_setting else "off_payload"]
client.publish(
"%s/%s/%s" % (topic_prefix, OUTPUT_TOPIC, out_conf["name"]),
retain=out_conf["retain"],
payload=payload,
)
for sens_conf in sensor_inputs:
try:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment