turn off all lights

Moderator: leecollings

Post Reply
Gianni
Posts: 230
Joined: Saturday 21 July 2018 19:03
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: Home@Belgium
Contact:

turn off all lights

Post by Gianni »

I have a zwave mesh and a 2 gang switch near my front door.
I only used 1 gang wired and the point was to use the second gang as a virtual switch to turn off all lights when i'm leave.
I already made a blocky but this is not working.
I create a group and this works but i cannot connect the group to the switch?
Can anyone point me to the right direction how i can use a wall switch to controll other switches?

greets G,
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: turn off all lights

Post by waaren »

Gianni wrote: Saturday 29 December 2018 0:38 Can anyone point me to the right direction how i can use a wall switch to controll other switches?
There are more answers to this.
1. Group activation device; goto the edit page of your group to the part Activation devices. Press Add device button and you will have a couple of seconds to press the switch that you want to control your group.
2. Use dzVents script below.

Code: Select all

-- group trigger

return {
            on      = { devices = { "groupSwitch"}}, -- Change to the name of the switch that you want to use for controlling the group 
    
    execute = function(dz,item)
        local myGroup = "Happy NewYear"              -- Change to the name of the group that you want to control 
        if item.state == "Off" then
            dz.groups(myGroup).switchOff()
        else
            dz.groups(myGroup).switchOn()
        end
    end
}
3. Blockly
blockly.png
blockly.png (25.62 KiB) Viewed 6480 times
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
Gianni
Posts: 230
Joined: Saturday 21 July 2018 19:03
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: Home@Belgium
Contact:

Re: turn off all lights

Post by Gianni »

Hello Waaren

did not know it was so easy
I know now why my blocky not worked i did not know there was a blocky set group :-)
But i took the first solution and added my switch to the activation.

can you help me wit this 2?
Now i can control all the lights on/off from 1 switch.
But if i turn on 1 switch let say living then the master switch will not turn on.
So i need to turn the switch on and off and then i can turn all the other switches off.

is there a way that the master switch get active with the other switches but not turn on all lights?
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: turn off all lights

Post by waaren »

Gianni wrote: Sunday 30 December 2018 22:11 But i took the first solution and added my switch to the activation.
Now i can control all the lights on/off from 1 switch.
But if i turn on 1 switch let say living then the master switch will not turn on.
So i need to turn the switch on and off and then i can turn all the other switches off.
is there a way that the master switch get active with the other switches but not turn on all lights?
Not if you use the master switch as a group activation device like you did. As soon as it switches On the group will be switched On as well, even if you use the option silent().
If you would choose to trigger the group by a script you can set it up like you want because you can use the option silent() what would prevent any further script activations from this switch.

But what about the situation that the switch is switched On silently and you would want all devices in the group to be switched On ?
Aren't you then in the same type of situation as you describe ? You would first have to switch it Off before switching On would cause the group to act according to your intention.
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
Gianni
Posts: 230
Joined: Saturday 21 July 2018 19:03
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: Home@Belgium
Contact:

Re: turn off all lights

Post by Gianni »

i have thought on this to :-)
But the main goal of this switch is to extend it with other devices and when i leave the house klik on the master switch and everything that is on will be turn off.
So normally it will never be used to turn everything on.
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: turn off all lights

Post by waaren »

Gianni wrote: Monday 31 December 2018 1:08 But the main goal of this switch is to extend it with other devices and when i leave the house klik on the master switch and everything that is on will be turn off.
So normally it will never be used to turn everything on.
In that case I suggest you switch to the method with the (slightly modified for this additional requirement) dzVents script.

Code: Select all

-- group trigger

return {
            on      = { devices = { "groupSwitch"}}, -- Change to the name of the switch that you want to use for controlling the group 
    
    execute = function(dz,item)
        local myGroup = "Happy NewYear"              -- Change to the name of the group that you want to control 
        if item.state == "Off" then
            dz.groups(myGroup).switchOff()              
            item.switchOn().aftersec(3).silent()       -- Masterswitch will return to On state after 3 seconds without triggering any script
        else
            dz.groups(myGroup).switchOn()
        end
    end
}
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
Gianni
Posts: 230
Joined: Saturday 21 July 2018 19:03
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: Home@Belgium
Contact:

Re: turn off all lights

Post by Gianni »

hello waaren

i try this but i think the silent did not works.
If i turn off the master switch he turn in in 3 second but all the other lights will go on 2 :-)
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: turn off all lights

Post by waaren »

Gianni wrote: Wednesday 02 January 2019 1:45 i try this but i think the silent did not works.
If i turn off the master switch he turn in in 3 second but all the other lights will go on 2 :-)
Did you remove this switch from the list of group activation devices ?
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
Gianni
Posts: 230
Joined: Saturday 21 July 2018 19:03
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: Home@Belgium
Contact:

Re: turn off all lights

Post by Gianni »

yep all switches ar removed from the list.

i have a copy of the log file maybe you see someting but for me it's not clear :-p.
The masterswitch called "alles uit living"
The group called "G_Alles_Living"

Code: Select all

2019-01-02 14:37:25.237 Status: dzVents: Debug: - Device: Lichten_Eetplaats
2019-01-02 14:37:25.237 Status: dzVents: Debug: - Device: Lichten_Toilet
2019-01-02 14:37:25.237 Status: dzVents: Debug: - Device: Lichten_Gang
2019-01-02 14:37:25.237 Status: dzVents: Debug: - Device: Lichten_Living
2019-01-02 14:37:25.268 Status: dzVents: Info: Handling events for: "Lichten_Gang", value: "Off"
2019-01-02 14:37:25.268 Status: dzVents: Info: ------ Start internal script: wissel _gang: Device: "Lichten_Gang (Schakelaars_Boven)", Index: 113
2019-01-02 14:37:25.269 Status: dzVents: Debug: Processing device-adapter for Wissel_Gang: Switch device adapter
2019-01-02 14:37:25.269 Status: dzVents: Debug: Constructed timed-command: Off
2019-01-02 14:37:25.269 Status: dzVents: Debug: Constructed timed-command: Off NOTRIGGER
2019-01-02 14:37:25.269 Status: dzVents: Info: ------ Finished wissel _gang 
2019-01-02 14:37:25.269 Status: dzVents: Debug: Commands sent to Domoticz:
2019-01-02 14:37:25.269 Status: dzVents: Debug: - Wissel_Gang = Off NOTRIGGER
2019-01-02 14:37:25.269 Status: dzVents: Debug: =====================================================
2019-01-02 14:37:25.270 Status: dzVents: Info: Handling events for: "Lichten_Living", value: "Off"
2019-01-02 14:37:25.270 Status: dzVents: Info: ------ Start internal script: wissel_living: Device: "Lichten_Living (Controller)", Index: 122
2019-01-02 14:37:25.271 Status: dzVents: Debug: Processing device-adapter for Wissel_Living: Switch device adapter
2019-01-02 14:37:25.271 Status: dzVents: Debug: Constructed timed-command: Off
2019-01-02 14:37:25.271 Status: dzVents: Debug: Constructed timed-command: Off NOTRIGGER
2019-01-02 14:37:25.271 Status: dzVents: Info: ------ Finished wissel_living
2019-01-02 14:37:25.271 Status: dzVents: Debug: Commands sent to Domoticz:
2019-01-02 14:37:25.271 Status: dzVents: Debug: - Wissel_Living = Off NOTRIGGER
2019-01-02 14:37:25.271 Status: dzVents: Debug: =====================================================
2019-01-02 14:37:25.354 Status: EventSystem: Script event triggered: /home/gianni/domoticz/dzVents/runtime/dzVents.lua
2019-01-02 14:37:25.394 Status: dzVents: Debug: Dumping domoticz data to /home/gianni/domoticz/scripts/dzVents/domoticzData.lua
2019-01-02 14:37:25.428 Status: dzVents: Debug: Processing device-adapter for Lichten_Kookplaats: Switch device adapter
2019-01-02 14:37:25.429 Status: dzVents: Debug: Processing device-adapter for Alles_Uit_Living: Switch device adapter
2019-01-02 14:37:25.430 Status: dzVents: Debug: Processing device-adapter for Lichten_Keukentafel: Switch device adapter
2019-01-02 14:37:25.430 Status: dzVents: Debug: dzVents version: 2.4.6
2019-01-02 14:37:25.430 Status: dzVents: Debug: Event triggers:
2019-01-02 14:37:25.430 Status: dzVents: Debug: - Device: Lichten_Kookplaats
2019-01-02 14:37:25.430 Status: dzVents: Debug: - Device: Alles_Uit_Living
2019-01-02 14:37:25.430 Status: dzVents: Debug: - Device: Lichten_Keukentafel
2019-01-02 14:37:25.460 Status: dzVents: Info: Handling events for: "Alles_Uit_Living", value: "On"
2019-01-02 14:37:25.460 Status: dzVents: Info: ------ Start internal script: Alles_uit_Living: Device: "Alles_Uit_Living (Controller)", Index: 123
2019-01-02 14:37:25.461 Status: dzVents: Debug: Processing device-adapter for G_Alles_Living: Group device adapter
2019-01-02 14:37:25.461 Status: dzVents: Debug: Constructed timed-command: On
2019-01-02 14:37:25.461 Status: dzVents: Info: ------ Finished Alles_uit_Living
2019-01-02 14:37:25.461 Status: dzVents: Debug: Commands sent to Domoticz:
2019-01-02 14:37:25.461 Status: dzVents: Debug: - Group:G_Alles_Living = On
2019-01-02 14:37:25.461 Status: dzVents: Debug: =====================================================
2019-01-02 14:37:25.461 Status: dzVents: Info: Handling events for: "Lichten_Keukentafel", value: "Off"
2019-01-02 14:37:25.461 Status: dzVents: Info: ------ Start internal script: wissel_keuken: Device: "Lichten_Keukentafel (Controller)", Index: 128
2019-01-02 14:37:25.462 Status: dzVents: Debug: Processing device-adapter for Wissel_Keukentafel: Switch device adapter
2019-01-02 14:37:25.462 Status: dzVents: Debug: Constructed timed-command: Off
2019-01-02 14:37:25.462 Status: dzVents: Debug: Constructed timed-command: Off NOTRIGGER
2019-01-02 14:37:25.462 Status: dzVents: Info: ------ Finished wissel_keuken
2019-01-02 14:37:25.462 Status: dzVents: Debug: Commands sent to Domoticz:
2019-01-02 14:37:25.463 Status: dzVents: Debug: - Wissel_Keukentafel = Off NOTRIGGER
2019-01-02 14:37:25.463 Status: dzVents: Debug: =====================================================
2019-01-02 14:37:25.574 Status: EventSystem: Script event triggered: /home/gianni/domoticz/dzVents/runtime/dzVents.lua
2019-01-02 14:37:25.659 Status: dzVents: Debug: Dumping domoticz data to /home/gianni/domoticz/scripts/dzVents/domoticzData.lua
2019-01-02 14:37:25.722 Status: dzVents: Debug: Processing device-adapter for G_Alles_Living: Group device adapter
2019-01-02 14:37:25.722 Status: dzVents: Debug: dzVents version: 2.4.6
2019-01-02 14:37:25.722 Status: dzVents: Debug: Event triggers:
2019-01-02 14:37:25.722 Status: dzVents: Debug: - Group: G_Alles_Living
2019-01-02 14:37:25.815 Status: dzVents: Debug: Group-event for: G_Alles_Living value: On
2019-01-02 14:37:25.881 Status: dzVents: Debug: Dumping domoticz data to /home/gianni/domoticz/scripts/dzVents/domoticzData.lua
2019-01-02 14:37:25.915 Status: dzVents: Debug: Processing device-adapter for Lichten_Eetplaats: Switch device adapter
2019-01-02 14:37:25.916 Status: dzVents: Debug: Processing device-adapter for Lichten_Toilet: Switch device adapter
2019-01-02 14:37:25.917 Status: dzVents: Debug: Processing device-adapter for Lux_Beneden: Lux device adapter
2019-01-02 14:37:25.918 Status: dzVents: Debug: Processing device-adapter for Lichten_Gang: Switch device adapter
2019-01-02 14:37:25.918 Status: dzVents: Debug: Processing device-adapter for Lichten_Living: Switch device adapter
2019-01-02 14:37:25.920 Status: dzVents: Debug: Processing device-adapter for Lichten_Keukentafel: Switch device adapter
2019-01-02 14:37:25.920 Status: dzVents: Debug: dzVents version: 2.4.6
2019-01-02 14:37:25.920 Status: dzVents: Debug: Event triggers:
2019-01-02 14:37:25.920 Status: dzVents: Debug: - Device: Lichten_Eetplaats
2019-01-02 14:37:25.920 Status: dzVents: Debug: - Device: Lichten_Toilet
2019-01-02 14:37:25.920 Status: dzVents: Debug: - Device: Lux_Beneden
2019-01-02 14:37:25.920 Status: dzVents: Debug: - Device: Lichten_Gang
2019-01-02 14:37:25.920 Status: dzVents: Debug: - Device: Lichten_Living
2019-01-02 14:37:25.920 Status: dzVents: Debug: - Device: Lichten_Keukentafel
2019-01-02 14:37:25.953 Status: dzVents: Info: Handling events for: "Lichten_Gang", value: "On"
2019-01-02 14:37:25.953 Status: dzVents: Info: ------ Start internal script: wissel _gang: Device: "Lichten_Gang (Schakelaars_Boven)", Index: 113
2019-01-02 14:37:25.954 Status: dzVents: Debug: Processing device-adapter for Wissel_Gang: Switch device adapter
2019-01-02 14:37:25.954 Status: dzVents: Debug: Constructed timed-command: On
2019-01-02 14:37:25.954 Status: dzVents: Debug: Constructed timed-command: On NOTRIGGER
2019-01-02 14:37:25.955 Status: dzVents: Info: ------ Finished wissel _gang
2019-01-02 14:37:25.955 Status: dzVents: Debug: Commands sent to Domoticz:
2019-01-02 14:37:25.955 Status: dzVents: Debug: - Wissel_Gang = On NOTRIGGER
2019-01-02 14:37:25.955 Status: dzVents: Debug: =====================================================
2019-01-02 14:37:25.955 Status: dzVents: Info: Handling events for: "Lichten_Living", value: "On"
2019-01-02 14:37:25.955 Status: dzVents: Info: ------ Start internal script: wissel_living: Device: "Lichten_Living (Controller)", Index: 122
2019-01-02 14:37:25.956 Status: dzVents: Debug: Processing device-adapter for Wissel_Living: Switch device adapter
2019-01-02 14:37:25.956 Status: dzVents: Debug: Constructed timed-command: On
2019-01-02 14:37:25.956 Status: dzVents: Debug: Constructed timed-command: On NOTRIGGER
2019-01-02 14:37:25.956 Status: dzVents: Info: ------ Finished wissel_living
2019-01-02 14:37:25.956 Status: dzVents: Debug: Commands sent to Domoticz:
2019-01-02 14:37:25.956 Status: dzVents: Debug: - Wissel_Living = On NOTRIGGER
2019-01-02 14:37:25.956 Status: dzVents: Debug: =====================================================
2019-01-02 14:37:25.956 Status: dzVents: Info: Handling events for: "Lichten_Keukentafel", value: "On"
2019-01-02 14:37:25.956 Status: dzVents: Info: ------ Start internal script: wissel_keuken: Device: "Lichten_Keukentafel (Controller)", Index: 128
2019-01-02 14:37:25.957 Status: dzVents: Debug: Processing device-adapter for Wissel_Keukentafel: Switch device adapter
2019-01-02 14:37:25.957 Status: dzVents: Info: ------ Finished wissel_keuken
2019-01-02 14:37:26.078 (Schakelaars_Boven) Light/Switch (Wissel_Gang)
2019-01-02 14:37:26.080 OpenZWave: Domoticz has send a Switch command! NodeID: 3 (0x03)
2019-01-02 14:37:26.083 (Controller) Light/Switch (Wissel_Living)
2019-01-02 14:37:26.039 Status: EventSystem: Script event triggered: /home/gianni/domoticz/dzVents/runtime/dzVents.lua
2019-01-02 14:37:26.079 Status: dzVents: Debug: Dumping domoticz data to /home/gianni/domoticz/scripts/dzVents/domoticzData.lua
2019-01-02 14:37:26.116 Status: dzVents: Debug: Processing device-adapter for Lichten_Kookplaats: Switch device adapter
2019-01-02 14:37:26.116 Status: dzVents: Debug: dzVents version: 2.4.6
2019-01-02 14:37:26.116 Status: dzVents: Debug: Event triggers:
2019-01-02 14:37:26.116 Status: dzVents: Debug: - Device: Lichten_Kookplaats
2019-01-02 14:37:29.149 MQTT: Topic: domoticz/in, Message: {"idx":57,"nvalue":0,"svalue":"82;128347.4","Battery":58,"RSSI":5}
2019-01-02 14:37:29.257 MQTT: Topic: domoticz/in, Message: {"idx":53,"nvalue":0,"svalue":"240","Battery":58,"RSSI":6}
2019-01-02 14:37:29.362 MQTT: Topic: domoticz/in, Message: {"idx":55,"nvalue":0,"svalue":"0.614","Battery":58,"RSSI":6}
2019-01-02 14:37:29.222 Status: dzVents: Debug: Dumping domoticz data to /home/gianni/domoticz/scripts/dzVents/domoticzData.lua
2019-01-02 14:37:29.267 Status: dzVents: Debug: Processing device-adapter for test: kWh device adapter
2019-01-02 14:37:29.267 Status: dzVents: Debug: dzVents version: 2.4.6
2019-01-02 14:37:29.267 Status: dzVents: Debug: Event triggers:
2019-01-02 14:37:29.267 Status: dzVents: Debug: - Device: test
2019-01-02 14:37:29.416 Status: dzVents: Debug: Dumping domoticz data to /home/gianni/domoticz/scripts/dzVents/domoticzData.lua
2019-01-02 14:37:29.447 Status: dzVents: Debug: Processing device-adapter for Patchkast: Voltage device adapter
2019-01-02 14:37:29.448 Status: dzVents: Debug: Processing device-adapter for Patchkast: 1-phase Ampere device adapter
2019-01-02 14:37:29.449 Status: dzVents: Debug: dzVents version: 2.4.6
2019-01-02 14:37:29.449 Status: dzVents: Debug: Event triggers:
2019-01-02 14:37:29.449 Status: dzVents: Debug: - Device: Patchkast
2019-01-02 14:37:29.449 Status: dzVents: Debug: - Device: Patchkast
2019-01-02 14:37:32.872 (Controller) Temp (Temperature_Motion_Living)
2019-01-02 14:37:33.004 Status: dzVents: Debug: Processing device-adapter for Temperature_Motion_Living: Temperature device adapter
2019-01-02 14:37:33.005 Status: dzVents: Debug: dzVents version: 2.4.6
2019-01-02 14:37:33.005 Status: dzVents: Debug: Event triggers:
2019-01-02 14:37:33.005 Status: dzVents: Debug: - Device: Temperature_Motion_Living
2019-01-02 14:37:42.978 (Controller) Temp (Temperature_Motion_Living)
2019-01-02 14:37:43.050 Status: dzVents: Debug: Dumping domoticz data to /home/gianni/domoticz/scripts/dzVents/domoticzData.lua
2019-01-02 14:37:43.122 Status: dzVents: Debug: Processing device-adapter for Temperature_Motion_Living: Temperature device adapter
2019-01-02 14:37:43.122 Status: dzVents: Debug: dzVents version: 2.4.6
2019-01-02 14:37:43.122 Status: dzVents: Debug: Event triggers:
2019-01-02 14:37:43.122 Status: dzVents: Debug: - Device: Temperature_Motion_Living
2019-01-02 14:37:53.084 (Controller) Temp (Temperature_Motion_Living)
2019-01-02 14:37:53.157 Status: dzVents: Debug: Dumping domoticz data to /home/gianni/domoticz/scripts/dzVents/domoticzData.lua
2019-01-02 14:37:53.208 Status: dzVents: Debug: Processing device-adapter for Temperature_Motion_Living: Temperature device adapter
2019-01-02 14:37:53.209 Status: dzVents: Debug: dzVents version: 2.4.6
2019-01-02 14:37:53.209 Status: dzVents: Debug: Event triggers:
2019-01-02 14:37:53.209 Status: dzVents: Debug: - Device: Temperature_Motion_Living
2019-01-02 14:37:56.133 (Controller) Lux (Lux_Beneden)
2019-01-02 14:37:56.200 Status: dzVents: Debug: Dumping domoticz data to /home/gianni/domoticz/scripts/dzVents/domoticzData.lua
2019-01-02 14:37:56.237 Status: dzVents: Debug: Processing device-adapter for Lux_Beneden: Lux device adapter
2019-01-02 14:37:56.237 Status: dzVents: Debug: dzVents version: 2.4.6
2019-01-02 14:37:56.237 Status: dzVents: Debug: Event triggers:
2019-01-02 14:37:56.237 Status: dzVents: Debug: - Device: Lux_Beneden
2019-01-02 14:38:00.539 Status: dzVents: Debug: Dumping domoticz data to /home/gianni/domoticz/scripts/dzVents/domoticzData.lua
2019-01-02 14:38:00.569 Status: dzVents: Debug: Event triggers:
2019-01-02 14:38:00.569 Status: dzVents: Debug: - Timer
2019-01-02 14:38:03.196 (Controller) Temp (Temperature_Motion_Living)
2019-01-02 14:38:03.263 Status: dzVents: Debug: Dumping domoticz data to /home/gianni/domoticz/scripts/dzVents/domoticzData.lua
2019-01-02 14:38:03.296 Status: dzVents: Debug: Processing device-adapter for Temperature_Motion_Living: Temperature device adapter
2019-01-02 14:38:03.296 Status: dzVents: Debug: dzVents version: 2.4.6
2019-01-02 14:38:03.296 Status: dzVents: Debug: Event triggers:
2019-01-02 14:38:03.296 Status: dzVents: Debug: - Device: Temperature_Motion_Living
2019-01-02 14:38:13.305 (Controller) Temp (Temperature_Motion_Living)
2019-01-02 14:38:13.371 Status: dzVents: Debug: Dumping domoticz data to /home/gianni/domoticz/scripts/dzVents/domoticzData.lua
2019-01-02 14:38:13.431 Status: dzVents: Debug: Processing device-adapter for Temperature_Motion_Living: Temperature device adapter
2019-01-02 14:38:13.432 Status: dzVents: Debug: dzVents version: 2.4.6
2019-01-02 14:38:13.432 Status: dzVents: Debug: Event triggers:
and this is my script

Code: Select all

-- group trigger

return {
            on      = { devices = { "Alles_Uit_Living"}}, -- Change to the name of the switch that you want to use for controlling the group 
    
    execute = function(dz,item)
        local myGroup = "G_Alles_Living"              -- Change to the name of the group that you want to control 
        if item.state == "Off" then
            dz.groups(myGroup).switchOff()              
            item.switchOn().aftersec(3).silent()       -- Masterswitch will return to On state after 3 seconds without triggering any script
        else
            dz.groups(myGroup).switchOn()
        end
    end
}
i try dzvents all,device and group
Last edited by Gianni on Wednesday 02 January 2019 17:42, edited 1 time in total.
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: turn off all lights

Post by waaren »

Gianni wrote: Wednesday 02 January 2019 14:47 yep all switches ar removed from the list.

i have a copy of the log file maybe you see someting but for me it's not clear :-p.
The masterswitch called "alles uit living"
The group called "G_Alles_Living"

and this is my script

Code: Select all

-- group trigger

return {
            on      = { devices = { "Alles_Uit_Living"}}, -- Change to the name of the switch that you want to use for controlling the group 
    
    execute = function(dz,item)
        local myGroup = "G_Alles_Living"              -- Change to the name of the group that you want to control 
        if item.state == "Off" then
            dz.groups(myGroup).switchOff()              
 -- My mistake          item.switchOn().aftersec(3).silent()       -- Masterswitch will return to On state after 3 seconds without triggering any script
 -- should be 
             item.switchOn().afterSec(3).silent()       -- Masterswitch will return to On state after 3 seconds without triggering any script
 
        else
            dz.groups(myGroup).switchOn()
        end
    end
}
i try dzvents all,device and group
Please try after changing aftersec(3) to afterSec(3) ; I made a mistake in my example script and case matters for dzVents commands.

Also please edit your post and enclose your scripts and log in [ code] [ /code) tags (use the </> symbol on top of the edit window
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
BladeM3
Posts: 6
Joined: Thursday 20 February 2020 9:20
Target OS: -
Domoticz version:
Contact:

Re: turn off all lights

Post by BladeM3 »

waaren wrote: Saturday 29 December 2018 8:47
Can anyone point me to the right direction how i can use a wall switch to controll other switches?
There are more answers to this.
1. Group activation device; goto the edit page of your group to the part Activation devices. Press Add device button and you will have a couple of seconds to press the switch that you want to control your group.
2. Use dzVents script below.
Spoiler: show

Code: Select all

-- group trigger

return {
            on      = { devices = { "groupSwitch"}}, -- Change to the name of the switch that you want to use for controlling the group 
    
    execute = function(dz,item)
        local myGroup = "Happy NewYear"              -- Change to the name of the group that you want to control 
        if item.state == "Off" then
            dz.groups(myGroup).switchOff()
        else
            dz.groups(myGroup).switchOn()
        end
    end
}
3. Blockly
Do you have to use both Blockly and dzVents to make this function work? Or only one of them is enough?
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: turn off all lights

Post by waaren »

BladeM3 wrote: Saturday 22 February 2020 8:40 Do you have to use both Blockly and dzVents to make this function work? Or only one of them is enough?
It is either 1, -2 or 3. So one of them is enough
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
BladeM3
Posts: 6
Joined: Thursday 20 February 2020 9:20
Target OS: -
Domoticz version:
Contact:

Re: turn off all lights

Post by BladeM3 »

Great! Can you help me with a simple script that i need too?
If pir1 motion not detected more than 5 mins AND door1 opens then run scene1 ..
can this work with a blockly script? Most of the scripts i see (in lua) are creating time stamps and compare each other values.. still i get confused with tha device tags etc.
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: turn off all lights

Post by waaren »

BladeM3 wrote: Saturday 22 February 2020 10:13 Great! Can you help me with a simple script that i need too?
I stick to dzVents scripts as it can do anything that can be done in Lua or Blockly and more. If dzVents is ok , I am happy to help.
Best to first have a look at the wiki and look at the available examples.
Probably you will end with a device triggered script that will evaluate the state of the door and the lastUpdate value of the PIR.
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
BladeM3
Posts: 6
Joined: Thursday 20 February 2020 9:20
Target OS: -
Domoticz version:
Contact:

Re: turn off all lights

Post by BladeM3 »

I've tried your dzvent script but it only switched the lights to on. The off function never worked. I'm a little bit confused though and i'm trying to understand the logic behind it...

if item.state == "Off" then
dz.groups(myGroup).switchOff()
else
dz.groups(myGroup).switchOn()

What i get? if the state is off then off or else on?

Shouldn't it be if state is off then ON or else OFF ?
I've tried to swap the switchon switchoff values to experiment and got an error. it didn't work at all.

The lights only goes off if i press from the admin panel the off function on the switch (which physically the switch doesn't have)
it's a xiaomi mini switch with click / double click /long press

So i have to check on the beggining if the value from the switch is a click , right? AND then if value of the light is on go to off and vice versa
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: turn off all lights

Post by waaren »

BladeM3 wrote: Sunday 23 February 2020 14:00 I've tried your dzvent script but it only switched the lights to on. The off function never worked. I'm a little bit confused though and i'm trying to understand the logic behind it...
Please share the complete script as you have it now and the loglines it produces. If your switch does not give an Off or On state the sxcript will not react. Also make sure you use groups and not scenes. ( A scene cannot be switched Off.)
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
BladeM3
Posts: 6
Joined: Thursday 20 February 2020 9:20
Target OS: -
Domoticz version:
Contact:

Re: turn off all lights

Post by BladeM3 »

Just managed to make it work and i’m partying like a kid in disneyland . I found out the toggleGroup function and it was so simple! I was trying all day with if on then off etc and was almost having smoke coming out of my head, hahah. Thank you!

Only ome problem! Why sometimes my lights which are on the group do not come on both on or full on? (Hue lights)

Code: Select all

 -- group trigger
return {
    on  = { devices = { "MiSwitch2"}},
    
    execute = function(dz,item)
        if item.state == "Click" then
        dz.devices("Bedroom").toggleSwitch()            
        end
    end    
}
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest