Problem with reading data from device

Moderator: leecollings

Post Reply
Xfiles
Posts: 15
Joined: Saturday 31 March 2018 23:08
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Problem with reading data from device

Post by Xfiles »

Hi,

I have problem with reading data from device.

I have device:
with state:

5.4;0.0;0.0

and value

0/5.4;0.0;0.0

I try to get this values (I need only first value: 5,4) by script:

Code: Select all

commandArray = {}
if (m % 1 == 0) then
    print "Odczyt bilansu energii:"
    current1, current2, current3=otherdevices_svalues['Pobor_pradu']:match("([^;]+);([^;]+);([^;]+)")

    print(current1)
    print(current2)
    print(current3)
    end
return commandArray
and I received in log only text "Odczyt bilansu energii:"
What is done incorrectly on my side?
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: Problem with reading data from device

Post by waaren »

Xfiles wrote: Friday 22 November 2019 14:24 and I received in log only text "Odczyt bilansu energii:"
What is done incorrectly on my side?
this :match should return something so my approach would be to ensure expected raw string is in otherdevices_svalues['Pobor_pradu']

Code: Select all

commandArray = {}
if (m % 1 == 0) then
    print "Odczyt bilansu energii:"
    sValue = otherdevices_svalues['Pobor_pradu']
    print ('Raw sValue: ' .. sValue)	
    current1, current2, current3= sValue:match("([^;]+);([^;]+);([^;]+)")

    print(current1)
    print(current2)
    print(current3)
    end
return commandArray
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
Xfiles
Posts: 15
Joined: Saturday 31 March 2018 23:08
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Problem with reading data from device

Post by Xfiles »

Thanks a lot! Now it works.
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest