I have an IR based Sony Subwoofer, I am monitoring it’s state based on Power Consumption using Smart Plug, but I don’t want the turn on command to repeat if it’s already on.
# Subwoofer Power ON/OFF based on energy consumption
- platform: template
switches:
living_room_subwoofer:
value_template: "{{ states('sensor.subwoofer_plug_ma') | int > 50 }}"
turn_on:
service: switch.turn_on
data:
entity_id: switch.htc180_turn_on_off
turn_off:
service: switch.turn_off
data:
entity_id: switch.htc180_turn_on_off
What you have created here is a switch, now you need an automation to turn it on/off. In your automation you can have a condition template that states if, off then continue with the automation:
conditions: "{{ states('sensor.subwoofer_plug_ma') | int < 51 }}"
So, if your device is already on, this automation would not continue.
You can add as many services as you want to the turn_on and turn_off options. They are like little scripts, you can use all the valid script syntax, including in-line conditions.