Node-Red Newbie: help writing a value into HA

Hello,

i did not find a concrete answer searching… but sure someone can point me as a newbie of Node-Red into the right direction:

I am running hass.io (latest version) and the node-red add-on.
My intention is to read values from my weather station from a Wunderground website and parsing dedicated values back into HA (Link is http://api.wunderground.com/weatherstation/WXCurrentObXML.asp?ID=MYID)

Techncially, i have done my first Node-Red flow using an inject -> http-request -> html nodes.
This way i see e.g. my current Temp (example: “15.4”).
What i am struggling around is how to get this value back into HA to see it on the Lovelace UI ?

Thanks for your help in advance!
/ Ralf

If you just want to get the temperature value over time you don’t need node red for this
I’d suggest to use a command line sensor instead (and you can use this value in bode red later if needed!)

Thats what i had before when running hassbian.
But hassio misses a command line utility (xmllib).
So i tried with Node-Red now.

You use make a rest sensor in Home Assistant set to gets its value from node red.

[{"id":"3c080ae1.d10b86","type":"http in","z":"5eb3594f.d294b8","name":"","url":"/currenttemp","method":"get","upload":false,"swaggerDoc":"","x":238,"y":992,"wires":[["40b6de61.a2f"]]},{"id":"3850921d.7a778e","type":"http response","z":"5eb3594f.d294b8","name":"","statusCode":"200","headers":{},"x":764,"y":992,"wires":[]},{"id":"40b6de61.a2f","type":"template","z":"5eb3594f.d294b8","name":"Do the stuff to get temp. Set payload to temp","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"22","output":"str","x":506,"y":992,"wires":[["3850921d.7a778e"]]}]
sensor:
  - platform: rest
    resource: http://IP:1880/currenttemp

edit:
Your actually flow may look something like this

why not just use the component for wu?

  • platform: wunderground
    api_key: xxxxxx
    pwd_id: xxxx
    monitored_conditions:
    • alerts
    • feelslike_f
    • temp_f

@ghvader: i have no api key from WU. And as known they do not give you anyone anymore.
Thats why i try with Node-Red.

@kermit: first, thanks for your help.
One question: what do i have to enter in the http post at the end?

Thanks, Ralf

Hello,

just tried with a template node, code:
{ "data": { "entity_id":"sensor.mywetter_temp","value" : {{payload}} } }
Unfortunately, did not work.
Surely i do s.th. silly but simple wrong… :frowning:

/ Ralf

I do this with a few different things in Node-Red, and I prefer to push them to an MQTT topic, and in HA, use an MQTT Sensor to read the value.

@flamingm0e
Can you tell me in more detail how you do this? I mean:

  1. pusing into mqtt (which one? Mosquitto?) and
  2. how you defined the sensor in HA

Thanks, Ralf

In Node-Red, you simply pass your payload to an MQTT topic.

Just create a MQTT sensor. state topic is the same as the MQTT topic you publish to

EDIT:
Here is one of my sensors:

- platform: mqtt
  state_topic: "homeassistant/misc/notiftimer"
  name: "Notification Timer"
  unit_of_measurement: "minutes"
  icon: mdi:timer

I have a Node-Red node sending a minute count every time it changes.

@Ralf I had no idea they were doing that. i just looked into it.
I have not used my api key in a while as my weather station died a few months back. i just got a new one at xmas, but have not added the api/weather stuff back to my home assistant yet.

it stinks that IBM is doing that to people.