Page 1 of 1

Problem updating a device.

Posted: Wednesday 13 April 2016 11:36
by RATA1
Hello,
This is doing my nut in.

I am reading from a string a value and I want to update that into my temperature dummy sensor.

I have a string "temperature" which reads in a value from a position in the string at j to i-1

local temperature=string.sub(XML_string,j,i-1)

I then update my variable at idx 108

commandArray = {}

This works:

commandArray['UpdateDevice'] = "108|0|25.20"


but this doesn't which is what I want:

commandArray['UpdateDevice'] = "108|0|..temperature

When I test it with

print ("temp= "..temperature.." length= "..z)

I get the right number (i.e. 25.20) with the correct length printed in the log.

What am I doing wrong or how can I debug further?

Thanks!

Re: Problem updating a device.

Posted: Wednesday 13 April 2016 11:52
by Westcott
Do you mean -
commandArray['UpdateDevice'] = "108|0|"..temperature

Re: Problem updating a device.

Posted: Wednesday 13 April 2016 12:13
by RATA1
Fixed it - dodgy eyes!!

had

commandArray['UpdateDevice'] = "108|0|..temperature

needed

commandArray['UpdateDevice'] = "108|0|"..temperature

Doh!

Re: Problem updating a device.

Posted: Wednesday 13 April 2016 12:14
by RATA1
Westcott wrote:Do you mean -
commandArray['UpdateDevice'] = "108|0|"..temperature

crossed post - thanks! too much staring!