[SOLVED] updating virtual powermeter in LUA

Moderator: leecollings

Post Reply
sebitop
Posts: 69
Joined: Sunday 08 June 2014 20:31
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: Toulouse France
Contact:

[SOLVED] updating virtual powermeter in LUA

Post by sebitop »

Hi everybody

since a couple of hours I'm struggling on a very simple thing wich consist in updating a virtual powermeter device with a value in LUA so if someone would have a second pairs of eyes and spot what I'm missing it would be fantastic

here is the code :

Code: Select all

	local linky = otherdevices[getdevicename(linky)]
        print(linky)
	local linky = string.match(linky, "^(%d+)")
	print(linky)
	commandArray['UpdateDevice'] = 1639 .. "|0|" .. linky

in a nutshell

1) I retrieve a value from another counter called LINKY so it gets a value like : 500;682591.8871 (first print linky)

2) as I just want the first value I do a string.match to get only the first part so the second print shows 510

3) I try to update the power meter just to get 500 KWH in it (the cumulative will be done using computed mode in the power meter) so I tried the command array update device but nothing comes up into the device

1639 is the correct number of the device and if I modify the the nvalue number in the formula it apparently changes in the devices values
but the concern is that I don't get a single proper KWH value in this device

thanks for your precious help !

cheers
seb
Last edited by sebitop on Wednesday 07 August 2024 15:33, edited 1 time in total.
domoticz on Raspberry Pi + RFXcom LAN moded + wifi
Blyss / DI.O / homemade / ESP / wemos
sebitop
Posts: 69
Joined: Sunday 08 June 2014 20:31
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: Toulouse France
Contact:

Re: updating virtual powermeter in LUA

Post by sebitop »

Finaly found my problem

the code is correct but when you create the virtual device using domoticz, if you don't select ACCEPT DEVICES FOR 5 MINUTES you will see the device but it won't work correctly

I deleted the device, activated the acceptance, recreated the virtual device and it works !

damn got it !

hope it will help !
domoticz on Raspberry Pi + RFXcom LAN moded + wifi
Blyss / DI.O / homemade / ESP / wemos
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest