I know, I’m a disaster but I keep on trying in creating my configuration. I have created a template switch which activate a script for powering on a light and another one to power it off.
Both scripts are working fine but the Switch is only powering on the light, because after few seconds the switch itself goes to off (and the light stays on).
I think the problem is the value_template, but I don’t know how I should address this problem.
Thanks but I don’t have any script.turn_on object defined… and I have multiple scripts, I cannot have them all with the same name.
I did try your suggestion, by enabling also the entity id, but I still have the same problem.
The Switch immediatelly go back to off, with the light staying on.
Nothing. It switches on the light but the “switch button” goes back to the off position immediately and the light stay on. Something is preventig the switch to stay on the ON position.
ive never tried to use the state of the switch itself as the value template for the same switch, let me do some testing and see if i can get it to work
Thanks a lot for your help. Really appreciated.
In all my test, I’ve also seen a strange thing with Script. If I had a delay option, the UI shows the toggles button instead of the ACTIVATE link. Any idea if this is a bug or the script can be also used as a switch ?
It depends on how many services you have attached to your script, for example if you just have 1 service to power off the devices, then it will show ACTIVATE, but if you say turn off 2 devices or something where you call more than 1 service in the script, it shows a toggle instead.
I didnt even know that, thats great!! Do you happen to know if you can use the actual switch for the value template of that switch? i was unable to get it to work either…
Hi,
thanks for the help. I’m trying to create switches for the Harmony Hub device, which I’m using to control the lights and cover control in the living room.
For doing that I need to send specific command and I’m not using the activities.
It seems I can only send command with script and nothing else.
When you say about the light state, do you have a simple example ? I couldn’t find anything easy to understand.
Hi pplucky, I don’t have any entity id for the light. I only have the entity of the IR Controller, which is capable of sending specific commands to the IR sensor in the living room and activate lights, covers and so on.
So I don’t have any entities for each lights or cover, only the remote controller.
I saw there is something specific for Harmony HUB on HA, but it is only able to control activity, not single command which I need.
That’s why I’ve started creating script for the Harmony HUB command and now I would like to create switches on top of them to properly use them for the lights, cover…
Have you looked at the send_command service for the Harmony Hub Remote component? I don’t have such a device, but by the description it looks like being able to do what you want/need:
Send Command: Send a single command or a set of commands to one device, device ID and available commands are written to the configuration file at startup. You can optionally specify the number of times you wish to repeat the command(s) and delay you want between repeated command(s).
Maybe someone else who also owns such a device can help you more, sorry.
I don’t know if you use MQTT, but if you can create an MQTT switch (similar to the one I have shown above), you could use the script and call it in an automation when the MQTT switch was turned on/off.
What you would need to make sure is that you also change the MQTT state topic value accordingly (so that your switch displays the state of your light) in the automation itself.
This way your script would serve to physically turn on/off via the automation and the MQTT switch would serve to show the light status and logically turn on/off (triggering the automation).
Hi !
Thanks for the suggestion, I will also try your solution but I’m not very familiar with MQTT.
Yesterday I’ve put togheter this:
input_boolean:
light_main_left:
name: Controls Main Left Light
initial: off
cover_main_right:
name: Controls Main Right Cover
initial: off
- alias: 'Prova Beamit Tapparella Su'
trigger:
platform: state
entity_id: input_boolean.cover_main_right
state: 'on'
action:
service: script.beamit_a5on
- alias: 'Prova Beamit Tapparella Giu'
trigger:
platform: state
entity_id: input_boolean.cover_main_right
state: 'off'
action:
service: script.beamit_a5off
In this way I have the switches and it seems to work fine. Now the question is, do because this script are driving lights and cover, is there a way to change the icon and have the correct one ? So, light “switch” style and same for cover ?