Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
MQTT connection to HomeAssistant not working
#8
Using an HTTP sensor in HomeAssistant is very easy. No configuration necessary in HA at all. The sensor just has to send POST requests to HomeAssistant. They will automatically show up as a sensor, if the correct URL and JSON payload are used.

Here is an example for a temperature sensor, taken from https://home-assistant.io/components/sensor.http/

Code:
$ curl -X POST -H "x-ha-access: YOUR_PASSWORD" \
       -H "Content-Type: application/json" \
       -d '{"state": "20", "attributes": {"unit_of_measurement": "°C", "friendly_name": "Bathroom Temp"}}' \
       http://localhost:8123/api/states/sensor.bathroom_temperature


--> Method must be POST, specific HTTP headers must be included and the payload must be a JSON string that contains the measured value and some static metadata.
Reply


Messages In This Thread
RE: MQTT connection to HomeAssistant not working - by code_talker - 01-25-2017, 10:24 AM

Forum Jump:


Users browsing this thread: 1 Guest(s)