Hello to all,
I’m new to this great community and would like to share a workaround for the eWelink integration bug:
When you try to create an automation with the eWelink Sonoff smart switch, eg. “Action:” call service → switch.toogle → entity (switch), the automation will not work, or rather it will not be able to find the switch. In the Home Assistant Log you can read this " Unable to find referenced entities switch.XXXXXX".The cause of this error is an integration bug and you can read the developer’s POV on their github…
How to? You can call a simple script as a service in your automation:
Copy the script code into your scripts.yaml:
'1234567890123': #edit this key
alias: Toggle eWelink
sequence:
- choose:
- conditions:
- condition: state
entity_id: &device switch.XXXXXXXXX #change the switch ID (find it in state tab under developer tools)
state: 'on'
sequence:
- service: switch.turn_off
entity_id: *device
- conditions:
- condition: state
entity_id: *device
state: 'off'
sequence:
- service: switch.turn_on
entity_id: *device
and in action of your automation.yaml:
action:
- service: script.turn_on
target:
entity_id: script.1234567890123 # copy here the script key
mode: single
WARNING: Do not modify the script with the UI editor, because HA reformats the code and causes the script stop
I hope this can help someone…
Notes:
If the problem has already been discussed and solved, please apologize in advance for the uselessness of my post.
I’m not english, sorry for my bad grammar.
Tested on:
Home Assistant 2021.11.5
Alvaro