Hello,
i will edit a CommandLineSwitch to my HASS config.
My device looks like the following:
#Commandlineswitch
switch LEDBuero:
platform: command_line
switches:
bueroled:
friendly_name: LEDBuero
command_on: "/usr/bin/curl --silent -X GET http://user:[email protected]/api/device/SteckdoseB2/turnOn | cut -c 3 | tr [r] 0"
command_off: "/usr/bin/curl --silent -X GET http://user:[email protected]/api/device/SteckdoseB2/turnOff | cut -c 3 | tr [r] 1"
value_template: '{{ return_value == "1" }}'
command_state: "/usr/bin/curl --silent -X GET http://user:[email protected]/api/device/SteckdoseB2/getState | cut -d: -f2 |cut -d, -f1|tr [true] 0|cut -c 1"
The reason why it looks like this is:
i understood the Command Line Switch like this:
- the on statement needs to get “0” as result from the curl command
- the off statement needs to get “1” as result from the curl command
- the get statement needs to get “0” for on
- and if it’s not 0 the state is off so i also can be another sign… here it’s a “f” as result if the switch is not on…
But wat ever i’m doing the switch is alway flipping back to it’s “ground” position.
so he’s toggling.
He don’t stay’s in the position i switch him to…
(Hope i signed my problem good enough)
can somebody help me
thanks chris
edit:
the usually result of the curl On/Off - command without the pipes is this:
{“result”:true,“success”:true} --> off
{“result”:true,“success”:true} --> on
the get command gives this here:
{“result”:false,“success”:true} --> off
{“result”:true,“success”:true} --> on