12-hak
(12 Hak)
July 18, 2016, 2:12pm
1
Im a little stuck with the HTTP sensor. I am trying to create a presence for a JSON post from IFTTT.
No matter what I do I cant seem to create the or update the identity using the curl commands as per the examples
Anyone got any idea or examples how they did it. Does the post create the sensor? It doesnt seem to no update and existing.
Thanks
fabaff
(Fabian Affolter)
July 19, 2016, 5:59am
2
Can you post the response you get if you run the curl
command? Thanks.
The example works on 0.25.0.dev.
If the sensor doesn’t exist, it will be create. Otherwise the state is updated
12-hak
(12 Hak)
July 19, 2016, 6:14am
3
If I run the GET command on an existing sensor I get the expected result
If I run the POST curl returns with no error (just returns to next line on the command line) but existing sensor is not update nor a new one created.
I am running the site over https this is my only variation from the example
I am am on 0.24
fabaff
(Fabian Affolter)
July 19, 2016, 8:10am
4
How does your curl
command looks like?
12-hak
(12 Hak)
July 19, 2016, 8:53am
5
So have tried it with ssl on and off. It works with SSL off. Does the POST need to be modified to work with SSL?
curl -X POST -H "x-ha-access: XXXXXX" \
-H "Content-Type: application/json" \
-d '{"state": "test"}' \
https://192.168.1.30:8123/api/states/sensor.iantest
returns
{"attributes": {}, "entity_id": "sensor.iantest", "last_changed": "2016-07-19T08:47:08.028826+00:00", "last_updated": "2016-07-19T08:47:08.028826+00:00", "state": "test"}
but doesnt update sensor
curl -X POST -H "x-ha-access: XXXXXX" \
-H "Content-Type: application/json" \
-d '{"state": "test"}' \
http://192.168.1.30:8123/api/states/sensor.iantest
returns same but does do update so something is not working on the https
12-hak
(12 Hak)
July 19, 2016, 10:14am
6
I retried this one and it seems to be working,. strange
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"}}' \
**https**://localhost:8123/api/states/sensor.bathroom_temperature
Attached it working in IFTTT , I will be making a trigger from Life360 presence detection to update a family presense sensor
If the first one in the family comes home front door is unlocked. It is relocked when last person leaves
hopsided
(Jared Lucey)
January 14, 2017, 2:04pm
7
Does your sensor state switch back to the previous value after ~10 seconds? I have been trying to set the state of a custom sensor I created and I can successfully change it with a POST, but then it reverts back to the previous value.