Switch Controlling multiple lights

Need help with a rule… still fairly new at this so im not sure how to set this rule up… I have a kitchen light that when i turn on i want it to turn on the bar lights to say 5%… but only if the bar lights were off. If they were on already then id like to leave them on and not change the brightness level. Also if i turn off the kitchen light id like for the bar light to only turn off if they were turned on when the kitchen light turns them on… is this possible or is it too complex?

This is how far ive gotten so far and it works as far as turning the bar lights on when the kitchen light it turned on… but as for all the other stuff… i have no idea on how to go about getting all that to work.

rule "When kitchen switch is on"
when
Item zwave_device_9e525cd7_node4_switch_binary changed from OFF to ON
then
zwave_device_9e525cd7_node5_switch_dimmer.sendCommand(5)
end

Go at it a bit at a time. Now you have ‘bar’ lights turning on with switch, you need to add the conditional ‘if’ before the turning-on, looking to see if the ‘bar’ light are indeed already off.
Two tasks there; find out how to do if, lots of examples around.
Find out how to read a dimmer Item, to test if it is on (hint, .state)

When it comes to remembering whether the ‘bar’ lights had a manual or automatic ON previously, you could use a ‘virtual’ Item, another switch that isn’t associated with any real device, as a flag. Set it when doing auto-on, clear it when doing manual-on, test it in your ‘off’ rule triggered from the manual switch.

You might like to think what result you would like if the ‘bar’ lights are auto-on but then someone makes a manual adjustment later.

1 Like