If group is On-Off set Switch On-Off  [Solved]

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:

If group is On-Off set Switch On-Off

Post by gschmidt »

Hi,

I have created a Virtual Dummy On/Off Switch to set, with a blockly script, a Group (of 4 switches) On-Off for voice control in Google Home.
I used a Virtual Dummy Switch because the wife keeps saying ON-OFF instead of activate/deactivate (Which is for Groups and Scenes)....arrrghhh!
However I also have a KAKU remote which also controls the Switches.

Now the Following Happens:

Turning the Virtual Dummy Switch On/Off With Voice Control and Domoticz buttons is working nicely.
When I turn off/on the 4 Switches with the remote, only the Group and the corresponding Switches nicely are switched On/Off
But the Virtual Switch does not respond offcourse!

How can I set the Virtual Switch to On/Off when the lights are switched on/off by the remote with a Script (Blockly or dzVents)?

Greetzzz,

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

Re: If group is On-Off set Switch On-Off

Post by waaren »

gschmidt wrote: Sunday 13 January 2019 12:01 How can I set the Virtual Switch to On/Off when the lights are switched on/off by the remote with a Script (Blockly or dzVents)?
Gerben
If I understand you correctly, you could use the learn mode in the switch tab to create a new switch that will be triggered by your remote and use that switch also in your Blockly.
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: If group is On-Off set Switch On-Off

Post by gschmidt »

I have 4 lights programmed to the remote: 3 buttons to 3 kaku (433) devices, which transmit to the 3 kaku receivers and one button to a learned on/off switch which turns on/off my virtual dimmer switch Yeelight LED RGBWW with a blockly script.So I don't have any buttons left on the remote....

Instead I have put all 4 lights into a group which is triggered by a virtual switch with a blockly script.

I want to tell this virtual switch that if the 4 lights are turned off with the remote (instead of voice or domoticz because this is already working), this virtual switch has to switch to off, beacause all the 4 lights are off...

Is that possible with a dzVents or Blockly script?
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: If group is On-Off set Switch On-Off  [Solved]

Post by waaren »

gschmidt wrote: Sunday 13 January 2019 18:34 Is that possible with a dzVents or Blockly script?
Like this ?

Code: Select all

local lights = {"switch1","switch2","switch3","switch4"}

return {
   on = { devices = lights},     -- Triggers on any of the above switches
   
   execute = function(dz)
      local atLeastOneLightOn 
      local groupSwitch = dz.devices("groupSwitch")
      
      for index,lightName in ipairs(lights) do
        if dz.devices(lightName).state == "On" then atLeastOneLightOn = true end   
      end
      if atLeastOneLightOn then 
            groupSwitch.switchOn().checkFirst().silent()      
      else
            groupSwitch.switchOff().checkFirst().silent()     -- If all switches are Off 
      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: If group is On-Off set Switch On-Off

Post by gschmidt »

Correctomundo...Working

Thanx man!
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest