REST sensor/switch that needs 2 URLs

Hi,

I’m trying to integrate a SYR SafeTech Connect water leak protection device into HA. It has some sort of HTTP interface in my local network, i.e. I need to call individual URLs to trigger an action or request data. Data is being returned as JSON, values to be transmitted are simply appended to the URL:

Unfortunately some commands require special “access rights”, thus I need to call http://syr.mydomain.com:5333/safe-tec/set/ADM/(1)f before I can e.g. clear an alarm or set parameters like maximum flow rate or similar. However, I am still new to HA and not sure how to do this best:

  1. Always call the access rights URL before I call another one? If yes, how can I do that? Seems there can only be one resource in a REST sensor

  2. Call the access rights URL immediately after startup and once every x hours. Would that be an automation (e.g. HA startup as trigger, but what service?) or a script?

Maybe there is also a more elegant way I didn’t think about yet :wink:

Thanks for your help!!
Klayman

1 Like

And does this call return an authentication token that you then need to present in the next call? Or, is a call to this URL just enabling some form of admin mode and you can then execute those other commands for a period of time?

You would need to configure a separate rest_command that calls that admin URL, and then use a script to execute that before updating the sensor using service homeassistant.update_entity combined with a very long scan_interval for that sensor.

That could be done with an automation. The rest_command that you define will become available as a service that you can use in an automation’s actions section.