Web API: Create switch on Home Assistant

Hi,

I have Home Assistant together with Node Red running. Normally I am using HA for GUI and for interconnecting to different Devices (Platforms) and Node Red for Automation.

I have a special system which has an API which I am quering via Node Red as this was the easiest way for me. It is a switch, so I can query the status and also change the value from 0 to 1 or back.

On Node Red I created an HTTP GET “http://192.168.1.220/api/1.0/datapoint/1/15/0/98/0” which delivers me a JSON Message. With JSON and “set msg.payload” I am extracting the needed value and sending it to MQTT.

On HA I am taking this MQTT and showing the Status of this Entity

The second part is to change the status of this switch (0/1). Therefore I created a HTTP PUT “http://192.168.1.220/api/1.0/datapoint” which I am feeding with an Inject “JSON” value “{“OID”:”/1/15/0/2/16/0",“value”:“1”}"

My question is now: I want to have a switch on HA to see the status of this switch and also have the option to change it. What would be the best approach?

Best Regards,
Johannes

A input_boolean switch will work

Ok, I got it working.

image

But one additional question: Is there a possibility to secure such a switch in that manner, that I need to do a second click or “accept” button?

Reason: This switch starts the Warmwater-Heating of my Heating system. I do not want that it starts if me or my family member by mistakes activate it. You now, this could happen easily on a mobile phone…

Br,
Johannes

Yes there is: