P1 counter value math [Solved]

Moderator: leecollings

Post Reply
StefanWouters
Posts: 14
Joined: Tuesday 18 June 2019 17:07
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

P1 counter value math [Solved]

Post by StefanWouters »

I am new with LUA, normaly i program PLC (Siemens S7). is their an easy way to store several values temperarely? I have made a script that analyses the data of the energymeter. But as soon the command "end" passes the value in de global/local variable is nil.
I want to make some calculations with several values, after i get all the values (delivery en Usage)
I have tried Blockly, but blockly has no math operators.....
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: P1 counter value math

Post by waaren »

StefanWouters wrote: Tuesday 18 June 2019 17:19 I am new with LUA. Is their an easy way to store several values temperarely? I have made a script that analyses the data of the energymeter. But as soon the command "end" passes the value in de global/local variable is nil.
In Lua you will have to store your temp results in domoticz uservariables to preserve them until a next run. Using dzVents you can you use persistent data.

dzVents is an easy to use API to domoticz. Written in- and on top of Lua.
If you are not yet familiar with dzVents then please look at the 10 lines using dzVents with Domoticz for an intro to dzVents.
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
StefanWouters
Posts: 14
Joined: Tuesday 18 June 2019 17:07
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: P1 counter value math

Post by StefanWouters »

i have found several methods but something is going wrong..;-) trying to get 1 value stored...
Attachments
Nieuw tekstdocument.txt
(2.54 KiB) Downloaded 50 times
Knipsel.PNG
Knipsel.PNG (137.78 KiB) Viewed 1664 times
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: P1 counter value math

Post by waaren »

StefanWouters wrote: Thursday 20 June 2019 21:25 i have found several methods but something is going wrong..;-) trying to get 1 value stored...
This message is about dzVents recognize the situation that the script wants to put a table value in the sValue field of a device which would lead to a crash off domoticz. So dzvents will not allow this to happen.

Please remove the -- from line 20.
The script will then produce some extra log lines which might make it easier to understand what is happening.
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
StefanWouters
Posts: 14
Joined: Tuesday 18 June 2019 17:07
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: P1 counter value math

Post by StefanWouters »

Bij deze

Code: Select all

2019-06-20 22:44:59.147 EventSystem: Event triggered: Script #6 stop eerste vrijgave_1
2019-06-20 22:44:59.021 Status: dzVents: Info: Handling events for: "Power", value: "24086340;17373198;3070180;6587818;748;0"
2019-06-20 22:44:59.021 Status: dzVents: Info: SME 0.1.6: ------ Start internal script: Script #1: Device: "Power (Slimmemeter)", Index: 1
2019-06-20 22:44:59.022 Status: dzVents: Debug: SME 0.1.6: Processing device-adapter for Test7: Counter device adapter
2019-06-20 22:44:59.023 Status: dzVents: Debug: SME 0.1.6: Gebruik laag = 24086340
2019-06-20 22:44:59.023 Status: dzVents: Debug: SME 0.1.6: Processing device-adapter for Test8: Counter device adapter
2019-06-20 22:44:59.023 Status: dzVents: Debug: SME 0.1.6: Gebruik hoog = 17373198
2019-06-20 22:44:59.024 Status: dzVents: Debug: SME 0.1.6: Processing device-adapter for Test9: Counter device adapter
2019-06-20 22:44:59.024 Status: dzVents: Debug: SME 0.1.6: Levering laag = 3070180
2019-06-20 22:44:59.025 Status: dzVents: Debug: SME 0.1.6: Processing device-adapter for Test10: Counter device adapter
2019-06-20 22:44:59.025 Status: dzVents: Debug: SME 0.1.6: Levering hoog = 6587818
2019-06-20 22:44:59.026 Status: dzVents: Debug: SME 0.1.6: Processing device-adapter for Test11: Counter device adapter
2019-06-20 22:44:59.026 Status: dzVents: Debug: SME 0.1.6: Actuele Gebruik = 748
2019-06-20 22:44:59.026 Status: dzVents: Debug: SME 0.1.6: Processing device-adapter for Test12: Counter device adapter
2019-06-20 22:44:59.027 Status: dzVents: Debug: SME 0.1.6: Actuele Levering = 0
2019-06-20 22:44:59.027 Status: dzVents: Debug: SME 0.1.6: Processing device-adapter for Uitgang 4: Switch device adapter
2019-06-20 22:44:59.027 Status: dzVents: Debug: SME 0.1.6: Constructed timed-command: Off
2019-06-20 22:44:59.028 Status: dzVents: Debug: SME 0.1.6: Processing device-adapter for Test14: Counter device adapter
2019-06-20 22:44:59.029 Status: dzVents: Info: SME 0.1.6: ------ Finished Script #1
2019-06-20 22:44:59.128 Status: Levering:
2019-06-20 22:44:59.128 Status: 0.0
2019-06-20 22:44:59.128 Status: 0.0
2019-06-20 22:44:59.128 Status: 0.0
2019-06-20 22:44:59.128 Status: Verbruik:
2019-06-20 22:44:59.128 Status: 224.0
2019-06-20 22:44:59.129 Status: 278.0
2019-06-20 22:44:59.129 Status: 246.0
2019-06-20 22:44:59.175 Status: Executing script: /home/pi/domoticz/scripts/uitgang2-uit
2019-06-20 22:44:59.028 Error: dzVents: Error: (2.4.23) SME 0.1.6: no updateCounter with value of type table allowed !!
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: P1 counter value math

Post by waaren »

StefanWouters wrote: Thursday 20 June 2019 22:43 Log

Code: Select all

2019-06-20 22:44:59.175 Status: Executing script: /home/pi/domoticz/scripts/uitgang2-uit
2019-06-20 22:44:59.028 Error: dzVents: Error: (2.4.23) SME 0.1.6: no updateCounter with value of type table allowed !!
OK.

Code: Select all

53	     domoticz.data.counter = domoticz.devices(idxcons).updateCounter(SMdata[5])
54    end
55    
56       domoticz.devices (warmtevraag) .switchOff ().checkFirst()
57        domoticz.devices(test3).updateCounter(domoticz.data.counter)
Don't understand what the script intends to do in these lines. What it actually does:

In line 53 domoticz.data.counter is set as a table. In line 57 device 44 is updated with this table. This is not allowed and therefore the script will abort and no devices will be updated.
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
StefanWouters
Posts: 14
Joined: Tuesday 18 June 2019 17:07
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: P1 counter value math

Post by StefanWouters »

I have Made soms tests in the script. I want to store some values, so that i can use them at the end of the script For some calculations. In want to know of their is power deliverd (> 1000W), or used. When their is enough delivery of power my energy system is going to heat up the boiler. When their is more power deliverd then (for example) 3000W the addition heating element wil be enabled.
User avatar
waaren
Posts: 6028
Joined: Tuesday 03 January 2017 14:18
Target OS: Linux
Domoticz version: Beta
Location: Netherlands
Contact:

Re: P1 counter value math

Post by waaren »

StefanWouters wrote: Friday 21 June 2019 18:33 I have Made soms tests in the script. I want to store some values, so that i can use them at the end of the script For some calculations. In want to know of their is power deliverd (> 1000W), or used. When their is enough delivery of power my energy system is going to heat up the boiler. When their is more power deliverd then (for example) 3000W the addition heating element wil be enabled.
OK. To set the value of device test3 you should modify the lines to

Code: Select all

     domoticz.data.counter = SMdata[5]
end
     domoticz.devices(warmtevraag).switchOff().checkFirst()
  domoticz.devices(test3).updateCounter(domoticz.data.counter)
Debian buster, bullseye on RPI-4, Intel NUC.
dz Beta, Z-Wave, RFLink, RFXtrx433e, P1, Youless, Hue, Yeelight, Xiaomi, MQTT
==>> dzVents wiki
StefanWouters
Posts: 14
Joined: Tuesday 18 June 2019 17:07
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: P1 counter value math

Post by StefanWouters »

that works!!
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest