Hi All.
I was chalinged by the wife yet again. she wants a all off button.
example if we go to bed an forgot some lights on down stairs. she wants to be able to turn them all of at once with a single switch on her tablet.
so what i did so far is the following.
1)
site map :
Yes, or divide them in room groups, then all the room groups into a general gLights group. This allows you to also just selectively turn off all lights certain rooms.
You will still need a rule to trigger when the Sleep_mode switch (?) is being activated, but then you could just have one
g_lights.sendCommand(OFF)
even now you don’t really need to check if the lights are on, you can just send them all an OFF command anyway as the wife wants to make sure all lights are off.
Magical property of a Group type Item ; if you send it a command (from UI or rule) it automatically distributes that command to all member Items.
That includes members that are also Group types, so you can have a hierarchy of Groups.
You do not have to use default widgets in your sitemap, and you show a Group type Item with e.g.
Switch item=myGroup
to allow direct commands of a Group.
You would usually use that in conjunction with giving your Group Item a sub-type and an aggregate function like OR(ON,OFF), so that the sitemap widget can also show you if any member is on.
Caution; this technique can produce a flurry of dozens of commands competing to get to the devices. Success depends on how well any given technology manages this.
You don’t need a rule, unless you plan to change other things as a result of activating sleep mode. If you only care about lights, I would just add the group itself to a sitemap:
Or as @rossko57 stated, you can just display the group in your sitemap to turn off all the lights in one go.
I prefer a night switch setup, which you also originally envisioned, which send an OFF command to the light group, but can also incorporate other night time routines in it as well, as turning the heating down etc.
So many possible solutions
Also good to have a quick look here for the group functionality
I also find it very important to have a night switch in order to be able to mute or silence certain notifications during the night by querying its state
Well, in that case then, and to answer your initial question - here’s a rule that should work.
rule "Sleep Mode All OFF"
when
Item Sleep_mode changed to "ON"
then
logInfo("Rule","Sleep Mode - ALL OFF")
Kitchen_Light_Stoep.sendCommand(OFF)
Kitchen_Light.sendCommand(OFF)
GuestRoom_Light.sendCommand(OFF)
MasterBedroom_Light_Ingan.sendCommand(OFF)
Master_Power.sendCommand(OFF)
Study_Power.sendCommand(OFF)
end
as @Hans_Lree says, you don’t particularly need to check if they are already on or off - just command them all off.
Groups with rule
If you wanted to use groups, you could add the following to your items file. This means that the group gLights is defined as a switch, and will be ON if any of its members are ON. It will be OFF if all its members are OFF:
Group:Switch:OR(ON,OFF) gLights
You then add each of your items to this group as follows (for example):
I suppose so, but I am not really using the Expire binding, and am also not sure how its future will be, as it’s still a v1 binding. Also Expire would always turn the switch back off after the given duration, no matter when you go to bed.
I turn off certain night switches with the sunrise time of the astro binding, or through motion sensors which get triggered after sunrise. Might be an option for you as well, or through a cron triggered rule depending on when you get up in the mornings.
Or just by pressing the button again when you get up.
If you do not want to check for the Sleep_mode state at all during the night you can make it just a push button with a single mapping and autoupdate false. Then it just turns your lights and squeezeboxes off, but doesn’t really have to be turned off again at all.
Item Switch Sleep_mode "All Lights & Things" {autoupdate="false"}
In sitemap Switch item=Sleep_mode mappings=["ON"="OFF"]