I have rules set up to dim my lights throughout the day.
is there a way too add a button too habpannel that when you press it brings lights up to full brightness and then when you click it again it returns the lights back too the brightness it was set to before the button press
The only way I could get to work was a switch set too alternate commands press 1 set too 100 press 2 set to 0 but that’s just on off not return to previous setting
You can do it in rules, but I don’t know how/if to do it in the Experimental Rules Engine.
You will need a Rule to save the state of the Dimmers before you bring them up to 100 and then a rule that restores the saved state when pressing the button again.
Like I said, not in the Experimental Rules Engine.
In the Rules DSL it would look something like:
Assuming the lights are in the same Group
var Map<Item, State> previousStates = null
rule "Save or restore dimmer states"
when
Item MyDimmerSwitch received command
then
if(receivedCommand == ON){
previousStates = storeStates(AllDimmers) // you can list each Item individually if you don't have a Group
AllDimmers.sendCommand(100) // send the lights to 100
}
else {
if(previousStates != null) {
restoreStates(previousStates)
previousStates = null
}
else {
AllDimmers.sendCommand(0) // if we don't have previous states to restore to just turn them OFF
}
}
end
do i need to create any special items ? something to store the previous values ?
i just cant quite understand how it works
do i need to change anything in the variable section of the rule
Do you mean like this ?
var Map<Item, State> previousStates = null
rule "Save or restore dimmer states"
when
Item Temp Bright received command
then
if(receivedCommand == ON){
previousStates = storeStates(GLRLightsDimmer) // you can list each Item individually if you don't have a Group
GLRLightsDimmer.sendCommand(100) // send the lights to 100
}
else {
if(previousStates != null) {
restoreStates(previousStates)
previousStates = null
}
else {
GLRLightsDimmer.sendCommand(0) // if we don't have previous states to restore to just turn them OFF
}
}
end
If i then created a switch called Temp Bright this rule would work ?