But after a few secconds the switch turns off again. Now I have the idea to create a dummy entity to save the state. But I don’t know how and if this is the correct way.
Sorry to revive this thread but I am looking for the exact same thing but can’t figure it out on my own.
So I recently asked for help about activating a switch that runs a script (post) and it runs perfectly but the problem is this switch reads the state from the script but the script itself never reports its state so when I turn it on, it will immediately revert to OFF after it runs.
Anyone could be so kind to post an example of what I need to make this switch report and keep its state? I’ve never used an input boolean before as the answer in this topic suggests so its all new to me.
The reason this switch doesn’t keep its state is it’s meant to be a toggle switch. It displays on while the script is running then turns off. Since most fans don’t have a discrete input for power on and power off, just power toggle, this was designed to act as such.
Input_booleans are essentially the same thing as switches, just manual switches. The other method I directed you to, basically figures the state of the fan by always turning the speed down to the minimum and then turning the power toggle off. It manages the state better but that’s if you “throw the remote away” and just use HA.
Is there a reason you can’t use input_booleans with HA_dashboard? If you can’t, then you could always add a template switch which follows the on/off of the input_boolean
@Jer78 I understand it now. I can use input_booleans in HADashboard but the post you linked me is way above my head as I am just starting out with HA. I would prefer the suggestion in your last paragraph as I’m already half way there with the switch and script.
Could you provide an example how I could achieve that and any modifications I need to make to my existing code?
@junior466 My suggestion was only if HADashboard couldn’t use input_booleans and you had the more complicated code working but just needed to use a switch. But since that’s not the case, here’s the easiest way to accomplish what you’re asking. You’d use an input_boolean and automation like this:
Hi sorry to bring this back -Im using tuya switches and they’ve been less that ideal since the api change.
The switches are not remembering their state similar to that of the others mentioned previously .
Ive grouped the switches together using a Template switch but still the same issue of remembering the state. Ive put together the code you’ve mentioned was curious if this would work or if im missing something to remember the off state.
- alias: 'TV Lights'
initial_state: off
trigger:
platform: state
entity_id: input_boolean.tv_lights
action:
- service: switch.turn_on
entity_id: switch.tv_lights