Steps to trigger node-red flow from home assistant

Dear all,
i recently started to play with Home assistant and node-red.
I used a node-red integration to handle my rollorshutters and I’m already able to manage from node-red itself by inject node.
Now i want to trigger it from home assistant (lovelace).
my idea is to use slider-entity-row to do something like
image

  • type: entities
    show_header_toggle: false
    title: Tapparelle
    entities:
    • entity: cover.tapparella_cucina
      name: Tenda sala
      icon: mdi:blinds
    • type: custom:slider-entity-row
      entity: cover.tapparella_cucina
      full_row: true

but i don’t have an entity (like cover.tapparella_cucina) because there is no any home assistant integration that is creating deivces or entities about that.
So, which are the main step i need to do?
i need to create some “empty” entities to link to slider-entity-row and then detect the event related to the UP/DOWN button pressed in node-red or…?

many thanks to who had a short time to give me some hints

thanks
bye
Marco

Hi,

I’m also facing same question. Maybe You find solution for it?

In our home we have recuperator which I can control via HTTP requests. I’m want to use Node Red for requesting needed info from it. Main usage would be to set fan speed. I also like to use slider to set fan speed with this custom integration: https://github.com/thomasloven/lovelace-slider-entity-row.

I’m trying to create “dummy” entity in home assistant using template, but can’t figure out how to configure template so Node Red could see that state changed:

My YAML configuration:

#Virtual sensors
fan:
  - platform: template
    fans:
      rekuperatorius_state:
        friendly_name: "Rekuperatorius"
        value_template: "{{ states('switch.rekuperatorius_state') }}"
        turn_on:
          service: switch.turn_on
        turn_off:
          service: switch.turn_off
      rekuperatorius_main_fan_speed:
        friendly_name: "Rekuperatoriaus greitis"
        value_template: "{{ states('input_boolean.state') }}"
        speed_template: "{{ states('input_select.speed') }}"
        turn_on:
          service: switch.turn_on
        turn_off:
          service: switch.turn_off
        set_speed:
          service: switch.fan_speed
          data:
            speed: "{{ speed }}"

Using this when I change slider position I only get “Failed to call service fan/turn_off. sequence item 0: expected str instance, Optional found”

I understand that Home Assistant doesn’t know what I want to do when I change the state and I should somehow describe this service, but I’m not quite sure how so Node Red would also know it.

Maybe template is not what I should use? Any help would be very appreciated. Thanks!

You could use either input_booleans, input_select, input_number, etc… to trigger things from lovelace to NR flows. On the other hand, check the “entities” node in NR, perhaps that’s what you’re after.

I would make sure the inputs are the only triggers from those flows. This way, you’ll always have your input updated to the device’s current state.

What are the available speeds of your fan under developer tools/states? do they match the speeds from your “input_select.speed”?

if they do, just do this:

[{"id":"b4a9e6aa.96f5d8","type":"server-state-changed","z":"c84d8f24.23022","name":"Input select","server":"9405c3fe.d0a6c","version":1,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"input_select.speed","entityidfiltertype":"exact","outputinitially":false,"state_type":"str","haltifstate":"","halt_if_type":"str","halt_if_compare":"is","outputs":1,"output_only_on_state_change":true,"for":0,"forType":"num","forUnits":"minutes","ignorePrevStateNull":false,"ignorePrevStateUnknown":false,"ignorePrevStateUnavailable":false,"ignoreCurrentStateUnknown":false,"ignoreCurrentStateUnavailable":false,"x":290,"y":280,"wires":[["2f37505.7c5d1b"]]},{"id":"2f37505.7c5d1b","type":"api-call-service","z":"c84d8f24.23022","name":"fan speed","server":"9405c3fe.d0a6c","version":1,"debugenabled":false,"service_domain":"fan","service":"set_speed","entityId":"fan.your_fan","data":"{\"speed\": \"{{payload}}\"}","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":470,"y":280,"wires":[[]]},{"id":"9405c3fe.d0a6c","type":"server","name":"Home Assistant","addon":true}]

Regarding he dummy entity, again, check out the entity node in NR

Thanks a lot @obaldius for Your answer.

So problem is not on NR side. I just tried to listen all events coming to NR and I can see that when I change fan.rekuperatorius_main_fan_speed state to on - NR receives it. but it doesn’t have speed node in json.

What are the available speeds of your fan under developer tools/states?

As You suggested I tried to check it and my available speeds are “low, medium, high” and speed is null and it never changes. So my configuration is definitely somehow wrong.

Because I’m total newbie with Home Assistant I’m just googling a lot what could I do so my “speed” value change when I change slider position. But I didn’t find any special using of fan template and slider-entity-row plugin.

From default fan template I understand if I didn’t set speeds on configuration.yaml then comes default values “low, medium, high”. I also tried to set

        speeds:
          - '1'
          - '2'
          - '3'

…got same speed_list: low, medium, high

Also tried:

        speeds:
          - min: 0
          - max: 100

Configuration passes validation, so I assume it should be ok. But nothing changes and still if i change slider position from 0-100 on Developer Tools > States > fan.rekuperatorius_main_fan_speed state still leaves off and “speed: null”.

Now I’m back to almost default configuration.yaml fan template.

fan:
  - platform: template
    fans:
      rekuperatorius_main_fan_speed:
        friendly_name: "Rekuperatoriaus greitis"
        value_template: "{{ states('input_boolean.state') }}"
        speed_template: "{{ states('input_select.speed') }}"
        turn_on:
          service: fan.turn_on
        turn_off:
          service: fan.turn_off
        set_speed:
          service: fan.set_speed
          data:
            speed: "{{ speed }}"

But still when I’m changing slider position I got an error: Failed to call service fan/turn_off. sequence item 0: expected str instance, Optional found

My entities card configuration:

type: entities
entities:
  - fan.rekuperatorius_state
  - sensor.rekuperatorius_main_fan_speed
  - fan.rekuperatorius_main_fan_speed
  - type: 'custom:slider-entity-row'
    entity: fan.rekuperatorius_main_fan_speed
    min: 0
    max: 100

So maybe should I describe service fan.turn_off manually so I could select value on slider from 0 to 100?

I’m totally lost here, need some light in the tunnel. Thanks :slight_smile:

Go to Developer tools/services and try the following. Set low/medium/high and hit “Call service” button. Try doing it with the fan off and with the fan on. Does it work? Does it accept low, medium and high? share results and entity_id.

My entity id: fan.rekuperatorius_main_fan_speed

When fan.rekuperatorius_main_fan_speed state is either off or on when I change the state over Developer tools > States, it doesn’t accept no one of the options low/medium/high and shows error:
Failed to call service fan/set_speed. sequence item 0: expected str instance, Optional found

Also tried to create entity without slider-entity-row plugin and got same error, when it’s failing to call service fan/set_speed.

Should I need to describe service fan/set_speed manually? And if yes, then how to do such thing? Thanks :slight_smile:

what’s the name of the actual fan? I believe I don’t understand you :smiley:

I don’t mean the template fan, your actual fan, the device, what’s its name?

Now I also think we didn’t understood each other :slight_smile:

Because I could only send commands to my fan (recuperator) I hope I could create virtual or in other words dummy entity using template. Then using this entity create slider, select slider position in percentage value and send values from HA through Node Red where HTTP request will be made and sent.
From my fan I could only request what is speed right now. All other commands I need to send I didn’t get any response from it.

What I found and understood, that template should be something like virtual sensor creation. I’m wrong about it?

I understood fan.turn_on/off or fan.set_speed is default when I don’t want to assing specific device. Clearly I’m wrong about it.

I never used the fan template but I believe a simple way to achieve this is to create an input_number that goes from 0 to 100. Input number can be displayed as a slider in Lovelace. Then use that as a trigger in Node Red.

Does your fan support that range of speeds? or does it have, let’s say, 3 or 4 speed settings?

If it does have a limited number of speeds, just create an input_select with, for example, options: off, 1, 2, 3, 4, 5. And again, use that in NR as a trigger.

Inputs are great to add to lovelace later.

Yes, my fan supports percentage values from 0 to 100.

Do You talking about this input_number: https://www.home-assistant.io/integrations/input_number/ ?

exactly

input_number:
  fan_speed:
    min: 0
    max: 100
    step: 1
    mode: slider
    unit_of_measurement: '%'

you can use that as a trigger to your fan. I would limit the trigger of your fan to the input number and nothing else.

I mean, if you want to use voice control too, set your voice flows in a way that when you say “Alexa, set the fan to 20%”, the flow will change the input to 20%, not the actual fan. This way you’ll always have your lovelace updated.

Ohhhh… Damn… Don’t know what to say… So much hours spend on debugging and feeling like total lost… :smiley:

Thanks a lot You man! I want to hug You right now! Need a lot to learn yet about HA :slight_smile:

1 Like