Rhasspy and node red

Hello,
I tried to check node red and after a day of learn & try I’m not sure it is better and simpler than intent_scripts.yaml.

To turn a specific light in intent scripts I use this short code:

ChangeEntityState:
  action:
    - service: rest_command.rhasspy_speak
      data_template:
        payload: turning {{ entity_state }}
        site: '{{ site_id }}'

    - service_template: >
        {% if entity_state == 'on' %}
          homeassistant.turn_on
        {% else %}
          homeassistant.turn_off
        {% endif %}

      data_template:
        entity_id: "{{ entity_name }}"

When trying in node red I had to add switch for each of the lights and for every light a switch for on and off.
I there a more simplek and smarter node red sequence that can do the same?

this can be

- service_template: >        
      homeassistant.turn_{{ entity_state }}

For Node-Red I suggest you use the call service node and provide the site_id and entity_state via a mustache template. (drag the call service node and check the documentation tab on it)

Cad you give me an example so I can have a starting point?

Here is a link to the documentation about mustache templates:

https://zachowj.github.io/node-red-contrib-home-assistant-websocket/guide/mustache-templates.html

This works for lights:

Event node:

Call service node:

Adjust as you need :slight_smile:

In my case location and action are slots, you need entity_state and entity_name from the event object (payload.event)

Probably I’m missing something.
How should I configure Rhappsy to send events?
Right now I use external MQTT in Rhappsy.
The MQTT is an addon in HASS.

Server

Satellite

It’s under intent handling, you should set it to Home Assistant and check the send events checkbox
Set it on the server

Still doesn’t work

I set home assistant to events on rhasspy server

image

image

image

What is your setting on the event node?
Does Rhasspy actually send an event?

I see the intent in the debug screen
image

You have an event node, but Rhasspy is sending intents.

Make sure you have checjed the send events checkbox

Couldn’t make it work with events so returned to intents.

It workes if I define a specific entity.

When I try to populate it dynamically it fails

image

The service should be:

turn_{{payload.intent.something}}

I do not know what something is, because I cannot see that in your screenshot.
payload.intent is the object, payload is the message payload.

the “sonething” is what I son’t know :slight_smile:!

it would be slots.entity_state if your slot is called entity_state.

that’s what I thought, but it doesn’t seem to work :frowning:

Is the message you showed in the previos post the one going to the node?

this is the way to do it:
turn_{{slots.entity_state}}

Was the problem that you used turn_{{{slots.entity_state}}} or that you used payload.intent.slots.entity_state ?

It didn’t work with this: {{payload.intent.slots.entity_state}}
worked with this: {{slots.entity_state}}

You figured it out despite my previous message not being clear enough. I meant it as the complete part and not the “something” you were asking for. You only get the information under payload when using mqtt. I am also using the websocket and node-red for my intent handling so i can help if you have more questions concerning that part. I am using fhem and not homeassistant for my homeautomation so i cant help with questions specific to the homeassistant nodes.