so that the power on SetTarget
is also 0 rather than 1
Setting the value to “0” in your private static JSON file will turn the lights off, not keep them on. I think you mean to use “1” there.
There is a built-in mechanism for disabling controls in the UI through static JSON. I do not know how this would look or operate (or even if it operates) with the multi-state (on/off) button control used for BinaryLight. But, here’s how it may be done, nonetheless:
The Conditions
section of the static JSON file, which usually follows the Control
array, is an array of conditions and commands that can enable and disable other controls. It is an array of objects with keys Trigger
, Target
and Action
. Start with the easy ones:
The Action
key may be either enable
or disable
. The Target
is the value of the ControlCode
for the control you want to enable/disable. For D_BinaryLight1.json that would be power_off
.
The Trigger
section has the most complex formatting, but should be straightforward in principle. It sets up the actual condition(s) under which the Action should take place on the Target control. Here’s what I believe it should look like for your goal:
"Control": [
{
... existing Control section data -- don't change this part
}
],
"Conditions": [{
"Trigger": {
"Operands": [{
"Service": "urn:upnp-org:serviceId:SwitchPower1",
"Variable": "Status",
"Value": {
"Equals": "1"
}
}]
},
"Action": "disable",
"Target": "power_off"
}]
... rest of the file
The hardest part of making this change will be placing it correctly in the file. In the 7.32 latest Beta (5350) version on my Plus. In that version of the file, the Control
section begins at line 281 and ends at line 336. This seems to be unchanged from many, many versions prior, so you should see the same if you’re on 7.31. Line 336 is a right square bracket ]
on a line by itself. Append a comma to this line, and then copy-paste the Conditions
section given above only, placing it after that ],
line. You can check your work by pasting the entire file into jsonlint.com.
Then do all the ritual things: save the file with a distinct name, upload it to the Vera, modify a device to use it, reload Luup, hard refresh your browser. You may also need to turn the device off and on once to get it to “stick” for the first time.
Juice may not be worth the squeeze, because it simply may not work with the multi-state button control, and your simple approach of changing the value only may be just fine. But the exercise may be interesting, and at least now it’s a bit documented and can be applied to other things, so offered as an alternative.
Edit: If multi-state button disable doesn’t work this way, it may just be that the multi-state button as a whole needs to be assigned a ControlCode
. It doesn’t have one; the control codes are on the substates, but not the parent. Then that new control code would be used in as the Target for Conditions. But today is not my day for this, have much else on my plate.