Send data from NR to HA

Hi, I’m a noob, just starting with NR. I’m not a programmer at all, but ready to learn.

I read the community portal to look for what I’m wondering about.

I’m playing around with data which is retrieved by NR by using the http request and json nodes.

I wonder how I can send this information to Home Assistant? (Maybe sending data is not the correct word). For example: I like to retrieve the Formula 1 drivers standings, and like to send the top 3 drivers to Home Assistant after each race. The current standing will be a schedule which check if a race has been done.

Retrieving the F1 drivers standings via the API-call is already been achieved.

Below is the response of the API call.

And the node-red flow so far to retrieve the information via de API call.

The json parsing has been done. Now I wonder how to address the individual parts (position, driver number, driver name, points) of the json structure and “translate” it to a sensor which I can present in HA.

There is of course the alternative way: directly use the REST option in configuration.yaml. But I’m too curious if it is possible to push this kind of information from NR to HA.

There are a number of options for you to sent data to HA from NR,.

  • The best is the following custom integration which will allow you to make sensors in NR and update the values to HA. It is easy and you check it out.
  • Another method is to use mqtt, You can create mqtt sensors in HA and send data to it from NR using mqtt publish node.
  • Yet another way is to create input_text entities in HA and update values to it from NR using the set value service.

There may be more methods also

1 Like

Another method is to make a HTTP Call to the HA API.
However, I agree the hass-node-red custom component is really awesome.

Additionally this:

1 Like

Hi,

I finally have the time to check your 1st option, the HACS integration. I’ll let you know how I progress.

Update:

  1. Installed the HACS part (restart HA)
  2. Installed the Node Red companion via Configuration, Integration, Add Integration

Lets see what I find.

1 Like

Yes! After a good search, reading and trying out I succeed to catch data into sensors with the MultiScrape option.

First you have to install Multiscrape Via HACS, and add the integration under Configuration.

Then I figure out the structure of the web-page, in my case Formula one (Standings).

I used Chrome together with an extension to select the right classes out of the html code.

. With the help of the CSS Selector Tester I figured out the right selects.

So my goal was to capture the driverstanding for the first three drivers and store them in a sensor.

The following code I used to achieve the capturing of the first driver.

After restart HA I searched for one of the sensors, and voila, there it is!

Next step is to show the first three drivers. A couple of questions pops up:

  1. is there a Custom card already available to show a competition ranking?
  2. Or modify custom card code to show the drivers standings?

Besides I still like to understand how I could show the results from an API goal, from within HA, but also via Node Red towards HA. Yesterday, I installed the code to build send information from Node Red to HA.