Help script problem!

Moderator: leecollings

Post Reply
liveviva
Posts: 2
Joined: Tuesday 09 May 2017 0:00
Target OS: Windows
Domoticz version:
Contact:

Help script problem!

Post by liveviva »

I am a novice, and my English is very poor, please do not laugh at!
Well, I created a text device in domoticz, is used to obtain a number coming from ESPEasy, I hope to achieve with the script in domoticz, judging whether the number change, according to the number of executive action.
But when I use devicechanged, but found that the number has not changed the situation, he still repeated action...
I don't know where the problem is.
Here is the code:

Code: Select all

commandArray = {}
-- loop through all the devices
for deviceName,deviceValue in pairs(devicechanged) do
if (devicechanged['Voice_Data']) then
    if (deviceValue == '1') then
        print('1')
    elseif (deviceValue == '2') then
        print('2')
    end
end
end
return commandArray
mjdb
Posts: 71
Joined: Thursday 12 January 2017 13:38
Target OS: Raspberry Pi / ODroid
Domoticz version: all beta
Location: NL - Pijnacker
Contact:

Re: Help script problem!

Post by mjdb »

A suggestion, not tested. Try to read the current value as text:

if (devicechanged['Voice_Data']) then

CurrentText = tostring(otherdevices_svalues['Voice_Data'])

if (CurrentText == '1') then

etc.
- - - - - - - - - - -
2 x Domoticz on Raspberry Pi; 2 x RFXtrx433; Aeotec Z-Stick
KlikAanKlikUit ICS-2000 as Relay
Aeotec MultiSensors 6; Danfoss Z Thermostats 014G0013; Kaku Switches, Z-wave Switches
liveviva
Posts: 2
Joined: Tuesday 09 May 2017 0:00
Target OS: Windows
Domoticz version:
Contact:

Re: Help script problem!

Post by liveviva »

mjdb wrote:A suggestion, not tested. Try to read the current value as text:

if (devicechanged['Voice_Data']) then

CurrentText = tostring(otherdevices_svalues['Voice_Data'])

if (CurrentText == '1') then

etc.
The same problem.
When value = 1 repeat execution
When value = 2 to do Nothing...
Looks like devicechanged is not working!
User avatar
jvdz
Posts: 2334
Joined: Tuesday 30 December 2014 19:25
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.107
Location: Netherlands
Contact:

Re: Help script problem!

Post by jvdz »

Check the exact content of the variable you are testing with to see why things don't work as expected:

Code: Select all

if (devicechanged['Voice_Data']) then
     CurrentText = tostring(otherdevices_svalues['Voice_Data'])
     print("|"..CurrentText .."|")
end
Jos
New Garbage collection scripts: https://github.com/jvanderzande/GarbageCalendar
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest