Can a scene trigger other scenes?

Moderator: leecollings

Post Reply
User avatar
leecollings
Posts: 167
Joined: Tuesday 30 June 2015 18:09
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: United Kingdom
Contact:

Can a scene trigger other scenes?

Post by leecollings »

I'd like to create an ALL OFF scene for each room in my house, which is easy enough.

But I'd also like to create a scene that triggers every ALL OFF scene I have. Is this possible?

Or is it better to just create each individual ALL OFF scene, and then create a blockly that goes through each one on the condition I want the global ALL OFF to be triggered? (For example, this will be when my Nest Away switch comes ON.

(The idea being that when no one is at home, all the lights get turned off).

What's your ideas?
Gravityz
Posts: 587
Joined: Wednesday 16 December 2015 19:13
Target OS: NAS (Synology & others)
Domoticz version: 2022.2
Location: Netherlands
Contact:

Re: Can a scene trigger other scenes?

Post by Gravityz »

not in domoticz i think

what i would do is make the different scenes for the rooms.
then make a scene whicj switches of eveything(with no devices in it)

make a bash script which turns off all the seperate scenes and put that script in the on action

ON Action: script:///usr/local/domoticz/var/scripts/allscenes-off.sh

something like

#!/bin/ash
curl -s "http://192.168.1.xx:xxxx/json.htm?type=command&param=switchlight&idx=SCENEID-ROOM1&switchcmd=Off"
curl -s "http://192.168.1.xx:xxxx/json.htm?type=command&param=switchlight&idx=SCENEID-ROOM2&switchcmd=Off"
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: Can a scene trigger other scenes?

Post by waaren »

leecollings wrote: Sunday 15 September 2019 14:00 What's your ideas?
My idea is:
  • create a Scene for each room (as you already mentioned)
  • create an (empty) All off scene
  • use dzVents to trigger room scenes

Code: Select all

return 
{

    on = { scenes = { 'House off' }},
              
    logging = {
                level = domoticz.LOG_DEBUG,
                marker = 'All off'
              },

    execute = function(dz)
        
        local timeBetweenScenes = 3 -- Find out how much time is needed between the individual scenes to get it working OK 
        local sceneDelay = 0
        
        dz.scenes().filter(function(scene)
            return ( (scene.name):find('Room') and (scene.name):find('Off')  ) -- based on finding string(s) in scene Names
        end).forEach(function(roomScene)
            roomScene.switchOn().afterSec(sceneDelay)
            sceneDelay = sceneDelay + timeBetweenScenes
        end)
        
     end 
}
or a bit shorter.

Code: Select all

return 
{

    on = { scenes = { 'House off' }},
              
    logging = {
                level = domoticz.LOG_INFO,
                marker = 'All off'
              },

    execute = function(dz)
        
        local timeBetweenScenes = 3 -- Find out how much time is needed between the individual scenes to get it working OK 
        local sceneDelay = 0
        local scenesRoomOff = { 40, 41, 42 } -- Scene idx numbers
        
        dz.scenes().filter(scenesRoomOff).forEach(function(roomScene)
            dz.log('Switching scene ' .. roomScene.name .. ' after ' .. sceneDelay .. ' seconds.')
            roomScene.switchOn().afterSec(sceneDelay)
            sceneDelay = sceneDelay + timeBetweenScenes
        end)
     end 
}
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
Gravityz
Posts: 587
Joined: Wednesday 16 December 2015 19:13
Target OS: NAS (Synology & others)
Domoticz version: 2022.2
Location: Netherlands
Contact:

Re: Can a scene trigger other scenes?

Post by Gravityz »

Ofcourse,
Ha. Need to update my os related lua scripts to dzvents
User avatar
leecollings
Posts: 167
Joined: Tuesday 30 June 2015 18:09
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: United Kingdom
Contact:

Re: Can a scene trigger other scenes?

Post by leecollings »

waaren wrote: Monday 16 September 2019 9:52
leecollings wrote: Sunday 15 September 2019 14:00 What's your ideas?
My idea is:
  • create a Scene for each room (as you already mentioned)
  • create an (empty) All off scene
  • use dzVents to trigger room scenes

Code: Select all

return 
{

    on = { scenes = { 'House off' }},
              
    logging = {
                level = domoticz.LOG_DEBUG,
                marker = 'All off'
              },

    execute = function(dz)
        
        local timeBetweenScenes = 3 -- Find out how much time is needed between the individual scenes to get it working OK 
        local sceneDelay = 0
        
        dz.scenes().filter(function(scene)
            return ( (scene.name):find('Room') and (scene.name):find('Off')  ) -- based on finding string(s) in scene Names
        end).forEach(function(roomScene)
            roomScene.switchOn().afterSec(sceneDelay)
            sceneDelay = sceneDelay + timeBetweenScenes
        end)
        
     end 
}
or a bit shorter.

Code: Select all

return 
{

    on = { scenes = { 'House off' }},
              
    logging = {
                level = domoticz.LOG_INFO,
                marker = 'All off'
              },

    execute = function(dz)
        
        local timeBetweenScenes = 3 -- Find out how much time is needed between the individual scenes to get it working OK 
        local sceneDelay = 0
        local scenesRoomOff = { 40, 41, 42 } -- Scene idx numbers
        
        dz.scenes().filter(scenesRoomOff).forEach(function(roomScene)
            dz.log('Switching scene ' .. roomScene.name .. ' after ' .. sceneDelay .. ' seconds.')
            roomScene.switchOn().afterSec(sceneDelay)
            sceneDelay = sceneDelay + timeBetweenScenes
        end)
     end 
}
Thanks for that, however I don't use dzVents, so I'll create a Blockly script to keep things simple, and I'll just trigger each room ALL OFF when the Away switch is set to On.

Thanks
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest