01-25-2017, 10:24 AM
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/
--> 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.
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.