Page 1 of 1

Help script problem!

Posted: Wednesday 10 May 2017 9:56
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

Re: Help script problem!

Posted: Wednesday 10 May 2017 10:15
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.

Re: Help script problem!

Posted: Wednesday 10 May 2017 10:49
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!

Re: Help script problem!

Posted: Wednesday 10 May 2017 17:50
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