dzvents is using variables from other script
Moderator: leecollings
-
- Posts: 13
- Joined: Friday 16 October 2015 9:45
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
dzvents is using variables from other script
Today I received a (Telegram) message "Sunscreen is going up" and this was sent by a script that nothing had to do with my sunscreen.
I found out that the script which turns on the lights should have sent the message "Lights going on" but used the message from the sunscreen-script .
the problem was the fact that I use the same line in both scripts:
os.execute('curl --data chat_id='..chatid..' --data-urlencode "text='..message..'" "https://api.telegram.org/bot'..token..'/sendMessage" ')
The variable: message is defined at the beginning of each script:
message = 'Sunscreen is going up' --> for the sunscreen-script
message = 'Lights going on' --> for the lamp-script
Does anyone know how to avoid this? besides that I have to rename all messages in the scripts with different names?
I found out that the script which turns on the lights should have sent the message "Lights going on" but used the message from the sunscreen-script .
the problem was the fact that I use the same line in both scripts:
os.execute('curl --data chat_id='..chatid..' --data-urlencode "text='..message..'" "https://api.telegram.org/bot'..token..'/sendMessage" ')
The variable: message is defined at the beginning of each script:
message = 'Sunscreen is going up' --> for the sunscreen-script
message = 'Lights going on' --> for the lamp-script
Does anyone know how to avoid this? besides that I have to rename all messages in the scripts with different names?
- waaren
- Posts: 6028
- Joined: Tuesday 03 January 2017 14:18
- Target OS: Linux
- Domoticz version: Beta
- Location: Netherlands
- Contact:
Re: dzvents is using variables from other script
Best practice in programming is to limit the scope of variables as much as possible. In this case you could start with changing the declaration of these vars fromcorthebor wrote: ↑Thursday 18 April 2019 21:05 Today I received a (Telegram) message "Sunscreen is going up" and this was sent by a script that nothing had to do with my sunscreen.
I found out that the script which turns on the lights should have sent the message "Lights going on" but used the message from the sunscreen-script .
the problem was the fact that I use the same line in both scripts:
os.execute('curl --data chat_id='..chatid..' --data-urlencode "text='..message..'" "https://api.telegram.org/bot'..token..'/sendMessage" ')
The variable: message is defined at the beginning of each script:
message = 'Sunscreen is going up' --> for the sunscreen-script
message = 'Lights going on' --> for the lamp-script
Does anyone know how to avoid this? besides that I have to rename all messages in the scripts with different names?
Code: Select all
message = 'Sunscreen is going up' --> for the sunscreen-script
message = 'Lights going on' --> for the lamp-script
Code: Select all
local message = 'Sunscreen is going up' --> for the sunscreen-script
local message = 'Lights going on' --> for the lamp-script
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: 13
- Joined: Friday 16 October 2015 9:45
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: dzvents is using variables from other script
@waaren
Thanks for the reply. I'll keep that in mind.
About domoticz.notify can natively send a notification to telegram: I looked in to that a while ago, but did not manage to get that working.
I will give it a try one of these days.
gr. Cor
Thanks for the reply. I'll keep that in mind.
About domoticz.notify can natively send a notification to telegram: I looked in to that a while ago, but did not manage to get that working.
I will give it a try one of these days.
gr. Cor
- waaren
- Posts: 6028
- Joined: Tuesday 03 January 2017 14:18
- Target OS: Linux
- Domoticz version: Beta
- Location: Netherlands
- Contact:
Re: dzvents is using variables from other script
in Domoticz [Setup] [Settings] [Notifications] in your dzVents script:
Code: Select all
domoticz.notify("Subject", "message",domoticz.PRIORITY_NORMAL,nil,nil,domoticz.NSS_TELEGRAM)
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: 13
- Joined: Friday 16 October 2015 9:45
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: dzvents is using variables from other script
@waaren
Thanks
Thanks
-
- Posts: 13
- Joined: Friday 16 October 2015 9:45
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: dzvents is using variables from other script
I managed to have the domoticz.notify command working but I changed back to the curl command because I received notifications on all configured services. (Email, pushover, telegram etc..).On a side note: domoticz.notify can natively send a notification to telegram since dzVents version 2.4.8
I better wait until the next (stable) update from domoticz to version 4.10200 (dzVents 2.4.8)
- waaren
- Posts: 6028
- Joined: Tuesday 03 January 2017 14:18
- Target OS: Linux
- Domoticz version: Beta
- Location: Netherlands
- Contact:
Re: dzvents is using variables from other script
That should not happen if you are on dzVents 2.4.8 and use the linecorthebor wrote: ↑Saturday 20 April 2019 11:15I managed to have the domoticz.notify command working but I changed back to the curl command because I received notifications on all configured services. (Email, pushover, telegram etc..).On a side note: domoticz.notify can natively send a notification to telegram since dzVents version 2.4.8
I better wait until the next (stable) update from domoticz to version 4.10200 (dzVents 2.4.8)
Code: Select all
domoticz.notify("Subject", "message",domoticz.PRIORITY_NORMAL,nil,nil,domoticz.NSS_TELEGRAM)
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: 13
- Joined: Friday 16 October 2015 9:45
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: dzvents is using variables from other script
This is my stable version of domoticz and dzvents and there is no update available for now...
And I would rather not change to the beta version
Version: 4.9700
Build Hash: a3a45906
Compile Date: 2018-06-23 16:24:51
dzVents Version: 2.4.6
And I would rather not change to the beta version
Version: 4.9700
Build Hash: a3a45906
Compile Date: 2018-06-23 16:24:51
dzVents Version: 2.4.6
- waaren
- Posts: 6028
- Joined: Tuesday 03 January 2017 14:18
- Target OS: Linux
- Domoticz version: Beta
- Location: Netherlands
- Contact:
Re: dzvents is using variables from other script
Understand. Can you try this in your current version ?
Code: Select all
domoticz.notify("Subject", "message",domoticz.PRIORITY_NORMAL,nil,nil,"telegram")
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: 13
- Joined: Friday 16 October 2015 9:45
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: dzvents is using variables from other script
Ok, missed that.
Is working like it should be.
Thanks again
Is working like it should be.
Thanks again
Who is online
Users browsing this forum: andrehj and 0 guests