I need to turn on a toggle switch that is already turned on.
A couple of situations:
Voice assistant turn on the Kettle (it won’t boil if the switch is already in the ON state)
Voice assistant turn off computer screens (they won’t turn off if the switch is already in the OFF state)
What is the best way to approach this needing to be able to turn a switch on or off that is already in the same state I need it to trigger?
A push button is not the answer because I also want to be able to turn on the computer screens or turn off the kettle.
Sometimes I show the voice control kettle to guests “Voice assistant turn on kettle” and then “Voice assistant turn off kettle”. Sometimes I trigger the kettle “Voice assistant turn on kettle” and don’t bother to turn off the switch.
The next time I go to to say “Voice assistant turn on kettle” I want it to work if I haven’t turned the switch off.
I doubt you ice the kettle for more than say 5 minutes. Why not have an automation that turns it off after 5 it so minutes if it’s on longer than that.
I disagree. I suppose in your case you are working wit no correct state at all (or assumed state?). Using a switch means HA needs to be aware of the state. If you can’t provide that you shouldn’t work with switches but services or scripts. You can also integrate scripts with voice assistants. If you want to use a switch you need to provide a correct state, by either polling the state or working with automations as explained above.
Ok so I say “Voice assistant turn on bedroom light” but someone turned it off manually last time and the switch in home assistant is still turned on, as a result the bedroom light does not turn on…
I recently changed my home from Domoticz to Home Assistant. In Domoticz a switch could be triggered multiple times (for example if it was ON it could be turned ON a second time without first having to turn the switch off).
homeassistant:
name: Home
unit_system: metric
# etc
customize:
# Add an entry for each entity that you want to overwrite.
input_boolean.kettle:
assumed_state: true
fire_event: true
Then to get an automation to trigger each time I turn the switch on without first having to turn it off, I tell the automation to listen for an EVENT, here is my automation yaml (example)
When you operate something manually, the correct state should be reflected in Home Assistant. If it’s not, then you’re not addressing the root problem.
The event listener can trigger even if already ON it does not need to go from OFF to ON or ON to OFF, it can trigger when a device turns ON and then ON again (even though the device history log will not show the multiple ON events), the event listener can see each ON event. Watch in: Developer Tools > Events, in “Listen to Events” enter “call_service” and press “Start Listening”, now trigger a boolean switch multiple times in the same state “example: voice assistant turn on x, voice assistant turn on x”. You should see both entries in the listener
Note that I believe the configuration.yaml modification (posted in one of my previous posts) for the boolean switch is needed before it will show in the event listener although I have not tested this so am not certain.
I can now say “Voice assistant turn on kettle” again and again and it turns on the Kettle just like it’s supposed to. I also have the flexibility of saying “Voice assistant turn off kettle” and it can turn off the kettle.
If I understood your explanation correctly, input_boolean.kettle is the entity that your voice assistant believes to be your actual kettle. When you tell the voice assistant to turn on the kettle it executes an input_boolean.turn_on service call. However, if input_boolean.kettle is already on then it would fail to trigger a State Trigger because there’s no state-change involved. Therefore you are using an Event Trigger to listen for the service call (input_boolean.turn_on) as opposed to a State Trigger listening for a (non-existent) state-change.
Is that a correct interpretation of what you have done?