In the current event scripts, I can switch on/off devices and that works well.
The new devices have a different control, either selector switch or dimmable
The current code for on/off is simple:
if (str(domoticz_.Devices["Light coffeemachine"].n_value_string)=="On"):
domoticz_.Command("Light coffeemachine","Off")
However I couldn't find an selector example that f.e. sets to level 20 after a trigger.
Maybe someone has coded this or can refer to an example I haven't found yet.
Other item is, in same scripts I want to start counting down after trigger which is also reloaded if the trigger reoccurs before 0 is achieved
At 0, a device should be switched off.
Is these some sample code for this too?
selector switch in events, count down
Moderators: leecollings, remb0
- waltervl
- Posts: 5149
- Joined: Monday 28 January 2019 18:48
- Target OS: Linux
- Domoticz version: 2024.7
- Location: NL
- Contact:
Re: selector switch in events, count down
I think you refer to Python Event scripts.
I do not use it myself and I tried to get as much as possible information on the wiki https://www.domoticz.com/wiki/Python_Events but your question I cannot answer.
If it stays quiet in this topic please consider to switch to dzVents, almost as simple and muche better documented and used by others: https://www.domoticz.com/wiki/DzVents:_ ... _scripting
I do not use it myself and I tried to get as much as possible information on the wiki https://www.domoticz.com/wiki/Python_Events but your question I cannot answer.
If it stays quiet in this topic please consider to switch to dzVents, almost as simple and muche better documented and used by others: https://www.domoticz.com/wiki/DzVents:_ ... _scripting
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
-
- Posts: 303
- Joined: Saturday 27 February 2016 0:30
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 2020.2
- Contact:
Re: selector switch in events, count down
To read selector level:
To define selector level to 30:
To switch a device off in 12 seconds (the cancelQueuedCommands ensure previous delayed commands will be destroyed):
Code: Select all
domoticz.devices('my selector').level)
Code: Select all
domoticz.devices('my selector').setLevel(30)
Code: Select all
domoticz.devices('my device').cancelQueuedCommands()
domoticz.devices('my device').switchOff().afterSec(12)
-
- Posts: 8
- Joined: Sunday 23 August 2015 19:16
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: selector switch in events, count down
switching to dzVents is indeed an option, I prefer to fix it in the current approach but as plan B it is an option
I now changed the code based upon this topic:
(script is triggered by switch to toggle between High and Mid, Low goes by timer at night)
domoticz_.Log(domoticz_.Devices["Nibe - Ventilation speed"].n_value_string)
if (domoticz_.Devices["Nibe - Ventilation speed"].n_value_string=="MID"):
domoticz_.Devices["Nibe - Ventilation speed"].setLevel(30)
domoticz_.Log("Python event script2: Bathroom FAN HIGH")
I get:
2023-02-19 11:04:46.782 Error: Traceback (most recent call last):
2023-02-19 11:04:46.783 Error: File "Buttons and sensors", line 124, in <module>
2023-02-19 11:04:46.783 Error: AttributeError: 'DomoticzEvents.PDevice' object has no attribute 'setLevel'
Seems to me, the syntax is not 100% OK yet
I now changed the code based upon this topic:
(script is triggered by switch to toggle between High and Mid, Low goes by timer at night)
domoticz_.Log(domoticz_.Devices["Nibe - Ventilation speed"].n_value_string)
if (domoticz_.Devices["Nibe - Ventilation speed"].n_value_string=="MID"):
domoticz_.Devices["Nibe - Ventilation speed"].setLevel(30)
domoticz_.Log("Python event script2: Bathroom FAN HIGH")
I get:
2023-02-19 11:04:46.782 Error: Traceback (most recent call last):
2023-02-19 11:04:46.783 Error: File "Buttons and sensors", line 124, in <module>
2023-02-19 11:04:46.783 Error: AttributeError: 'DomoticzEvents.PDevice' object has no attribute 'setLevel'
Seems to me, the syntax is not 100% OK yet
- waltervl
- Posts: 5149
- Joined: Monday 28 January 2019 18:48
- Target OS: Linux
- Domoticz version: 2024.7
- Location: NL
- Contact:
Re: selector switch in events, count down
I think flyingDomoticz is referring to Dzvents syntax. So it is possible it does not work with Python events as you have noticed.
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
Who is online
Users browsing this forum: No registered users and 1 guest