@Burningstone this is so far what I have, any feedback on this or if there’s a bettery way
I have a sensor that combines the data from two sensors to give me what the current value is on, off, auto start/stop
- platform: template
sensors:
generator_start_stop:
friendly_name: Generate Start/Stop State
value_template: >
{% if states.sensor.generator_auto_start_stop and states.sensor.generator_manual_start %}
{% if is_state('sensor.generator_auto_start_stop', '1') and is_state('sensor.generator_manual_start', '0') %}
Auto Start/Stop
{% elif is_state('sensor.generator_auto_start_stop', '0') and is_state('sensor.generator_manual_start', '0') %}
Off
{% elif is_state('sensor.generator_auto_start_stop', '0') and is_state('sensor.generator_manual_start', '1') %}
On
{% elif is_state('sensor.generator_auto_start_stop', '1') and is_state('sensor.generator_manual_start', '1') %}
On
{% else %}
N/A
{% endif %}
{% else %}
N/A
{% endif %}
Then I have an input select with corresponding values:
input_select:
generator_start_stop:
name: Generator
options:
- "On"
- "Off"
- "Auto Start/Stop"
icon: mdi:target
Then I have an automation which syncs the input_select to the sensor value:
- alias: 'Update Generator Input'
trigger:
- platform: state
entity_id: sensor.generator_start_stop
action:
service: input_select.select_option
data_template:
entity_id: input_select.generator_start_stop
option: "{{ states('sensor.generator_start_stop') }}"
Now if I want to use the input select to change the state, I have a automation that fires a script for each state:
- alias: Generator Input Select Off
trigger:
- platform: state
entity_id: input_select.generator_start_stop
to: 'Off'
action:
- service: script.turn_on
data:
entity_id: script.generator_off
- alias: Generator Input Select On
trigger:
- platform: state
entity_id: input_select.generator_start_stop
to: 'On'
action:
- service: script.turn_on
data:
entity_id: script.generator_on
- alias: Generator Input Select Auto
trigger:
- platform: state
entity_id: input_select.generator_start_stop
to: 'Auto Start/Stop'
action:
- service: script.turn_on
data:
entity_id: script.generator_auto
And one of the scirpts looks like this:
generator_off:
alias: 'Generator Off Script'
sequence:
- service: mqtt.publish
data:
topic: "N/b827eb57c4de/settings/0/Settings/Generator0/AutoStartEnabled"
payload: '{ "value": 0}'
- service: mqtt.publish
data:
topic: "N/b827eb57c4de/generator/0/Generator0/ManualStart"
payload: '{ "value": 0}'
It seems to work, but I’m of course wondering if there is a cleaner/simpler way to implement. Any feedback appreciated