Toggle on/off alarm

I have the intent working in HA [speaks the sentence] it’s the actual sentence and getting it to toggle is the issue… Little help please :slight_smile:

turn (on)(alarm):alarm_control_panel.blink_johns_house

turn (off)(alarm):alarm_control_panel.blink_johns_house

Its a little hard to be sure because I’m not exactly sure what you are trying to speak to Rhasspy and what you want the output to be to HA. But if you are trying to send the entity id to HA, that should go after the word “on” or “off”. The : tells rhasspy to send that value instead of what was spoken. So I thin tou want something like:

turn (on):alarm_control_panel.blink_johns_house{alarm}

Also the slot name should use curly braces I think. If I got this right what would be sent to HA is the AlarmOn intent with “alarm_control_panel.blink_johns_house” as the value in the slot named “alarm”.

Hopefully that helps.

John I am also confused by what you are trying to achieve here - possibly because your use of the word “toggle” doesn’t seem consistent with your [AlarmOn] and [AlarmOff] intents.

FYI, the light and switch domains (and probably others) have a “toggle” service as well as turn_on and turn_off.
Screenshot from 2022-12-28 17-27-56
If the switch is currently on, toggle will turn it off; and if switch is currently off, toggle will turn it on.
Turn_on will set the switch to on whether it is already on or off.

See Training - Rhasspy for sentences.ini syntax

The round brackets () are used to group multiple words, or group alternative words … neither of which seem to apply in your code.
The colon (:slight_smile: indicates a synonym; which also doesn’t look right.

Do you have multiple alarm devices ? If not, you could just have intent [AlarmOn], say “turn on the alarm”, and code the HA automation to arm the alarm device.

If you have multiple alarm devices you will want to pass its name in a tag (using curly brackets{}), like

turn on (house | garage){name} alarm

Alternatively you might be trying to have one intent to turn your single alarm on or off

turn ( on | off ){state} alarm

or you could combine both :wink:

1 Like

Yes the combination works but I’m trying to figure out how to actually turn the alarm on which is:


That’s the Home Assistant entity I need to ‘toggle’ or ‘turn on’ or ‘off’

It comes back with the sentence but I’m trying to figure out where do I actually put the command to turn on or off?
In HA Intent? Or in the Sentence…

That’s where I"m confused
Thank you
Happy New Year

So this is what I have in total:


alarm = $hass/alarm
turn ( on | off ){state}alarm{name}

HA intent in HA Config: [which still needs a bit of work]

      text: >-
        {% set sensor = "alarm_control_panel.blink_johns_house" %}        
        {% if sensor ==  "disarmed" %}
        The Alarm is now disarmed
        {% elif sensor == "armed_away" %}
        The Alarm is now armed
        {% endif %}

Rhasspy slot:


I say ‘Turn off the alarm’ and it returns off for state and when I say ‘Turn on the alarm’ it returns on as the state
and this returns:

But it never turns the alarm on… I believe if I’m correct the ‘toggle’ isn’t on or off it’s
arm away and disarm on the HA side…

So that’s where I am right now :slight_smile:
Still missing something simple I’m sure but being new at this I’m trying to learn

Sorry John, my mistake ! Most people get stuck well before the point of actioning the voice command, so well done !

As always with computers, there are several ways to achieve the same objective. There are 3 options for “Intent Handling” with Home Assistant. I have since changed to doing all my automations in node-RED (another learning curve, so I’m not recommending it for you now), but I started using Home Assistant Intents.

In the “settings > Intent Handling” section at the Rhasspy which is detecting the voice commands,

Enter the URL for your Home Assistant including port :8123 and select “Send Intents”. I needed to also setup a HA “Long-Lived Access Token” (at the very bottom of your Profile at very bottom left corner of your HA page) but you may not.

You now need to edit the HA “/config/configuration.yaml” file and add the keywords “intent:” and “intent_script:” before your HA intents.

My own example of turning lights on|off the intent code was

    text: Turning {{ name }} {{state }}
    - service: light.turn_{{ state }}
        entity_id: light.{{ name | replace(" ","_") }}

I don’t have an alarm myself, but it looks to me as though you want to perform the action of arm or disarm your alarm, and that according to HA Developer Tools

select your entity, then click [YAML Mode] to see the action you want your intent to perform.

Putting it all together I believe you want

      text: The Alarm is now {{state }}
      - service: alarm_control_panel.alarm_{{ state }}
          entity_id: alarm_control_panel.blink_johns_house
          code: "1234"

This then leaves a small issue … that you are currently passing in {name} with value or “alarm” which is not used, and {state} with a value of “on” or “off” - but the service you want to perform is called “alarm_arm_away” or “alarm_disarm”. The “alarm_” prefix is common, so I suggest the easiest fix here is to go back to your sentences.ini file and add substitutions for on and off, such as:

turn ( on:arm_away | off:disarm ){state} [the] alarm
( arm:arm_away | disarm ) the alarm

Sorry for the long post, but I found that -while all the information is in the rhasspy documentation - it is not so easy to find the bit you want when you need it :frowning:

1 Like

Thank you so much, I’m going to reread this a few times to see I can make some things stick :slight_smile:

I’m getting there :slight_smile:

Had the Intent Handling all setup the way you showed already so I was good there :slight_smile:
Your light example is very nice!!!

My Intent section in HA config was good as far at intent: and intent_script:
Had to really fix the AlarmChangeState to your example but the beauty of that is I can also see how HA sees this so Thank you!

This then leaves a small issue … that you are currently passing in {name} with value or “alarm” which is not used, and {state} with a value of “on” or “off” - but the service you want to perform is called “alarm_arm_away” or “alarm_disarm”. The “alarm_” prefix is common, so I suggest the easiest fix here is to go back to your sentences.ini file and add substitutions for on and off, such as:

YES!! Perfect!!

The sentence example you give is excellent!!! NOW I can use that to develop my ‘talents’ further :slight_smile:

Node Red? Yeah I looked at that a few months back and installed it and said ohhhhhhh I gotta read a lot more to get this LOL.

Thank you so much for your help!!!

OH and the action between the command and actually arming or disarming is really quick!!!

Local control :wink:

I personally struggled with programming automations in YAML, and haven’t looked back since I swapped to node-RED - but it is yet another learning curve … and the biggest lesson by far that I have learnt is to stick to one learning curve at a time. It’s like going over one hill at a time; but when the next hill starts before the previous has finished, they quickly become a mountain.

I’ll get there but right now I’m trying to get a handle on this :sweat_smile:

Node red is a hill i will take on at some point but not right now.

1 Like