Page 1 of 1

Can a scene trigger other scenes?

Posted: Sunday 15 September 2019 14:00
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?

Re: Can a scene trigger other scenes?

Posted: Sunday 15 September 2019 15:37
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"

Re: Can a scene trigger other scenes?

Posted: Monday 16 September 2019 9:52
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 
}

Re: Can a scene trigger other scenes?

Posted: Monday 16 September 2019 9:59
by Gravityz
Ofcourse,
Ha. Need to update my os related lua scripts to dzvents

Re: Can a scene trigger other scenes?

Posted: Monday 16 September 2019 13:38
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