How to check if Group Scene is activated

Easy to use, 100% Lua-based event scripting framework.

Moderator: leecollings

Post Reply
gschmidt
Posts: 200
Joined: Thursday 20 December 2018 11:03
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

How to check if Group Scene is activated

Post by gschmidt »

Hi,

How can I check in dzVents if a Group Scene is activated?
Is it like this:

Code: Select all

local TV = dz.groups('Ziggo TV')

if TV.state == 'On' then blabla
or else?
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: How to check if Group Scene is activated

Post by waaren »

gschmidt wrote: Saturday 01 May 2021 10:58 Hi,

How can I check in dzVents if a Group Scene is activated?
Is it like this:

Code: Select all

local TV = dz.groups('Ziggo TV')

if TV.state == 'On' then blabla
or else?
Yes something like that

Code: Select all

return
{
    on =
    {
        groups =
        {
            'Ziggo TV',
        },
    },

    logging = {
        level = domoticz.LOG_INFO,
        marker = 'groupState',
    },

    execute = function(dz, item)
        dz.groups().forEach(function(group)
            dz.log('Group ' .. group.name .. '; State: ' .. group.state .. '; Active: ' .. dz.utils.toStr(group.active))
        end)

        if item.state == 'On' then
            dz.log('\n\nGroup ' .. item.name.. ' is On')
        end

    end
}
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
gschmidt
Posts: 200
Joined: Thursday 20 December 2018 11:03
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: How to check if Group Scene is activated

Post by gschmidt »

waaren wrote: Saturday 01 May 2021 19:36
gschmidt wrote: Saturday 01 May 2021 10:58 Hi,

How can I check in dzVents if a Group Scene is activated?
Is it like this:

Code: Select all

local TV = dz.groups('Ziggo TV')

if TV.state == 'On' then blabla
or else?
Yes something like that

Code: Select all

return
{
    on =
    {
        groups =
        {
            'Ziggo TV',
        },
    },

    logging = {
        level = domoticz.LOG_INFO,
        marker = 'groupState',
    },

    execute = function(dz, item)
        dz.groups().forEach(function(group)
            dz.log('Group ' .. group.name .. '; State: ' .. group.state .. '; Active: ' .. dz.utils.toStr(group.active))
        end)

        if item.state == 'On' then
            dz.log('\n\nGroup ' .. item.name.. ' is On')
        end

    end
}
Thanx, this is working indeed.

However I am not sure if this is the approach for solving my problem. :?

To control my AV System (TV, Yamaha Receiver and Ziggo Next Box) I have created 11 Scenes.
Scene 1: Turns On Receiver, TV and Ziggo Next (to the correct outputs)
Scene 2: Turns Off: Receiver, TV and Ziggo Next
The other 9 Scenes are not using Ziggo Next so they also turn Off the Ziggo Next e.g. Watching Netflix with TV App:

Netflix.JPG
Netflix.JPG (43.42 KiB) Viewed 827 times

The problem is that the Ziggo Next Remote has a Toggle On/Off button.
So the Virtual On/Off Switch in domoticz, which controls the Ziggo Next box via Node-Red is actually a toggle On/Off button.

Now if I switch from Scene 1 to Scene 3 (Netflix) the Ziggo Next Box turns off correctly.
But when I switch from Scene 3 to one of the other Scenes (Except Scene 1), those Scenes also want to Turn Off the Ziggo Next...but it is already Turned Off by switching from Scene 1 to Scene 3, As a result the Ziggo Next is turned On (the Off Command in the group has no effect) again because it is a Toggle Button.

How can I solve this problem with dzVents?

Note: I also have created a Virtual Switch in Domoticz, which keeps track of the online/offline status of the Ziggo Next Box. (maybe this can be of use?)
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: How to check if Group Scene is activated

Post by waaren »

gschmidt wrote: Saturday 01 May 2021 20:31 Now if I switch from Scene 1 to Scene 3 (Netflix) the Ziggo Next Box turns off correctly.
But when I switch from Scene 3 to one of the other Scenes (Except Scene 1), those Scenes also want to Turn Off the Ziggo Next...but it is already Turned Off by switching from Scene 1 to Scene 3, As a result the Ziggo Next is turned On (the Off Command in the group has no effect) again because it is a Toggle Button.

Note: I also have created a Virtual Switch in Domoticz, which keeps track of the online/offline status of the Ziggo Next Box. (maybe this can be of use?)
That is a different question then the topic title.

You need a conditional action and that is not possible in a scene or group. You could solve it by removing the Ziggo next On/Off button from your scenes and use a dzVents script triggered by any of the described scenes and let the script perform the required action on the button.
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
gschmidt
Posts: 200
Joined: Thursday 20 December 2018 11:03
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: How to check if Group Scene is activated

Post by gschmidt »

waaren wrote: Saturday 01 May 2021 21:07
gschmidt wrote: Saturday 01 May 2021 20:31 Now if I switch from Scene 1 to Scene 3 (Netflix) the Ziggo Next Box turns off correctly.
But when I switch from Scene 3 to one of the other Scenes (Except Scene 1), those Scenes also want to Turn Off the Ziggo Next...but it is already Turned Off by switching from Scene 1 to Scene 3, As a result the Ziggo Next is turned On (the Off Command in the group has no effect) again because it is a Toggle Button.

Note: I also have created a Virtual Switch in Domoticz, which keeps track of the online/offline status of the Ziggo Next Box. (maybe this can be of use?)
That is a different question then the topic title.

You need a conditional action and that is not possible in a scene or group. You could solve it by removing the Ziggo next On/Off button from your scenes and use a dzVents script triggered by any of the described scenes and let the script perform the required action on the button.
Yes Sorry I know.

Removing the ZIggo Next from the Scenes and handle On/Off in dzVents was exactly my idea too!
This approach was the main reason for my Topic question, because I need the Scenes for Voice control i.c.w. Controlicz
Thanx I will give it a try!

One question about the checkFirst command: Switch.switchOn().checkFirst()
Will this check first if Switch is not already On, and if so the switchOn() command is not send?
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: How to check if Group Scene is activated

Post by waaren »

gschmidt wrote: Sunday 02 May 2021 9:44 One question about the checkFirst command: Switch.switchOn().checkFirst()
Will this check first if Switch is not already On, and if so the switchOn() command is not send?
Indeed.
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest