Trigger script when pressing a wall switch

Topics (not sure which fora)
when not sure where to post, post here and mods will move it to right forum.

Moderators: leecollings, remb0

Post Reply
dannybloe
Posts: 1355
Joined: Friday 29 August 2014 11:26
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: Ermelo
Contact:

Trigger script when pressing a wall switch

Post by dannybloe »

Hi folks,

Right now I have a zwave wall switch that triggers a scene. In the scene I switch off a dozen lights in the house. Because it takes an enormous amount of time before all the lights go out (sometimes almost a minute!!) I was thinking to try it with a lua script.

Basically, that's is where my experiment ended. It seems to be possible to trigger a script when the scene is activated using script:// but there seem to be no documentation at all on how to use this (do not try to search for 'script://'). I suspect that Domoticz tries to run a OS script located at the path behind script:// but it only gives me errors when I try to link it to a lua script. So that doesn't help me much.

So, the only thing I can come up with then is to create a dummy switch, turn that on in my scene, have a lua script mydummyswitch.lua and use that. Or is there a easier way to do this?
Creator dzVents - RPi3, loads of zwave devices, esp8266, evohome.
alfred_j_kwak
Posts: 110
Joined: Friday 20 September 2013 18:49
Target OS: Raspberry Pi / ODroid
Domoticz version: 2.3530
Location: Finland
Contact:

Re: Trigger script when pressing a wall switch

Post by alfred_j_kwak »

You could start with wiki: https://www.domoticz.com/wiki/Events
dannybloe
Posts: 1355
Joined: Friday 29 August 2014 11:26
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: Ermelo
Contact:

Re: Trigger script when pressing a wall switch

Post by dannybloe »

Ehm... I know.. but it doesn't tell me how to trigger a script when a scene is activated or I am blind. I can't find any documentation on how the 'script://' fields work.
Creator dzVents - RPi3, loads of zwave devices, esp8266, evohome.
alfred_j_kwak
Posts: 110
Joined: Friday 20 September 2013 18:49
Target OS: Raspberry Pi / ODroid
Domoticz version: 2.3530
Location: Finland
Contact:

Re: Trigger script when pressing a wall switch

Post by alfred_j_kwak »

You don't need scene with Lua. You can create dummy switch and use that to activate script. If you use switch then you don't need script://.... at all.
dannybloe
Posts: 1355
Joined: Friday 29 August 2014 11:26
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: Ermelo
Contact:

Re: Trigger script when pressing a wall switch

Post by dannybloe »

I believe I need a scene or a group otherwise I cannot link the physical z-wave wall-switch to something in Domoticz:

wall switch press > trigger a scene > set dummy switch to on > trigger script_device_dummyswitch.lua

Or is there a way to trigger a dummy switch when I press my zwave switch? I haven't found a way to do that yet.
Creator dzVents - RPi3, loads of zwave devices, esp8266, evohome.
alfred_j_kwak
Posts: 110
Joined: Friday 20 September 2013 18:49
Target OS: Raspberry Pi / ODroid
Domoticz version: 2.3530
Location: Finland
Contact:

Re: Trigger script when pressing a wall switch

Post by alfred_j_kwak »

For example - here is a page where you could find syntax for running script with switch. viewtopic.php?f=23&t=9176
I suppose that after you have working solution, then you could write guide into wiki.
dannybloe
Posts: 1355
Joined: Friday 29 August 2014 11:26
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: Ermelo
Contact:

Re: Trigger script when pressing a wall switch

Post by dannybloe »

Problem with that approach is that you can't run lua scripts and you don't get all the states from Domoticz. You have to do loads of curls to get the current states and curl new states etc.
So why not put a script in scripts/lua with the name: script_myscenename.lua and have that triggered when the scene is activated. Or script_groupname.lua.

Or is that already possible?
Creator dzVents - RPi3, loads of zwave devices, esp8266, evohome.
alfred_j_kwak
Posts: 110
Joined: Friday 20 September 2013 18:49
Target OS: Raspberry Pi / ODroid
Domoticz version: 2.3530
Location: Finland
Contact:

Re: Trigger script when pressing a wall switch

Post by alfred_j_kwak »

When you read that wiki-page there is said: "To switch a scene or group, put prefix 'Scene:' or 'Group:' in front of the scene name. Note that it is not possible to check the state of a scene or group, since that is not its intended use."
alfred_j_kwak
Posts: 110
Joined: Friday 20 September 2013 18:49
Target OS: Raspberry Pi / ODroid
Domoticz version: 2.3530
Location: Finland
Contact:

Re: Trigger script when pressing a wall switch

Post by alfred_j_kwak »

As you noticed english is not my primary language so it might be that I'm not answering to your question - so I rest my case. Sorry.
dannybloe
Posts: 1355
Joined: Friday 29 August 2014 11:26
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: Ermelo
Contact:

Re: Trigger script when pressing a wall switch

Post by dannybloe »

Alfred.. I don't want to switch a group or a scene! Please read my post. It is the other way round: I want to trigger a script when a scene is triggered by a button and preferable a LUA script.
Creator dzVents - RPi3, loads of zwave devices, esp8266, evohome.
dannybloe
Posts: 1355
Joined: Friday 29 August 2014 11:26
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: Ermelo
Contact:

Re: Trigger script when pressing a wall switch

Post by dannybloe »

alfred.. thanks anyway :)

Anyway.. I managed to trigger a lua script via dummy switch route and unfortunately it is still slow. Turning off a group of zwave devices just takes an irregular long time. Maybe it's just zwave or maybe OpenZwave. I don't know. Funny is that turning on a group of switches seems to be a lot faster.

Maybe I should try to live with it and trust that eventually all the lights will go out. It's just that I don't want to come downstairs the next morning to learn that some commands never reached a light and that they stayed on all night.
Creator dzVents - RPi3, loads of zwave devices, esp8266, evohome.
User avatar
bbqkees
Posts: 407
Joined: Sunday 17 August 2014 21:01
Target OS: Linux
Domoticz version: 4.1x
Location: The Netherlands
Contact:

Re: Trigger script when pressing a wall switch

Post by bbqkees »

My Z-Wave network is about the same size as yours and I too have delays. All the lights go out after each other. Can take about 30 seconds for a single floor.
Until now they are always off when I get up in the morning so I don't really care.
Delay is worse for devices that are not directly connected to the controller, which is logical as the commands are relayed via the mesh network.

When the lighting group for the ground floor turns off in the evening, my Hue lights are the first to turn off and then you see all the Z-Wave lights turn off randomly after that.
A bit like you see in movies when they cut the power of a city, you see all the blocks go out after each other.
Bosch / Nefit / Buderus / Junkers / Worcester / Sieger EMS bus Wi-Fi MQTT Gateway and interface boards: https://bbqkees-electronics.nl/
dannybloe
Posts: 1355
Joined: Friday 29 August 2014 11:26
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: Ermelo
Contact:

Re: Trigger script when pressing a wall switch

Post by dannybloe »

You know what would be nice? If somehow the z-wave mesh network could be superimposed on the floorplans. Or something like that. Perhaps that could give you some insight. Ah well.. just fantasizing... :D
Creator dzVents - RPi3, loads of zwave devices, esp8266, evohome.
User avatar
bbqkees
Posts: 407
Joined: Sunday 17 August 2014 21:01
Target OS: Linux
Domoticz version: 4.1x
Location: The Netherlands
Contact:

Re: Trigger script when pressing a wall switch

Post by bbqkees »

You can see the mesh in the Z-Wave control panel.
Bosch / Nefit / Buderus / Junkers / Worcester / Sieger EMS bus Wi-Fi MQTT Gateway and interface boards: https://bbqkees-electronics.nl/
dannybloe
Posts: 1355
Joined: Friday 29 August 2014 11:26
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: Ermelo
Contact:

Re: Trigger script when pressing a wall switch

Post by dannybloe »

bbqkees wrote:You can see the mesh in the Z-Wave control panel.
Yeshh indeed.. but it has no positional information in the relativistic quantum space-time continuum. And since the positions are more or less available in the floorplans you might visualize the routes through the mesh from the controller to subnodes on the plan. But the algorithm isn't that trivial I guess if you want to make it useful.

Nevermind ;-)
Creator dzVents - RPi3, loads of zwave devices, esp8266, evohome.
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest