Node-RED POST node

Hello,

just to let you know that I wrote a custom node for node-red to post state updates directly to Home Assistant.

The source code is available on GitHub: https://github.com/lpandolfini/node-red-contrib-hass
Or you can install it directly via npm (https://www.npmjs.com/package/node-red-contrib-hass)

Any feedback is appreciated

Thanks
Luca

1 Like

Nice! Iā€™ve cobbled together a eventsource node, so you can listen to updates:

(NPM: https://www.npmjs.com/package/node-red-contrib-eventsource)

Just throw in https://[url of homeassistant]:8123/api/stream?api_password=[password] as the URL, and you can read live updated from home assistant.

It ignores certificate validation at the moment, because node canā€™t deal with custom CAs which is what I use.

Hey guys,
Would you mind sharing some insight on how you connected one with the other?
Noobie here, sorry for hijacking

@madpilot @lpandolfini

Some help, please!!!

I have:
-RaspberryPI with 433 and node red installed and fully working (I was able to install node-red-contrib-hass and the mqtt component, last is connecting fine, not sure about the contrib-hass)
-Windows 10 with Home Assistant and MQTT Broker running (with self signed CA! :frowning: )

What Iā€™m trying to do:
Get Node-Red to send info to HA and (me) be able to use it:
-I would like the 433 devices to pass the info to HASS through node-red.
ie: when my motion sensor(s) gets activated, to show on HA or be able to use it, like if motion sensor -> turn light (I know thatā€™s doable with HA and the automation etc, my issue comes from getting the actual data from node-red to HA)

What I donā€™t understand is how node-red pass the info to HA and how I could use it, read it, etcā€¦
I have read a lot of MQTT and node-red and tried looking for an example for node-red-contrib-hassā€¦ even tried and error with connecting, etcā€¦ broker the setup twice (probably got connected, but couldnā€™t figure what was going on)

Any help appreciated it.

EDIT: forgot to mention: I been using the ā€œdebugā€ to read the messages coming in/out from serial and mqtt. Deleted to debug other issues at this point, but I could add it again.

@madpilot
screenshot of my node-red: https://www.dropbox.com/s/jqng99l058r4lxq/Screenshot%202016-12-14%2011.20.51.png?dl=0

Hi. Iā€™m really interested to interface HA and Node-red. @Madpilot, could I have some more info by you about payload decoding you realized to parse the event coming from HA stream?
Thank you very much in advance.

@madpilot @lpandolfini

I seem to be having trouble parsing the data being returned by eventsource. It looks like JSON data, but all my attempts to parse it fail. Could you please provide some guidance on the next steps for using eventsource? Maybe a function that leaves me with a javascript object I can use?

Sorry for taking so long to reply to everyone. @-mentioning @MadPilot doesnā€™t work - my username is all lower case.

@mkzimms Itā€™s already parsed, you should just be able to treat it like a regular JS object.

@alpat59 The easiest way to work out the format is to attach a debug object to the output of the eventsource node, and look what gets produced. An example I just pulled looks like this:

{
  "payload": {
    "data": {
      "old_state": null,
      "new_state": {
        "last_changed": "2016-12-10T11:11:10.794063+00:00",
        "attributes": {
          "order": 2,
          "friendly_name": "all lights",
          "auto": true,
          "entity_id": [
            "light.bedroom_light",
            "light.lounge_room_lamp",
            "light.bedroom_lamp"
          ],
          "hidden": true
        },
        "last_updated": "2016-12-10T11:11:10.794063+00:00",
        "entity_id": "group.all_lights",
        "state": "on"
      },
      "entity_id": "group.all_lights"
    },
    "origin": "LOCAL",
    "time_fired": "2016-12-10T11:11:10.794097+00:00",
    "event_type": "state_changed"
  },
  "_msgid": "eb5317a6.14ace8"
}

@aelg305 That image doesnā€™t work - you might need to reupload it.

Need some helpā€¦ Tried to setup the node-red but get these errors:

with this config:

when i put in the address i get:

How exaclty do i have to configure this?

Maybe ask @lpandolfini?

The plugin I wrote is an input, not an output - I donā€™t use the node-red plugin.

My guess is though, you would need a glue function in between owntracks and Node Hass, as I doubt the output from owntracks is in the format that HASS is expecting (Which is why it is returning a 500 error)

See: https://github.com/lpandolfini/node-red-contrib-hass#usage

Sorry guys,
Iā€™m working very hard and I donā€™t have my developement platform available now. Just give me some time to build it again and Iā€™ll try to have a look at it.
Thanks