Get data (from P1) into dummy?

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

Get data (from P1) into dummy?

Post by BarryT » Monday 02 May 2016 17:53

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
6x Raspberry 3
2x VPS Server
2x Active VPN
A lot of scripts, switches and sensors :)

User avatar
Mediacj
Posts: 102
Joined: Wednesday 11 February 2015 17:09
Target OS: Raspberry Pi
Domoticz version:
Location: Netherlands
Contact:

Re: Get data (from P1) into dummy?

Post by Mediacj » Monday 02 May 2016 18:50

Not the solution but just a possibility, have a look at:
https://www.domoticz.com/wiki/Domoticz_ ... mart_meter

BarryT
Posts: 281
Joined: Tuesday 31 March 2015 22:06
Target OS: Linux
Domoticz version: beta
Location: east netherlands
Contact:

Re: Get data (from P1) into dummy?

Post by BarryT » Monday 02 May 2016 18:55

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? :?
6x Raspberry 3
2x VPS Server
2x Active VPN
A lot of scripts, switches and sensors :)

BarryT
Posts: 281
Joined: Tuesday 31 March 2015 22:06
Target OS: Linux
Domoticz version: beta
Location: east netherlands
Contact:

Re: Get data (from P1) into dummy?

Post by BarryT » Monday 02 May 2016 19:05

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
6x Raspberry 3
2x VPS Server
2x Active VPN
A lot of scripts, switches and sensors :)

User avatar
Westcott
Posts: 548
Joined: Tuesday 09 December 2014 18:04
Target OS: Raspberry Pi
Domoticz version: Beta
Location: UK - Glos
Contact:

Re: Get data (from P1) into dummy?

Post by Westcott » Monday 02 May 2016 19:17

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 2x FGSD002, FGMS001
Horstmann - 2x HRT4, 2x C-stat-11, 4x ASR-ZW, TKB 2x TZ56, 2x TZ68E
Max-EQ Cube, Valve, Neo 2x door
RFXtrx433E, RFlink - 1byone driveway, doorbell, Oregon and BangGood temp
Wifi - YeeLight RGB, 3x ESP8266

BarryT
Posts: 281
Joined: Tuesday 31 March 2015 22:06
Target OS: Linux
Domoticz version: beta
Location: east netherlands
Contact:

Re: Get data (from P1) into dummy?

Post by BarryT » Monday 02 May 2016 20:53

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?
6x Raspberry 3
2x VPS Server
2x Active VPN
A lot of scripts, switches and sensors :)

User avatar
Westcott
Posts: 548
Joined: Tuesday 09 December 2014 18:04
Target OS: Raspberry Pi
Domoticz version: Beta
Location: UK - Glos
Contact:

Re: Get data (from P1) into dummy?

Post by Westcott » Monday 02 May 2016 21:01

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 2x FGSD002, FGMS001
Horstmann - 2x HRT4, 2x C-stat-11, 4x ASR-ZW, TKB 2x TZ56, 2x TZ68E
Max-EQ Cube, Valve, Neo 2x door
RFXtrx433E, RFlink - 1byone driveway, doorbell, Oregon and BangGood temp
Wifi - YeeLight RGB, 3x ESP8266

BarryT
Posts: 281
Joined: Tuesday 31 March 2015 22:06
Target OS: Linux
Domoticz version: beta
Location: east netherlands
Contact:

Re: Get data (from P1) into dummy?

Post by BarryT » Monday 02 May 2016 21:23

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!
6x Raspberry 3
2x VPS Server
2x Active VPN
A lot of scripts, switches and sensors :)

User avatar
Westcott
Posts: 548
Joined: Tuesday 09 December 2014 18:04
Target OS: Raspberry Pi
Domoticz version: Beta
Location: UK - Glos
Contact:

Re: Get data (from P1) into dummy?

Post by Westcott » Monday 02 May 2016 21:40

Zwave - Sigma Z+ stick, Fibaro 2x FGSD002, FGMS001
Horstmann - 2x HRT4, 2x C-stat-11, 4x ASR-ZW, TKB 2x TZ56, 2x TZ68E
Max-EQ Cube, Valve, Neo 2x door
RFXtrx433E, RFlink - 1byone driveway, doorbell, Oregon and BangGood temp
Wifi - YeeLight RGB, 3x ESP8266

BarryT
Posts: 281
Joined: Tuesday 31 March 2015 22:06
Target OS: Linux
Domoticz version: beta
Location: east netherlands
Contact:

Re: Get data (from P1) into dummy?

Post by BarryT » Monday 02 May 2016 22:07

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!
6x Raspberry 3
2x VPS Server
2x Active VPN
A lot of scripts, switches and sensors :)

User avatar
Shaggie_NB
Posts: 42
Joined: Thursday 30 January 2014 21:46
Target OS: Windows
Domoticz version:
Location: Oss
Contact:

Re: Get data (from P1) into dummy?

Post by Shaggie_NB » Monday 02 May 2016 23:19

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: 42
Joined: Thursday 30 January 2014 21:46
Target OS: Windows
Domoticz version:
Location: Oss
Contact:

Re: Get data (from P1) into dummy?

Post by Shaggie_NB » Saturday 07 May 2016 3:00

Barry is this working for you?

BarryT
Posts: 281
Joined: Tuesday 31 March 2015 22:06
Target OS: Linux
Domoticz version: beta
Location: east netherlands
Contact:

Re: Get data (from P1) into dummy?

Post by BarryT » Saturday 07 May 2016 8:21

Thnxx shaggie! Going to try this tonight... i let you know :)
6x Raspberry 3
2x VPS Server
2x Active VPN
A lot of scripts, switches and sensors :)

BarryT
Posts: 281
Joined: Tuesday 31 March 2015 22:06
Target OS: Linux
Domoticz version: beta
Location: east netherlands
Contact:

Re: Get data (from P1) into dummy?

Post by BarryT » Tuesday 10 May 2016 19:47

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.
6x Raspberry 3
2x VPS Server
2x Active VPN
A lot of scripts, switches and sensors :)

BarryT
Posts: 281
Joined: Tuesday 31 March 2015 22:06
Target OS: Linux
Domoticz version: beta
Location: east netherlands
Contact:

Re: Get data (from P1) into dummy?

Post by BarryT » Tuesday 10 May 2016 19:50

Info:

As you can see, 1 sensor "stroom"
stroom.png
stroom.png (7.66 KiB) Viewed 3071 times
and the actual in blocky.. but wich actual?
blocky.png
blocky.png (28.39 KiB) Viewed 3071 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
6x Raspberry 3
2x VPS Server
2x Active VPN
A lot of scripts, switches and sensors :)

User avatar
Shaggie_NB
Posts: 42
Joined: Thursday 30 January 2014 21:46
Target OS: Windows
Domoticz version:
Location: Oss
Contact:

Re: Get data (from P1) into dummy?

Post by Shaggie_NB » Tuesday 10 May 2016 22:09

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: 281
Joined: Tuesday 31 March 2015 22:06
Target OS: Linux
Domoticz version: beta
Location: east netherlands
Contact:

Re: Get data (from P1) into dummy?

Post by BarryT » Tuesday 10 May 2016 22:46

Thats cool.. Thnxx so far!

I let you know.
6x Raspberry 3
2x VPS Server
2x Active VPN
A lot of scripts, switches and sensors :)

spikehome
Posts: 20
Joined: Friday 04 March 2016 16:13
Target OS: -
Domoticz version:
Contact:

Re: Get data (from P1) into dummy?

Post by spikehome » Wednesday 04 January 2017 14:42

@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 3 guests