The idea is to have something that can flip/toggle the status of the user led (the ONLY programmable led on hap lite) at each run.
For the moment I am using it as the script connected to Mode button, so at each press of the mode button the user led is triggered at the opposite state it is:
Code: Select all
/system routerboard mode-button
set enabled=yes hold-time=0s..2s on-event=LEDtoggle
Code: Select all
/system leds
:if ([:len [find where (leds="user-led" and type=on)]] > 0) do={
set [find where leds="user-led"] type=off
} else={
set [find where leds="user-led"] type=on}
Code: Select all
/system script
add dont-require-permissions=no name=LEDtoggle owner=admin policy=read,write \
source="/system leds\r\
\n:if ([:len [find where (leds=\"user-led\" and type=on)]] > 0) do={\r\
\nset [find where leds=\"user-led\"] type=off\r\
\n} else={\r\
\nset [find where leds=\"user-led\"] type=on}\r\
\n"

Questions:
1. is it "correct"? (as is it works, but to be picky the else condition should probably be "narrowed" to another conditional check, and I am also not too sure about the various brackets)
2. can it be simplified? (the detection method with len of the find with two conditions seems to me a bit over-complicated)
3. is there a way in Ros command to "flip" a value 0/1 (or yes/no or in this case on/off)?
4. besides the above doubts, better ways/ideas?