Sending http push url to HASS

Hi,

the simple answer to this is most likely “no, not possible” as the documentation explicitly states that the Restful API in HASS only supports JSON, so here is my issue:

My GCE IPX800 controller only supports sending http push messages for On/Off states. Is there a way without using JSON to communicate from the IPX to HASS?

I am able to connect to the IPX from HASS without any issue but unfortunately for binary sensor devices like PIR’s the updates are not instantaneous and additionally frequent polling from HASS tends to receive a ‘timeout’ from the controller, meaning the state is not updated within HASS.

This is an example of the entry in the configuration.yaml file:

binary_sensor:
  - platform: rest
    resource: http://<ip_address_of_ipx>/api/xdevices.json?Get=D
    value_template: '{{ value_json.D33 }}'
    name: "Door"

The actual output from the IPX is in XML but using the value_json template I am able to acquire the state, instead of using many shell based ‘cut’ and ‘grep’ commands in a long string.

An ideal solution would be to send something like:

http://<ip_address_of_hass>/api/states?binary_sensor.door=on
http://<ip_address_of_hass>/api/states?binary_sensor.door=off

to HASS upon state change.

Using curl of course this works fine to change the state of the sensor in HASS:

curl -X POST -H "Authorization: Bearer token" -H "Content-Type: application/json" -d '{"state": "on", "attributes": {"friendly_name": "Door"}}' http://localhost:8123/api/states/binary_sensor.door

Unfortunately I can’t input it into the IPX :frowning:

The side effect from using HASS to poll the IPX is that sensors do not get updated and show the wrong states; as you can see in the image, the Front Door is being shown as ‘open’ but it is in fact closed. Additionally the PIR’s do not show motion properly either, so there maybe motion but HASS will show the location as being ‘clear’.

Does anyone have a solution or perhaps a different suggestion?

Thanks.

How good re you at programming in Python?

Sounds like you need to create a custom integration.

Thanks @tom_I, I don’t have much Python experience but your suggestion is valid. Looks like there is a lot more reading/learning to do in terms of creating a custom integration.

On the side I think it will please the GCE guys too as they were looking at doing the same thing :wink:

It will probably be useful for creating a REST based dimmer too as currently there doesn’t seem to be any information outside of a dimmer light template, in order to get a command line based dimmer switch.

Yeah I know what you mean. I haven’t yet had a problem that would require me to delve into integration development. Though I have read the docs. And to be honest they’re not ‘development for dummys’ docs. They assume quite a bit of knowledge.

At least the docs do contain a ‘Hello World’ example.

Though I think what I’m looking at doing would be the reverse of the API push/poll integration described here:

I’m not sure how happy the devs would be if I asked for ‘push’ based integration as a feature request. There is a notification service in HASS but I haven’t played with or read up on it yet.

Why not just use webhooks?

There are a lot of sensors that work on ‘local push’. e.g. look at the right hand side column here: https://www.home-assistant.io/integrations/plex/

Maybe pick a simple local push sensor and try to reverse engineer it in conjunction with the docs.

Is this what you mean?

That could be a possibility too. Thanks for that!

It’s also possible without ifttt, an webhook that triggers an automation

1 Like

Yeah just found it…

The good news is that the IPX does support POST as well as GET.

I guess on the IPX side I just need to add the string:

http://<domain address>:8123/api/webhook/<webhook_id>

After creating the appropriate Webhook in HASS

Or other option, you can do it in nodered.
So IPX → NodeRed → HA

No python to write either :slight_smile:

GV

Thank you!

I have just spend the last few hours getting the webhook functioning :stuck_out_tongue:

All works fine but the IPX unfortunately is behaving strangely. I will need to investigate as it seems to be something to do with the POST function.

I’ll have a look at NodeRed too. :slight_smile:

You don’t have to create a web hook. Just create an automation that will set the value of a helper input binary sensor and you’re done.

Thanks but I am not sure what you mean by “helper input binary sensor”?

Google gave a bunch of input_* links eg:

I meant a helper input boolean entity. Sorry for the confusion.

Ah ok gotcha :wink:

So, do you mean doing something like:

  1. Poll IPX controller
  2. Update binary sensor
  3. based on binary sensor state, set Input Boolean value

?

Or do you mean set the Input Boolean directly from my controller? <- Unfortunately I cannot do this as the controller does not support JSON, so I can only send Push based urls.
The Webhook method would have worked but seems like there is a software glitch with the IPX using POST as well. :sob:

Now I need to find some kind of GET based solution… and not receive the 405 Error

I have a Synology, also using actions, not compatible with post, only get…

So I have setup a small php server , so I call a php file … That php file sends a post to HA

Have you considered Zapier webhooks? They seem to support GET requests. You could then use Zapier to make a POST request to your HA.

https://zapier.com/page/webhooks/

Zapier is good, but there is always a delay…