I don't know why it doesn't work
Moderator: leecollings
-
- Posts: 9
- Joined: Sunday 28 September 2014 15:31
- Target OS: Raspberry Pi / ODroid
- Domoticz version: V4.9700
- Contact:
I don't know why it doesn't work
Who could explain to me why it does not seem to work. Here is my script:
return {
on = {
timer = { 'every minute' }
},
execute = function(domoticz, timer)
if (device'Fin_chauffage'.state == 'On')
then
device'prise ordi'.switchOff()
device'prise TV Chambre'.switchOff()
domoticz.notify('Hey pas mal')
else
device'prise TV Chambre'.switchOn()
device'prise ordi'.switchOn()
end
end
}
Thanks for your help
Pascal
return {
on = {
timer = { 'every minute' }
},
execute = function(domoticz, timer)
if (device'Fin_chauffage'.state == 'On')
then
device'prise ordi'.switchOff()
device'prise TV Chambre'.switchOff()
domoticz.notify('Hey pas mal')
else
device'prise TV Chambre'.switchOn()
device'prise ordi'.switchOn()
end
end
}
Thanks for your help
Pascal
- waaren
- Posts: 6028
- Joined: Tuesday 03 January 2017 14:18
- Target OS: Linux
- Domoticz version: Beta
- Location: Netherlands
- Contact:
Re: I don't know why it doesn't work
You missed a couple of () in your code. Do you see anything in the domoticz logfile ?
Please use code tags around your code to improve readability on the forum.
Please use code tags around your code to improve readability on the forum.
Code: Select all
return {
on = { timer = { 'every minute'} },
logging = { level = domoticz.LOG_ERROR,
marker = "chauffage actions" },
execute = function(domoticz, timer)
if (device('Fin_chauffage').state == 'On') then
device('prise ordi').switchOff()
device('prise TV Chambre').switchOff()
domoticz.notify('Hey pas mal')
else
device('prise TV Chambre').switchOn()
device('prise ordi').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
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
-
- Posts: 9
- Joined: Sunday 28 September 2014 15:31
- Target OS: Raspberry Pi / ODroid
- Domoticz version: V4.9700
- Contact:
Re: I don't know why it doesn't work
No I don't see anything in logfile. even with yours. Amazing
- waaren
- Posts: 6028
- Joined: Tuesday 03 January 2017 14:18
- Target OS: Linux
- Domoticz version: Beta
- Location: Netherlands
- Contact:
Re: I don't know why it doesn't work
Did you enable logging in your /etc/init.d/domoticz.sh ?
by removing the # on the line
Code: Select all
#DAEMON_ARGS="$DAEMON_ARGS -log /tmp/domoticz.txt"
Code: Select all
DAEMON_ARGS="$DAEMON_ARGS -log /tmp/domoticz.txt"
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
-
- Posts: 9
- Joined: Sunday 28 September 2014 15:31
- Target OS: Raspberry Pi / ODroid
- Domoticz version: V4.9700
- Contact:
Re: I don't know why it doesn't work
I just did, but nothing happens. Probably something I did not do properly, but I don't know what.
-
- Posts: 9
- Joined: Sunday 28 September 2014 15:31
- Target OS: Raspberry Pi / ODroid
- Domoticz version: V4.9700
- Contact:
Re: I don't know why it doesn't work
Here is the error I have:
2018-07-18 21:10:56.190 Status: dzVents: Error (2.4.6): chauffage actions: ...e/pi/domoticz/scripts/dzVents/generated_scripts/kiki.lua:8: attempt to call global 'device' (a nil value)
Thanks for your help
2018-07-18 21:10:56.190 Status: dzVents: Error (2.4.6): chauffage actions: ...e/pi/domoticz/scripts/dzVents/generated_scripts/kiki.lua:8: attempt to call global 'device' (a nil value)
Thanks for your help
- waaren
- Posts: 6028
- Joined: Tuesday 03 January 2017 14:18
- Target OS: Linux
- Domoticz version: Beta
- Location: Netherlands
- Contact:
Re: I don't know why it doesn't work
We are getting somewhere now. Please try this modified script.
Code: Select all
return {
on = { timer = { 'every minute'} },
logging = { level = domoticz.LOG_ERROR,
marker = "chauffage actions" },
execute = function(domoticz, trigger)
if (domoticz.devices('Fin_chauffage').state == 'On') then
domoticz.devices('prise ordi').switchOff()
domoticz.devices('prise TV Chambre').switchOff()
domoticz.notify('Hey pas mal')
else
domoticz.devices('prise TV Chambre').switchOn()
domoticz.devices('prise ordi').switchOn()
end
end
}
Last edited by waaren on Thursday 19 July 2018 7:14, edited 2 times in total.
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
-
- Posts: 9
- Joined: Sunday 28 September 2014 15:31
- Target OS: Raspberry Pi / ODroid
- Domoticz version: V4.9700
- Contact:
Re: I don't know why it doesn't work
here it is:
2018-07-18 21:39:00.664 Status: dzVents: Error (2.4.6): chauffage actions: ...e/pi/domoticz/scripts/dzVents/generated_scripts/kiki.lua:8: attempt to call local 'device' (a table value)
2018-07-18 21:39:00.664 Status: dzVents: Error (2.4.6): chauffage actions: ...e/pi/domoticz/scripts/dzVents/generated_scripts/kiki.lua:8: attempt to call local 'device' (a table value)
- waaren
- Posts: 6028
- Joined: Tuesday 03 January 2017 14:18
- Target OS: Linux
- Domoticz version: Beta
- Location: Netherlands
- Contact:
Re: I don't know why it doesn't work
My mistake. I edited the previous post
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
-
- Posts: 9
- Joined: Sunday 28 September 2014 15:31
- Target OS: Raspberry Pi / ODroid
- Domoticz version: V4.9700
- Contact:
Re: I don't know why it doesn't work
any clue?
- waaren
- Posts: 6028
- Joined: Tuesday 03 January 2017 14:18
- Target OS: Linux
- Domoticz version: Beta
- Location: Netherlands
- Contact:
Re: I don't know why it doesn't work
Did you try the edited version ?
the logic in your script causes dzVents to send you a notifications every minute for as long as "Fin_chauffage" state is On. It will also switch the other devices with a delay varying from 1 - 60 seconds. If you want to change the script in such a way that it triggers direct and only when the state of "Fin_chauffage" changes; modify it to:
Code: Select all
return {
on = { devices = { 'Fin_chauffage'} },
logging = { level = domoticz.LOG_ERROR,
marker = 'chauffage actions' },
execute = function(domoticz, trigger)
if trigger.state == 'On' then
domoticz.devices('prise ordi').switchOff()
domoticz.devices('prise TV Chambre').switchOff()
domoticz.notify('Hey pas mal')
else
domoticz.devices('prise TV Chambre').switchOn()
domoticz.devices('prise ordi').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
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
-
- Posts: 9
- Joined: Sunday 28 September 2014 15:31
- Target OS: Raspberry Pi / ODroid
- Domoticz version: V4.9700
- Contact:
Re: I don't know why it doesn't work
Thanks a lot Waaren. It is working exactly how I wanted. What is the difference between:
execute = function(domoticz, trigger) and execute = function(domoticz, Device)?
Thanks again.
Pascal
execute = function(domoticz, trigger) and execute = function(domoticz, Device)?
Thanks again.
Pascal
-
- Posts: 742
- Joined: Saturday 30 May 2015 22:40
- Target OS: Raspberry Pi / ODroid
- Domoticz version: beta
- Contact:
Re: I don't know why it doesn't work
Please check the wiki:pascal wrote: Thanks a lot Waaren. It is working exactly how I wanted. What is the difference between:
execute = function(domoticz, trigger) and execute = function(domoticz, Device)?
Thanks again.
Pascal
https://www.domoticz.com/wiki/DzVents:_ ... gerInfo.29
There they use the word 'item'. It is your choice what word to use. In your script you didn't make use of the'trigger word', so you can skip it as well:
execute = function(domoticz)
- waaren
- Posts: 6028
- Joined: Tuesday 03 January 2017 14:18
- Target OS: Linux
- Domoticz version: Beta
- Location: Netherlands
- Contact:
Re: I don't know why it doesn't work
@Jake, in the example based on the device state change trigger is used so better to leave it like it is.jake wrote: ↑Thursday 19 July 2018 14:18Please check the wiki:pascal wrote:What is the difference between:
execute = function(domoticz, trigger) and execute = function(domoticz, Device)?
https://www.domoticz.com/wiki/DzVents:_ ... gerInfo.29
There they use the word 'item'. It is your choice what word to use. In your script you didn't make use of the'trigger word', so you can skip it as well:
execute = function(domoticz)
@pascal, the the second parm in the function(domoticz,Device) (or function(domoticz,trigger) ) is the object that is triggering the script.
It can be a device, variable, scene, group, timer, security or httpResponse depending on what you defined in the on = (....) section.
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
-
- Posts: 742
- Joined: Saturday 30 May 2015 22:40
- Target OS: Raspberry Pi / ODroid
- Domoticz version: beta
- Contact:
Re: I don't know why it doesn't work
@waaren, I based my comment on the initial scripts. Now I see in your suggested improved script (which I think is much better in this situation) that you used the 'trigger' in your script as intended.
Who is online
Users browsing this forum: No registered users and 1 guest