Use HA REST API to get device state in command_line sensor

Hi all,

I have a HA install both my house and a off-site location. I am trying to integrate a switch on the off-site location into my main instance.

I first thought of using Automation Webhooks to handle the switching, but then the state would be incorrect of the device was switched by a Automation on the off-site location. I also can’t use the ‘Remote Homeassistant’ HACS add-on because only the main instance can reach the off-site location, not the other way arround.

Therefore, I am trying to set up a command_line sensor to both switch and retrieve the state from the remote instance. I already succeeded in switching the device, but I can’t get the command_state and value_template to work.

This is the output when calling the API with curl:


Can someone help me getting the ‘on’ and ‘off’ state workign with the command_state and value_template so I can view the actual status?