group.state not on / mixed
Moderator: leecollings
-
- Posts: 67
- Joined: Wednesday 10 May 2017 17:57
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
group.state not on / mixed
Hi,
I'm trying to make a dzvents script based on a group of lights.
I want to switch "Slapen" on when all lights are off between nighttime.
Is it possible to get the status "Mixed" of a group?
I now have a script based on "group.state == 'Off'" but "On" should not work because not all lights are on at once.
Can i set "group.state == 'Mixed" ? It is not stated in the wiki.
I'm trying to make a dzvents script based on a group of lights.
I want to switch "Slapen" on when all lights are off between nighttime.
Is it possible to get the status "Mixed" of a group?
I now have a script based on "group.state == 'Off'" but "On" should not work because not all lights are on at once.
Can i set "group.state == 'Mixed" ? It is not stated in the wiki.
- waaren
- Posts: 6028
- Joined: Tuesday 03 January 2017 14:18
- Target OS: Linux
- Domoticz version: Beta
- Location: Netherlands
- Contact:
Re: group.state not on / mixed
Yes,terrorsource wrote: ↑Thursday 13 September 2018 10:51 Hi,
I'm trying to make a dzvents script based on a group of lights.
I want to switch "Slapen" on when all lights are off between nighttime.
Is it possible to get the status "Mixed" of a group?
I now have a script based on "group.state == 'Off'" but "On" should not work because not all lights are on at once.
Can i set "group.state == 'Mixed" ? It is not stated in the wiki.
Code: Select all
return {
on = { devices = { "triggerDevice" }}, -- Change for your triggerDevice
logging = { level = domoticz.LOG_DEBUG,
marker = "Check Group state" },
execute = function(dz)
myGroup = dz.groups("All active devices") -- Change for your group
if myGroup.state == "Mixed" then
dz.log("state of group " .. myGroup.name .. " ===>> " .. myGroup.state,dz.LOG_DEBUG)
else
dz.log("state of group " .. myGroup.name .. " ===>> " .. myGroup.state,dz.LOG_DEBUG)
end
end
}
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
-
- Posts: 67
- Joined: Wednesday 10 May 2017 17:57
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: group.state not on / mixed
I've now created this, but it is not sending a message via Prowl when the status of the Group changes.
Code: Select all
return {
on = {
groups = { 'AlleLampenHuis' }
},
execute = function(dz)
myGroup = dz.groups("AlleLampenHuis") -- Change for your group
if myGroup.state == "Mixed" and domoticz.devices("Thuis").state == "Off" then
-- domoticz.devices("Slapen").switchOff().checkFirst()
domoticz.notify("State=MIXED","State=MIXED.", domoticz.PRIORITY_NORMAL,nil,nil,domoticz.NSS_PROWL)
elseif myGroup.state == "Off" and domoticz.devices("Thuis").state == "Off" then
-- domoticz.devices("Slapen").switchOn().checkFirst()
domoticz.notify("State=OFF","State=OFF.", domoticz.PRIORITY_NORMAL,nil,nil,domoticz.NSS_PROWL)
elseif myGroup.state == "On" and domoticz.devices("Thuis").state == "Off" then
-- domoticz.devices("Slapen").switchOff().checkFirst()
domoticz.notify("State=ON","State=ON.", domoticz.PRIORITY_NORMAL,nil,nil,domoticz.NSS_PROWL)
end
end
}
- waaren
- Posts: 6028
- Joined: Tuesday 03 January 2017 14:18
- Target OS: Linux
- Domoticz version: Beta
- Location: Netherlands
- Contact:
Re: group.state not on / mixed
Try change all "dz" to "domoticz" or vice versa.
Verstuurd vanaf mijn ONEPLUS A3003 met Tapatalk
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
-
- Posts: 67
- Joined: Wednesday 10 May 2017 17:57
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: group.state not on / mixed
Still not working. I've even cleaned up the script but it is not sending messages. Looks like it's never triggered.
Now have only 1 switch in the group, a dummy switch. when i toggle it nothing happens.
Code: Select all
return {
on = {
groups = { 'AlleLampenHuis' }
},
execute = function(domoticz, group)
myGroup = domoticz.groups("AlleLampenHuis")
if myGroup.state == "Mixed" then
domoticz.notify("State=MIXED","State=MIXED.", domoticz.PRIORITY_NORMAL,nil,nil,domoticz.NSS_PROWL)
elseif myGroup.state == "Off" then
domoticz.notify("State=OFF","State=OFF.", domoticz.PRIORITY_NORMAL,nil,nil,domoticz.NSS_PROWL)
elseif myGroup.state == "On" then
domoticz.notify("State=ON","State=ON.", domoticz.PRIORITY_NORMAL,nil,nil,domoticz.NSS_PROWL)
end
end
}
- waaren
- Posts: 6028
- Joined: Tuesday 03 January 2017 14:18
- Target OS: Linux
- Domoticz version: Beta
- Location: Netherlands
- Contact:
Re: group.state not on / mixed
The script in its current form will only execute when the group is switched On or Off. State changes of any device in the group will not trigger it.terrorsource wrote: ↑Thursday 13 September 2018 20:25Still not working. I've even cleaned up the script but it is not sending messages. Looks like it's never triggered.
Now have only 1 switch in the group, a dummy switch. when i toggle it nothing happens.
domoticz simply does not create a group level event for it and dzVents is therefore not aware anything changed on the grouplevel.
If you want to have the script triggered on any groupdevice change you will have to add these devices in the "on = devices" section
Code: Select all
on = { devices = { "groupdevice1, groupdevice2 , ... groupdevice99" }},
what might help is that these devicenames can be entered in a wildcard form e.g. group*
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
-
- Posts: 67
- Joined: Wednesday 10 May 2017 17:57
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: group.state not on / mixed
The last script is just for test purposes only.waaren wrote: ↑Thursday 13 September 2018 21:21The script in its current form will only execute when the group is switched On or Off. State changes of any device in the group will not trigger it.terrorsource wrote: ↑Thursday 13 September 2018 20:25Still not working. I've even cleaned up the script but it is not sending messages. Looks like it's never triggered.
Now have only 1 switch in the group, a dummy switch. when i toggle it nothing happens.
domoticz simply does not create a group level event for it and dzVents is therefore not aware anything changed on the grouplevel.
If you want to have the script triggered on any groupdevice change you will have to add these devices in the "on = devices" sectionCode: Select all
on = { devices = { "groupdevice1, groupdevice2 , ... groupdevice99" }},
what might help is that these devicenames can be entered in a wildcard form e.g. group*
Want to have it send a message when the group has changed (ON/OFF/Mixed).
From there on i can switch "Sleeping" on and create an alarm for motion and doors.
- waaren
- Posts: 6028
- Joined: Tuesday 03 January 2017 14:18
- Target OS: Linux
- Domoticz version: Beta
- Location: Netherlands
- Contact:
Re: group.state not on / mixed
Maybe this other approach can help you achieving what you want. It will notify you within a minute after a group state change happens by a device in that group or imediate when the group itself was changed manual of via a command.terrorsource wrote: ↑Friday 14 September 2018 9:28 The last script is just for test purposes only.
Want to have it send a message when the group has changed (ON/OFF/Mixed).
From there on i can switch "Sleeping" on and create an alarm for motion and doors.
When executed the first time it will also send 1 notification
Code: Select all
local groupName = "AlleLampenHuis"
return {
on = {
groups = { groupName },
timer = { "every minute" },
httpResponses = { "getSceneState" }},
logging = {
level = domoticz.LOG_INFO,
marker = "getSceneState"
},
data = { state = { initial = "" }},
execute = function(dz, item)
local myGroup = dz.groups(groupName)
local function triggerJSON()
local urlString = dz.settings['Domoticz url'] .. "/json.htm?type=scenes"
dz.openURL({ url = urlString,
method = "GET",
callback = "getSceneState" })
end
local function getState(groupName)
local state = "No state found for " .. groupName
if item.json.result ~= nil then
rt = item.json.result
else
dz.log("No values found",dz.LOG_DEBUG )
return
end
for i=1,#rt do -- Loop through the result
dz.log( "Checking group " .. rt[i].idx .. " ===>> " .. rt[i].Name ,dz.LOG_DEBUG)
if rt[i].Name == groupName then
return rt[i].Status
end
end
return state
end
if item.isHTTPResponse then
myGroup.state = getState(groupName)
if myGroup.state ~= dz.data.state then
dz.data.state = myGroup.state
dz.log("State changed to " .. myGroup.state, dz.LOG_FORCE)
dz.notify("State=" .. myGroup.state ,"State=" .. myGroup.state, dz.PRIORITY_NORMAL,nil,nil,dz.NSS_PROWL)
else
dz.log("State of : " .. myGroup.name .. " is still " .. myGroup.state, dz.LOG_DEBUG)
end
else
triggerJSON()
end
end
}
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
-
- Posts: 67
- Joined: Wednesday 10 May 2017 17:57
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: group.state not on / mixed
Thanks for the script. i've extended it a bit further.waaren wrote: ↑Saturday 15 September 2018 21:48Maybe this other approach can help you achieving what you want. It will notify you within a minute after a group state change happens by a device in that group or imediate when the group itself was changed manual of via a command.terrorsource wrote: ↑Friday 14 September 2018 9:28 The last script is just for test purposes only.
Want to have it send a message when the group has changed (ON/OFF/Mixed).
From there on i can switch "Sleeping" on and create an alarm for motion and doors.
When executed the first time it will also send 1 notification
This is the result:
Code: Select all
local groupName = "AlleLampenHuis"
return {
on = {
groups = { groupName },
timer = { "every minute between nighttime and 05:00", "at 05:01" },
httpResponses = { "getSceneState" }},
logging = {
level = domoticz.LOG_INFO,
marker = "getSceneState"
},
data = { state = { initial = "" }},
execute = function(dz, item)
local myGroup = dz.groups(groupName)
local function triggerJSON()
local urlString = dz.settings['Domoticz url'] .. "/json.htm?type=scenes"
dz.openURL({ url = urlString,
method = "GET",
callback = "getSceneState" })
end
local function getState(groupName)
local state = "No state found for " .. groupName
if item.json.result ~= nil then
rt = item.json.result
else
dz.log("No values found",dz.LOG_DEBUG )
return
end
for i=1,#rt do -- Loop through the result
dz.log( "Checking group " .. rt[i].idx .. " ===>> " .. rt[i].Name ,dz.LOG_DEBUG)
if rt[i].Name == groupName then
return rt[i].Status
end
end
return state
end
if item.isHTTPResponse then
myGroup.state = getState(groupName)
if domoticz.time.matchesRule("at 05:01") then
dz.devices("Slapen").switchOff().checkFirst()
dz.notify("Slaapstand=OFF","Slaapstand is uitgezet.", dz.PRIORITY_NORMAL,nil,nil,dz.NSS_PROWL)
elseif myGroup.state ~= dz.data.state then
dz.data.state = myGroup.state
if dz.data.state == "Off" and dz.devices("Thuis").state == "On" then
dz.devices("Slapen").switchOn().checkFirst()
dz.notify("Slaapstand=ON","Slaapstand is aangezet.", dz.PRIORITY_NORMAL,nil,nil,dz.NSS_PROWL)
elseif dz.data.state == "On" and dz.devices("Thuis").state == "On" then
dz.devices("Slapen").switchOff().checkFirst()
dz.notify("Slaapstand=OFF","Slaapstand is uitgezet.", dz.PRIORITY_NORMAL,nil,nil,dz.NSS_PROWL)
elseif dz.data.state == "Mixed" and dz.devices("Thuis").state == "On" then
dz.devices("Slapen").switchOff().checkFirst()
dz.notify("Slaapstand=OFF","Slaapstand is uitgezet.", dz.PRIORITY_NORMAL,nil,nil,dz.NSS_PROWL)
end
elseif
dz.log("Status van : " .. myGroup.name .. " is nog steeds: " .. myGroup.state, dz.LOG_DEBUG)
end
else
triggerJSON()
end
end
}
Who is online
Users browsing this forum: No registered users and 1 guest