By not specifying a state, the automation will get triggered by any state change to switch.remote1 STATE TRIGGER
Triggers when the state of a given entity changes. If only entity_id is given trigger will activate for all state changes, even if only state attributes change.
Thank you for the reply, but I think you misunderstood my question. (or mayby my question was to complex )
Another try:
How do I change the state of switch.remote2 to ‘off’ (in the action section), but not trigger an event.
As an example the script below.
Presuming remote1, 2 and 3 are all ‘on’.
When pressing the off-button on switch.remote1 , switch.remote2 must set to ‘off’, but must not trigger the event for switch.remote2. So switch.remote3 stays in state ‘on’.
alias: ‘Remote1’
trigger:
platform: state
entity_id: switch.remote1
to: ‘off’
action:
service: switch.turn_off
entity_id: switch.remote2 ## << This triggers the script below and is not what I want. Just set the state to off.
alias: ‘Remote2’
trigger:
platform: state
entity_id: switch.remote2
to: ‘off’
action:
service: switch.turn_off
entity_id: switch.remote3
you can switch off the automation in the first part :
- alias: Remote1
trigger:
- platform: state
entity_id: switch.remote1
to: off
action:
- service: homeassistant.turn_off
entity_id: automation.remote2
- delay: 00:00:03
- service: switch.turn_off
entity_id: switch.remote2 ## << This triggers the script below and is not what I want. Just set the state to off.
- service: homeassistant.turn_on
entity_id: automation.remote2
or use input_boolean in combination with conditions
See if the following works for you (use the IP of your HA; you will need curl installed). It will change the state in HA but won’t actually trigger the switch to off (as I think it would need state to be “Off” instead of “OFF”)
curl -X POST -d '{"state": "OFF"}' http://127.0.0.1:8123/api/states/switch.remote2
Thanks!
I want to change the state of my fan which is both controlled by Broadlink RM pro and the remote of the fan itself so that can correspond to the actual state of the button color.
I have add a power monitor plug used for judging the state. But I can’t find a better way to change the state of the entity: switch.fan_power
I’m pretty much in the same situation except that I plan to use Tasmota IR with both IR blaster and IR receiver placed near the fan instead of Broadlink RM (as Broadlink doesn’t do passive recording of IR codes, while Tasmota IR would update HA with all IR commands received case the IR physical remote was used).
I’ve tried Tasmota IR on both split AC and cheap fan with a regular NodeMCU and separate IR blaster and receiver and it works fine (at least with the split AC as it successfully recognized most commands that I needed to setup the HVAC component).
The fan remote uses toggle instead of discrete commands which is not very useful as it is not easy to know the state; as you mentioned, a power monitor plug would provide feedback when it is working, however I don’t know if it would reliably identify different fan speeds or swing motion.
I also ran into the same issue with my IR-controlled AC. Trying to ‘correct’ the status of the AC created an infinite loop (because when I corrected the state the on/off would fire and make it out of sync again).
I solved it by creating input_boolean.AC_status, and tied the switch.AC status to that. When the AC is manually controlled, an energy monitoring plug detects the change and then the input_boolean.AC_status is updated which changes the switch.AC without sending the on/off commands.
Configuration.yaml:
##AC as a switch entity
#boolean helps to enable watchdog automation to toggle switch.ac w/out triggering the on/off command
input_boolean:
ac_status:
name: AC Status
icon: mdi:air-conditioner
switch:
- platform: template
switches:
living_room_ac:
friendly_name: AC
icon_template: "mdi:air-conditioner"
value_template: "{{ is_state('input_boolean.AC_status', 'on') }}"
turn_on:
- service: script.turn_on
entity_id: script.ac_power
- service: input_boolean.turn_on
entity_id: input_boolean.ac_status
turn_off:
- service: script.turn_on
entity_id: script.ac_power
- service: input_boolean.turn_off
entity_id: input_boolean.ac_status
Value_template ties switch.AC to the input_boolean.AC_status. The switch.AC on/off commands also update the input_boolean.AC_status.
AC Watchdog correction automation:
alias: "[AC] Watchdog to correct AC on/off status"
description: ""
trigger:
- platform: numeric_state
entity_id: sensor.ac_power_outlet_active_power
for:
hours: 0
minutes: 0
seconds: 5
id: AC turned On
above: 0.8
- platform: numeric_state
entity_id: sensor.ac_power_outlet_active_power
for:
hours: 0
minutes: 0
seconds: 5
id: AC turned Off
below: 0.8
enabled: true
condition:
- condition: or
conditions:
- condition: and
conditions:
- condition: trigger
id: AC turned On
- condition: or
conditions:
- condition: state
entity_id: switch.living_room_ac
state: "off"
- condition: state
entity_id: input_boolean.ac_status
state: "off"
enabled: false
alias: Either AC or AC_status are off
alias: Turned on but AC is off
- condition: and
conditions:
- condition: trigger
id: AC turned Off
- condition: or
conditions:
- condition: state
entity_id: switch.living_room_ac
state: "on"
- condition: state
entity_id: input_boolean.ac_status
state: "on"
enabled: false
alias: Either AC or AC_status are off
alias: Turned Off but AC is On
action:
- if:
- condition: trigger
id: AC turned On
then:
- service: input_boolean.turn_on
data: {}
target:
entity_id: input_boolean.ac_status
enabled: true
- if:
- condition: trigger
id: AC turned Off
then:
- service: input_boolean.turn_off
data: {}
target:
entity_id: input_boolean.ac_status
mode: single
Triggers based on power consumption whenever the AC is turned on/off. You’ll need to correct this for your specific AC’s power consumption and it might not work depending on your AC unit. Then conditions check to make sure that the status is incorrect, then actions correct the input_boolean.AC_status which then updates the