@ItsMee wrote:
Hi,
the automation of my garden watering works so far:
- exernal script with logic determines water amount per relais & populates a sensor
- input_number shows those values in an user editable way
- external script sends updates (e.g. if temperature raises over the day) - those update the input_number to reflect the change
- input_number state change trigger an MQTT message that will tell ‘manual user overwrite’ to the external script
All that works fine - with the exception that the state change could be originated from a user change (in that case I want the MQTT message & stop the script from doing further changes) or by the script (in that change - no MQTT message so the script will not stop calculation.
Not sure if that’s very clear. Basically I’d love to have an option in below automation to determine if the trigger was caused by a UI change - or via automation.
Trigger MQTT on (UI sourced) change of input_number
- alias: arti2mqtt trigger: - platform: state entity_id: 'input_number.inb1' [..] - platform: state entity_id: 'input_number.inb8' action: - service: mqtt.publish data_template: topic: "artirain/homeassistant2db" payload_template: '{"KEY":"{{trigger.from_state.attributes.friendly_name | replace("Kräuterbeet","ART_MIN_R1") | [..] | replace("Vorgarten Beete","ART_MIN_R8" ) }}", "VALUE": "{{ trigger.to_state.state}}", "TS": "{{now().year}}-{{now().month}}-{{now().day}} {{now().hour}}:{{now().minute}}:{{now().second}}", "SENSOR_TYPE":"ARTIRAIN-MANUAL", "OBJECT":"ARTIRAIN", "SENSOR":"HOMEASSISTANT", "UNIT":"min" }'
Alternativly I could create a temporary variable in the automated update of the input_number (e.g. 'AUTOMATED_UPDATE_IN_PROGRESS=1 | 0) and change that before and after the automated change. With that I could include an if statement in the mqtt posting. However, that doesn’t sound very elegant.
Populate external script change into input_number
- alias: ArtiRainRelais1Change trigger: - platform: state entity_id: 'sensor.krauterbeet' - platform: homeassistant event: start action: service: input_number.set_value data_template: entity_id: input_number.inb1 value: "{{ states('sensor.krauterbeet') | float }} "
Thanks for your thoughts!
ItsMee
Posts: 1
Participants: 1