Looking for safe, consistent voice behavior: check state before on/off (+ confirmation)

Hi everyone :wave:

I’m trying to get a consistent “safe” behavior from my voice assistant in Home Assistant and would love to know if there’s a built-in or recommended way to do this.

What I want (for any entity):

When I say things like:

  • “Turn on the boiler”
  • “Turn off the living room light”
  • “Turn on the bedroom AC”

I want HA / the voice assistant to:

  1. Check the current state first.
  2. If the entity is already in the requested state:
  • Do not change anything yet.

  • Respond with something like:

    • “The boiler is already on, do you still want to turn it on/change it?”
  • Wait for an explicit yes/no.

  • Only if I confirm → perform the action.

  1. If it’s not in the requested state:
  • Just run turn_on / turn_off normally and confirm.

Goal: avoid blindly toggling things that are already on/off (boiler, AC, doors, etc).

Context:

  • I’m currently using Gemini as my AI agent.
  • I know this can be “prompt engineered” (HassGetState before HassTurnOn/Off), but in reality the LLM doesn’t always follow the rules, so it’s not reliable as a safety layer.

What I’m looking for:

  • Is there any simple / built-in / officially recommended pattern for this?

    • For example using Assist, assist_satellite.ask_question, sentence triggers, or a specific agent setup.
  • Any community-proven examples (GitHub / blueprints / intent_script) of:

    • A single guarded on/off intent/script
    • That checks state, asks for confirmation if already matching, and only then executes.

If you have links to working examples or best practices (with Gemini or with Assist-only), I’d really appreciate it. :pray:

Turn on command uses light.turn_on, switch.Turn_on or similar. Basically it turn ON the item requested to be turn ON.

If the device is already on it does Not toggle it off. Both toggle and off are distinct and separate commands.

Turning ON a device that is ON results in nothing. I’m pretty sure it doesn’t register as a state change but I would need to verify.

With this, what your asking seems unnecessary

Since you are using LLM, you should add the check in your prompt

If I ask you you to turn a device On check if device is ON. If it is on take no action and just respond. The device is already on….something bettter but basically that

I tried to formulate it in his instructions but it doesn’t happen. And secondly, there are cases like in the Wheeler, if someone is at home, I turn it on for a certain time and you turn it on again without knowing it’s not working.

Build a custom voice command for special cases