How can I check if group state is 'mixed'?
The domoticz.groups('myGroup').state returns 'Off' even there is one light turned on and UI shows 'mixed'.
Is it possible to get list/table of devices from group?
I'd like to create a rule if any of the lights in one group is on then I wouldnt want to turn on another light with motion sensor.
How to check if group state is mixed?
Moderator: leecollings
-
- Posts: 140
- Joined: Wednesday 17 December 2014 17:30
- Target OS: Linux
- Domoticz version: V3.8650
- Location: Jyväskylä, Finland
- Contact:
How to check if group state is mixed?
LXC(x64 Ubuntu Xenial), RFXtrx433E, MySensors
-
- Posts: 140
- Joined: Wednesday 17 December 2014 17:30
- Target OS: Linux
- Domoticz version: V3.8650
- Location: Jyväskylä, Finland
- Contact:
Re: How to check if group state is mixed?
This is what I ended up by now.
Code: Select all
local kitchenLightsGroup = {'Eteinen-spotit',
'Kettio-spotit-vasen',
'Keitto-spotit-oikea',
'Ruokapoyta',
'Saareke katto',
'Allastaso',
'Ylakaapit',
'Ylavalo'}
return {
on = {
devices = {
['Motion-kids'] = {'between 02:00 and 07:00'}
},
timer = {
'every minute between 02:00 and 06:00'
}
},
execute = function(domoticz, device)
--domoticz.log('Keittio: ' .. domoticz.groups('Keittio-valot').state, domoticz.LOG_INFO)
if(s ~= nil) then
-- triggered by motion sensor
-- check what light are already on at kitchen
local enabledkitchenLights = {}
for i, name in ipairs(kitchenLightsGroup) do
if(domoticz.devices(name).state ~= 'Off') then
enabledkitchenLights[#enabledkitchenLights+1] = name
end
end
-- This would be nice if we could take light from group and take all of them what are not off
-- local enabledkitchenLights = kitchenLightsGroup.filter(function (lightName)
-- return (domoticz.devices(lightName).state ~= 'Off')
-- end)
-- Just debugging
for i, lightName in ipairs(enabledkitchenLights) do
domoticz.log('Light on: ' .. lightName , domoticz.LOG_INFO)
end
-- Turn kids room light on with very much dimmed so they can see and walk to parents room at night
if(domoticz.devices('MH1-katto').state == 'Off' and #enabledkitchenLights == 0) then
domoticz.devices('MH1-katto').dimTo(35)
domoticz.log('Turn on kids room night walking light', domoticz.LOG_INFO)
end
elseif(domoticz.devices('MH1-katto').state == 'On' and domoticz.devices('MH1-katto').lastUpdate.minutesAgo > 10) then
-- no motion for a while, turn off kids room light
-- TODO: add check if was turned on by switch
domoticz.devices('MH1-katto').switchOff()
domoticz.log('Turn off kids room night walking light', domoticz.LOG_INFO)
end
end
}
LXC(x64 Ubuntu Xenial), RFXtrx433E, MySensors
-
- Posts: 1355
- Joined: Friday 29 August 2014 11:26
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Location: Ermelo
- Contact:
Re: How to check if group state is mixed?
Yes, that's because the group by itself is a kind of device that has a state. Its state is not depending on its group members. Don't know how expensive it is to provide the information in dzVents. I'm afraid it requires extra queries that have to be run before dzVents can start processing scripts.
Creator dzVents - RPi3, loads of zwave devices, esp8266, evohome.
-
- Posts: 140
- Joined: Wednesday 17 December 2014 17:30
- Target OS: Linux
- Domoticz version: V3.8650
- Location: Jyväskylä, Finland
- Contact:
Re: How to check if group state is mixed?
How expensive would it be to build device-id's list(and perhaps some other group device properties) for group when application is started and refresh it when group(scene) is modified?
Bit of the same area: viewtopic.php?f=59&t=19848
Code: Select all
SELECT Scenes.ID AS SceneID, SceneDevices.DeviceRowID AS DeviceID,
SceneDevices.Cmd AS DeviceCommand, SceneDevices.Level AS Level,
SceneDevices.Hue AS Hue, SceneDevices.OnDelay AS OnDelay,
SceneDevices.OffDelay AS OffDelay FROM SceneDevices
INNER JOIN Scenes ON Scenes.ID = SceneDevices.SceneRowID
WHERE Scenes.ID = 4
LXC(x64 Ubuntu Xenial), RFXtrx433E, MySensors
Who is online
Users browsing this forum: No registered users and 1 guest