Node-red-contrib-home-assistant-websocket

That was it. I didn’t realize I haven’t updated that container for a long time. Upgraded to 0.19.6, and it is working again.

Thanks again!

Any idea what the following error would be from? Everything seems to be working okay and I can connect to the server just fine. Note, that this is on a rpi zero w that’s not running HA.

Node-Red Version: 0.19.6
Run in Docker: No

Screenshot%20from%202019-03-02%2021-25-55

For some reason, lodash didn’t get installed by npm when the module got installed. You could uninstall and try reinstalling or run npm install lodash from within the node-red directory.

Super easy fix! I did npm install and the error is no longer there.

I’ve been tracking this thread for a few months now and it amazes me at how you continue to both develop the module and support people who have questions with it. Keep up the great work!

Hi
is there a way to log the actions from Node Red in the HA log?

Hi Everyone,

Just upgraded to this as I decided to take another stab at node-red. Got it all going but for the life of me, I cannot figure out how to get call-api-service for device_tracker.see working (probably due to my newbness) and hope someone can steer me in the right direction:

My data:

{
    "dev_id": "chris_nodered",
    "location_name": "{{msg.location.isat[0]}}",
    "gps": "[{{msg.location.lat, msg.location.lon}}]"
}

The debug data you see in the screenshot is part of my flow I pass to call-api-service:

If I statically set location_name to say “home” and drop gps, it’ll update the device_tracker entity but that doesn’t work for what I’m trying to do (which is dynamically populate the tracker with data from my flow)

Can someone shed some light on this and lend a helping hand? This is the last step in my geofence flow, everything but this is working (and was rather easy, which surprised me) but I’m stumped on this.

Thanks!

More than likely it’s because mustache templates use dot notation for everything even arrays.

Try

...
"location_name": "{{msg.location.isat.0}}",
...
1 Like

Thanks @Kermit
While it doesn’t fail with this, it doesn’t update it either :frowning:
If I include the GPS data, it still fails. Not sure why as using the dev-ui I can enter the data manually and it works.

It because device tracker is expecting the gps to be of type float and they’re getting passed in as a string. Drop a function node before the call-service node and try

msg.payload = {
    data: {
        "dev_id": "chris_nodered",
        "location_name": msg.location.isat[0],
        "gps":[
            msg.location.lat, 
            msg.location.lon
        ]
    }
};

return msg;
1 Like

This is kind of what I ended up doing earlier today before reading this :slight_smile:

{
    "data": {
        "dev_id": "chris_nodered",
        "location_name": "{{location.isat.0}}",
        "attributes": {
            "source_type": "gps",
            "gps_accuracy": "{{gps_accuracy}}",
            "latitude": "{{location.lat}}",
            "longitude": "{{location.lon}}",
            "battery": "{{battery}}"
        }
    }
}

It’s not elegant I suppose but it does work which makes me happy :slight_smile: I very much appreciate you giving me a hand with this, here’s the flow as it stands (portion thereof):

I did have to remove the entity from core.restore_state with all the testing it took me to get to this point, once I did that, it worked like a charm.

I gave up on node-red a while back but glad I saw this thread and tried again – I may be able to repro my old python script using it which would be make me even happier :slight_smile:

New Release v0.9.1

Bug Fixes

  • Fix for checking valid entity id (4ee501e)
  • haltif: Fix to include contexts on other operators (1a250b9)
  • poll-state: Set default value for updateIntervalUnits (61f9768)

Features

  • api: New node for direct access to api (ed7341a)

  • call-service: domain and service fields accept templates (8f86906)

  • get-history: Add flatten option (b46a4d5)

  • poll-state: Added Interval Units (44f75c0)

  • Access to msg, flow and global context (e1ce911)

Full Changelog


Buy me a coffee For those that enjoy my work.

2 Likes

I’ve been trying to get the ‘Fire Event’ node to update a binary_sensor all morning without luck, does anyone have an example? I’ve tried vai direct input into the node and via payload without success :frowning:

Hi guys, I’m getting the error - [api-current-state:Occupancy] entity could not be found in cache for entity_id: sensor.mark_presence_confidence, sending empty payload

Looking above that seemed to be a version thing so I went away and updated everything:

  • Node.js Version: 10.12.0
  • Node Red Version: 0.19.6
  • NR Home Assistant Plugin Version: 0.9.1
  • Is Node Red running in Docker: No (HA 0.89.1)
  • Browser: Safari and Chrome

I’m using the long lived token access method. Should I revert to the mentioned version of NodeRed?

I’m also seeing the:

12 Mar 18:23:25 - [debug] [server:HomeAssistant] WebSocket Connecting http://10.10.10.4:8123
12 Mar 18:23:25 - [debug] [server:HomeAssistant] config server event listener connecting
12 Mar 18:23:25 - [debug] [server:HomeAssistant] config server event listener closed

Log entries as well.

Mark

—- Edit

Definitely a connection issue. Getting Call service attempted without connection to server on the call service nodes in console debug.

—- Edit 2

It was a firewall issue… Had to switch to localhost and comms came straight up. Interestingly at some piping i started getting connection errors in the node-red log that weren’t there before.

I’m loving the recent updates to this palette.

Quite a lot of my node-red flows have a Current State node that’s followed by a Switch node to change the flow depending on the state of the entity.

Wondering whether it would be possible to build some switch functionality into the Current State node? So you get a different output depending on the state of the node (other other attribute.

1 Like

fyi, whenever i update my NR docker image to the latest, i have to go into the docker command line and:

docker exec -it -u root nodered bash

npm uninstall node-red-contrib-home-assistant-websocket

npm install node-red-contrib-home-assistant-websocket

exit

and then restart my docker container.

I never have to do that.

Are you asking for more than the two outputs that has now if you using the halt-if logic?

I don’t normally use this package in a docker setup but like @flamingm0e said when I have tested it before I have never had this problem.

Why do you have to do this? You never really said.

@Kermit just started using the deCONZ for my zigbee devices. The xiaomi round buttons see action through the event node, not like sensors or mqtt (zigbee2mqtt).
Everything good but i needed to use the long_release time and i noticed the time is not on the msg. If i subscribe to ha event listener i get the time_fired property. This obviously can be resolved at nodered, but i though it was worth to mention