You need to pass the JSON as the body of the POST, not as part of the URL. It’s possible that Imperihome doesn’t off that. You can see an example for IFTTT that does the same. Check out the IFTTT component page.
Thanks ih8gate … really appriciate your help here …OK will IFTTT component solve my issue, that is I call a URL in Imperihome that sends the request to IFTTT and IFTTT in turn triggers an event with respective ID, in my case switch.bedroom_light.
If this is possible can you please turn/push me a little in the right direction as to how to make this happen. I went through the IFTTT page and also created a trigger in IFTTT that has POST parameters like you have shown inthe above image, also added ifttt component with the KEY in yaml file … by now what what next how to make this all work … sorry to be a noob … if you can just assist me here I shall pick it from there
regards
Sammy
I was showing IFTTT as an example of formatting your data. But if Imperihome can’t send a body with a POST, then I guess you could use it as an intermediary. It might have a bit of latency. If Imperihome can do the proper format for a POST, you’re much better using that.
I’m not really clear on what you need at this point. Try tackling things one step at a time - make sure that IFTTT->Home Assistant works first by using an IFTTT DO button to trigger it. Then move on to triggering from Imerpihome via the IFTTT Maker channel.
Hi ih8gate.
I managed to solve it. I created an event in IFTTT and in the “then” part connected it to the web request,
IFTTT was already added to YAML file with the KEY. Then was just a matter of passing the below URL
https://maker.ifttt.com/trigger/EventName/with/key/myIFTTTKEY
and that switched on the Lights and only lights and not the speakers. I provided the same URL in Imperihome and IT WORKED!!!
The only tiny complaint is that its bit slow, I mean its takes 1-2 seconds after the button is pressed, Plus I cannot use local IP from IFTTT, I had to use DDNS and fw the HA IP, which I personally did not want to, but if that’s the only way to solve this so be it … I am happy. …
Cant believe it was so simple, wish someone could have suggested this earlier, I have two threads running for the same issue I was facing for last 5 days and was not able to solve it …anyway late than never. thank you again for pointing me to IFTTT. I might now go into more detail automation and might need some more assistance, hope you will be there …
Regards
Sammy
How would it be a GET for getting a SENSOR value, for example
in the below I would need only DURATION
https://xxx.duckdns.org/api/states/sensor.da_casa_a_scuola?api_password=xxx
{“attributes”: {“destination_addresses”: [" Roma RM, Italy"], “distance”: “22.6 km”, “duration”: “24 mins”, “duration_in_traffic”: “23 mins”, “friendly_name”: “da Casa a Scuola”, “mode”: “driving”, “origin_addresses”: [" RM, Italy"], “status”: “OK”, “unit_of_measurement”: “min”, “units”: “metric”}, “entity_id”: “sensor.da_casa_a_scuola”, “last_changed”: “2017-08-24T13:49:32.790577+00:00”, “last_updated”: “2017-08-24T13:49:32.790577+00:00”, “state”: “23”}
Here’s a push in the right direction:
sorry I don’t undestand much. Can it be added in the URL?
Like this?
I misunderstood what you were asking - I though you were trying to extract a value.
You can’t do GETs to Home Assistant’s API. It has to be a POST.
well yes, I try to get a value from a sensor, with the program HTTP SHORTCUT
If I do this in my browser
https://xxx.duckdns.org/api/states/sensor.da_casa_a_scuola?api_password=xxx
I receive this
{“attributes”: {“destination_addresses”: [" Roma RM, Italy"], “distance”: “22.6 km”, “duration”: “24 mins”, “duration_in_traffic”: “23 mins”, “friendly_name”: “da Casa a Scuola”, “mode”: “driving”, “origin_addresses”: [" RM, Italy"], “status”: “OK”, “unit_of_measurement”: “min”, “units”: “metric”}, “entity_id”: “sensor.da_casa_a_scuola”, “last_changed”: “2017-08-24T13:49:32.790577+00:00”, “last_updated”: “2017-08-24T13:49:32.790577+00:00”, “state”: “23”}
but I want to receive only the duration
how to do that with a POST, is it possible?
Does HTTP Shortcut let you parse JSON? Then refer to the URL I gave above. If not, I’m not sure what your options are.
I think yes
shall I put what
{“attributes”: “duration”}
What happened when you tested that with the template dev tool like I suggested?
I have no idea of what you mean … sorry
In the program I can put an URL use GET or POST and then ADD HEADER and ADD PARAMETER
in ADD PARAMETER shall I put
value_json[0][‘duration’]
?
In your shortcut, do a GET of that URL (https://xxx.duckdns.org/api/states/sensor.da_casa_a_scuola?api_password=xxx). Then parse it using the JSON parsing tools in HTTP Shortcut (assuming they have such tools).
You can use the template dev tool to figure out the expression to parse the JSON.
this I did, and like this I receive the below
{“attributes”: {“destination_addresses”: [" Roma RM, Italy"], “distance”: “22.6 km”, “duration”: “24 mins”, “duration_in_traffic”: “23 mins”, “friendly_name”: “da Casa a Scuola”, “mode”: “driving”, “origin_addresses”: [" RM, Italy"], “status”: “OK”, “unit_of_measurement”: “min”, “units”: “metric”}, “entity_id”: “sensor.da_casa_a_scuola”, “last_changed”: “2017-08-24T13:49:32.790577+00:00”, “last_updated”: “2017-08-24T13:49:32.790577+00:00”, “state”: “23”}
which is fine. But I want to receive only the DURATION value, not the full message
Sure. You need to parse that on the HTTP Shortcut side.
My goal is to have easily a value of duration.
So I click my widget (which is querying the sendor for the duration of commuting time) and I receive the value of the sensor (in the above case the value: 24 minutes)
But which command to parse in order to get the DURATION value?