Get data (from P1) into dummy?

Moderator: leecollings

Post Reply
BarryT
Posts: 367
Joined: Tuesday 31 March 2015 22:06
Target OS: Linux
Domoticz version: 2024.3
Location: east netherlands
Contact:

Get data (from P1) into dummy?

Post by BarryT »

Hi everybody,

can someone help me out?
I want to have some dummy sensors, wich tell me the 'live' watts currently using, as well a dummy for the solar part, and also one for the total usage of the energy today...

My JSON output is >

{
"ActTime" : 1462204188,
"ServerTime" : "2016-05-02 17:49:48",
"Sunrise" : "06:03",
"Sunset" : "20:59",
"result" : [
{
"AddjMulti" : 1.0,
"AddjMulti2" : 1.0,
"AddjValue" : 0.0,
"AddjValue2" : 0.0,
"BatteryLevel" : 255,
"Counter" : "87.841",
"CounterDeliv" : "88.312",
"CounterDelivToday" : "13.213 kWh",
"CounterToday" : "1.753 kWh",
"CustomImage" : 0,
"Data" : "63981;23860;38383;49929;0;143",
"Description" : "",
"Favorite" : 1,
"HardwareID" : 21,
"HardwareName" : "P1 Kabel",
"HardwareType" : "P1 Smart Meter USB",
"HardwareTypeVal" : 4,
"HaveTimeout" : false,
"ID" : "1",
"LastUpdate" : "2016-05-02 17:49:48",
"Name" : "Stroom",
"Notifications" : "false",
"PlanID" : "0",
"PlanIDs" : [ 0 ],
"Protected" : false,
"ShowNotifications" : true,
"SignalLevel" : "-",
"SubType" : "Energy",
"SwitchTypeVal" : 0,
"Timers" : "false",
"Type" : "P1 Smart Meter",
"TypeImg" : "counter",
"Unit" : 1,
"Usage" : "0 Watt",
"UsageDeliv" : "143 Watt",
"Used" : 1,
"XOffset" : "0",
"YOffset" : "0",
"idx" : "132"
}
],
"status" : "OK",
"title" : "Devices"
}

Can someone help me out on how to get, for example the "UsageDeliv" : "143 Watt", (solar part) or the "Usage" : "0 Watt", (live usage) into a dummy?
Can this simple done by a lua or a python script, or with curl/json/php?

Thanks!
Barry
User avatar
Mediacj
Posts: 74
Joined: Wednesday 11 February 2015 16:09
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: Netherlands
Contact:

Re: Get data (from P1) into dummy?

Post by Mediacj »

Not the solution but just a possibility, have a look at:
https://www.domoticz.com/wiki/Domoticz_ ... mart_meter
BarryT
Posts: 367
Joined: Tuesday 31 March 2015 22:06
Target OS: Linux
Domoticz version: 2024.3
Location: east netherlands
Contact:

Re: Get data (from P1) into dummy?

Post by BarryT »

Thnx MediacJ, but allready saw that..
That is not what i'm looking for.
I'm just looking for a way to get status (counter) and a way to send it trough a script (may be everything) and get it (back) into a dummy (counter).
As we all know the p1 smart meter have several outputs, like wattage usage, wattage total, retour wattage, retour total etc..
I just want to splitted it up into 4 dummy's with each its own counter.

Why is it so hard? :?
BarryT
Posts: 367
Joined: Tuesday 31 March 2015 22:06
Target OS: Linux
Domoticz version: 2024.3
Location: east netherlands
Contact:

Re: Get data (from P1) into dummy?

Post by BarryT »

I wish it was just easy as,

get state from json with curl or something, and then send it back like >

commandArray[1] = {['UpdateDevice'] = CounterDelivToday .. "|0|" .. deliveredpower .. ";" .. solaroutput}
commandArray[2] = {['UpdateDevice'] = CounterToday .. "|0|" .. totalpowertoday .. ";" .. usedenergy}
commandArray[3] = {['UpdateDevice'] = Usage .. "|0|" .. powerusage .. ";" .. LivePowerUsage}

But it seems that this is not the way it should work :P
User avatar
Westcott
Posts: 423
Joined: Tuesday 09 December 2014 17:04
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: UK - Glos
Contact:

Re: Get data (from P1) into dummy?

Post by Westcott »

If this is JSON data from some url, then you can use JSON.lua
It decodes the JSON data into a table-

JSON = (loadfile "/home/pi/domoticz/scripts/lua/JSON.lua")()
local jsondata = assert(io.popen(url))
local data = jsondata:read('*all')
jsondata:close()
jsonresult = JSON:decode(data)
Zwave - Sigma Z+ stick, Fibaro, Horstmann, Neo Coolcam, EUROtronic
RFlink - IR detectors and temperatures
Wifi - YeeLights, ESP32s, Anoop sockets
Zigbee - lots with zigbee2mqtt and ZbBridge
BarryT
Posts: 367
Joined: Tuesday 31 March 2015 22:06
Target OS: Linux
Domoticz version: 2024.3
Location: east netherlands
Contact:

Re: Get data (from P1) into dummy?

Post by BarryT »

Cool.. but how do you use that in a practical way?
Read sensor, write it to a table and then read table and import it to a virtual sensor?
User avatar
Westcott
Posts: 423
Joined: Tuesday 09 December 2014 17:04
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: UK - Glos
Contact:

Re: Get data (from P1) into dummy?

Post by Westcott »

There's several topics, and I think a Wiki, describing the details.
But yes, that's exactly how it's done using just Lua.
Zwave - Sigma Z+ stick, Fibaro, Horstmann, Neo Coolcam, EUROtronic
RFlink - IR detectors and temperatures
Wifi - YeeLights, ESP32s, Anoop sockets
Zigbee - lots with zigbee2mqtt and ZbBridge
BarryT
Posts: 367
Joined: Tuesday 31 March 2015 22:06
Target OS: Linux
Domoticz version: 2024.3
Location: east netherlands
Contact:

Re: Get data (from P1) into dummy?

Post by BarryT »

Okay...
Could you send me some topics then?
I've searched almost the hole forum, but i couldn't find anything to 'scrape' a value from a sensor to a dummy!

Thanks!
User avatar
Westcott
Posts: 423
Joined: Tuesday 09 December 2014 17:04
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: UK - Glos
Contact:

Re: Get data (from P1) into dummy?

Post by Westcott »

Zwave - Sigma Z+ stick, Fibaro, Horstmann, Neo Coolcam, EUROtronic
RFlink - IR detectors and temperatures
Wifi - YeeLights, ESP32s, Anoop sockets
Zigbee - lots with zigbee2mqtt and ZbBridge
BarryT
Posts: 367
Joined: Tuesday 31 March 2015 22:06
Target OS: Linux
Domoticz version: 2024.3
Location: east netherlands
Contact:

Re: Get data (from P1) into dummy?

Post by BarryT »

What does a google api has to do with a value i want to scrape from a energy counter?

I dont get it :lol: sorry!
User avatar
Shaggie_NB
Posts: 25
Joined: Thursday 30 January 2014 20:46
Target OS: Windows
Domoticz version:
Location: Oss
Contact:

Re: Get data (from P1) into dummy?

Post by Shaggie_NB »

BarryT wrote:Okay...
Could you send me some topics then?
I've searched almost the hole forum, but i couldn't find anything to 'scrape' a value from a sensor to a dummy!

Thanks!
In Blockly you can choose Devices Utility and there is Gas actual and Electricity actual.
Now you can make a user variabele like "gas actual"
In the set statement you can set "gas actual"= (device) gas actual.
Now you can use the "gas actual" variabele in a LuA script to update the dummy gas..

I tried this variabele in a JSON command but this isn't working. Otherwise you could do it all in Blockly... :(
User avatar
Shaggie_NB
Posts: 25
Joined: Thursday 30 January 2014 20:46
Target OS: Windows
Domoticz version:
Location: Oss
Contact:

Re: Get data (from P1) into dummy?

Post by Shaggie_NB »

Barry is this working for you?
BarryT
Posts: 367
Joined: Tuesday 31 March 2015 22:06
Target OS: Linux
Domoticz version: 2024.3
Location: east netherlands
Contact:

Re: Get data (from P1) into dummy?

Post by BarryT »

Thnxx shaggie! Going to try this tonight... i let you know :)
BarryT
Posts: 367
Joined: Tuesday 31 March 2015 22:06
Target OS: Linux
Domoticz version: 2024.3
Location: east netherlands
Contact:

Re: Get data (from P1) into dummy?

Post by BarryT »

Shaggie! Peukie? ;-)

Okay, seriously.
I've try'd that option but that isnt working.
It is a "actual", thats correct but how do i found out the right "value" of the " actual" power.
My P1 Meter has alot of outputs!

P1 Smart Meter > Energy
Output: 95806;46909;73135;106641;3943;0

Output: T1 T2 Ttotal R1 R2
R are for the panels ofcourse, but the question is how to SPLIT these values to a "dummy" sensor :-)
Last edited by BarryT on Tuesday 10 May 2016 19:53, edited 4 times in total.
BarryT
Posts: 367
Joined: Tuesday 31 March 2015 22:06
Target OS: Linux
Domoticz version: 2024.3
Location: east netherlands
Contact:

Re: Get data (from P1) into dummy?

Post by BarryT »

Info:

As you can see, 1 sensor "stroom"
stroom.png
stroom.png (7.66 KiB) Viewed 5575 times
and the actual in blocky.. but wich actual?
blocky.png
blocky.png (28.39 KiB) Viewed 5575 times
Totaal verbruik: T1: 51.672 kWh, T2: 44.904 kWh, Totaal: 96.576 kWh
Teller: T1: 95.806, T2: 47.261
Totaal Levering: R1: 42.092 kWh, R2: 100.458 kWh, Totaal: 142.550 kWh
Teller Retour: R1: 73.135, R2: 106.641
Jaarkosten: -10.11
User avatar
Shaggie_NB
Posts: 25
Joined: Thursday 30 January 2014 20:46
Target OS: Windows
Domoticz version:
Location: Oss
Contact:

Re: Get data (from P1) into dummy?

Post by Shaggie_NB »

I think stroom actual here is 3909...
But put it in a uservariabele and write it to log. And then you know for sure.
BarryT
Posts: 367
Joined: Tuesday 31 March 2015 22:06
Target OS: Linux
Domoticz version: 2024.3
Location: east netherlands
Contact:

Re: Get data (from P1) into dummy?

Post by BarryT »

Thats cool.. Thnxx so far!

I let you know.
spikehome
Posts: 24
Joined: Friday 04 March 2016 15:13
Target OS: -
Domoticz version:
Contact:

Re: Get data (from P1) into dummy?

Post by spikehome »

@BarryT
did it work?
I want the same.
Only i want the Usagedeliv into a dummy.
The Usage is only what you use at power.
The Usagedeliv is the power you send back but the Usage is then always 0.

edit:
tryed with lua but i dont get figure it out how lua works
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest