Send POST to Home Assistant

In the past, when updating HA sensor values, etc I have been sending HE device info to a php page on a Raspberry PI.
URL example: xxx.xxx.x.180/Dev/setHASensor.php?entity=sensor.sensor_name&fname=what_ever&unit=c&icon=icon-type&state=25

This PHP page convert this info into the properly formatted CURL statement such as:

curl -vs -o /dev/null -X POST -H "Authorization: Bearer super-long-token" -H "Content-Type: application/json" -d '{"state": "25" ,"attributes": {"unit_of_measurement": "km", "icon": "mdi:thermometer","friendly_name": "Backyard Temperature"}}' http://192.168.1.190:8123/api/states/sensor.ecowitt_ch2_backyard_temp

Has worked this way for years but I want to get rid of the PI and send this HE info directly to HA preferably though a RM Send POST I can not for the likes of me get this to work. How would I include this long HA token in such POST?

I have tried to create this rule without the token and by adding username and password (i.e http://username:password@192......) but HA keeps throwing an authentication error.

I am out of ideas and looking for help. Much appreciated in advance.

Let's see a screenshot of your rule machine rule; the "action" part where you are defining the http post request (blur out any personal info). Also, are you receiving any errors on the hubitat side (for the rule) when sending the request?

Well that's just it. I dont even know where to begin with RM send POST. The only options I have is URL and Body. I know for the Token to be passed the POST request needs a HEADER option.

In the URL field I have: http://192.168.1.190:8123/api/states/sensor.ecowitt_ch2_backyard_temp
In the BODY field I have:
"state": "45" ,"attributes": {"unit_of_measurement": "c", "icon": "mdi:thermometer","friendly_name": "xxxxxxxxxxxxx"

Thats all there is

I’m fairly certain the behavior is expected as there is not place in RM to edit the http header, so the auth token is not sent.

You could write a smartapp to do this or use the HA maker api integration to get the device over to HA

The integration HA -> HE actually works pretty good but, for most part, its a one way street. In the case of temperature sensors I can not update HA with HE data.

the HA maker api integration is HE -> HA and does update HA from HE devices

3 Likes

Hmmmm this looks different then what I have installed. (Home Assistant Device Bridge)I will have to check this out

I use both the HA maker api integration for HE -> HA and Home Assistant Device Bridge for HA -> HE. they both work well, till matter makes this unnecessary. :wink:

4 Likes

HADB is a Hubitat community developed integration to bring Home Assistant (HA) devices/entities into Hubitat Elevation (HE).

@jason0x43's integration, linked above by @sidjohn1, brings HE devices into HA.

I use both and they work great for their intended purposes.

4 Likes

FWIW, I use the Maker API app to feed all sorts of HE info to HA. It works flawlessly. Well worth looking into.

1 Like