#Create toggle with REST calls?

1 messages · Page 1 of 1 (latest)

unique sorrel
#

I am trying to create a dashboard button that sends a REST command (JSON API) when turned on, and a different one when turned off. Not sure how to do this? Any thoughts?

dark hawk
#

You can create two rest_command actions, and attach those actions to the turn on or turn off of a toggle.

#

What maintains the state of the toggle? Home assistant, or is it queried from something?

unique sorrel
#

I have created the rest_command actions. They are basically calling out to my existing Homeseer system to send JSON commands to turn Z-wave lights on and off.

#

I created a button, but when I try and add a second tap_action I get an error that it is a duplicated command, so I am not sure how to add them both to it.

dark hawk
#

So a button and a toggle are two different things

#

do you want a button or do you want a toggle

unique sorrel
#

Honestly fine with either. If I use the button I want to press it (On) and trigger one rest_command and then (Off) to trigger the other. Or I can use a toggle and do the same thing on the sliding of the toggle

#

Button would probably be preferable though

dark hawk
#

So a button can't remember the state of the toggle, so you need something to store that memory

#

that could be an input_boolean, or you can somehow use the state of the zwave light if you have that

unique sorrel
#

Ahh, OK, that makes sense. Then without either having it store a value (On=1 or Off=0) then I would just create 2 buttons and have them use perform_action and send the different commands.

That make sesne?

dark hawk
#

Yeah I mean just having two buttons is an easy option, if that works for you

unique sorrel
#

It works for now, once I learn more I may revisit it. But eventually I will migrate my Z-Wave over to HA from Homeseer and that will make this irrelevant.