Enelogic P1 port adapter LAN

Moderator: leecollings

berkens
Posts: 34
Joined: Tuesday 06 October 2015 13:03
Target OS: NAS (Synology & others)
Domoticz version: 3.8891
Location: Amsterdam
Contact:

Enelogic P1 port adapter LAN

Post by berkens »

Hi All,

Tried to add my Enelogic P1 port adapter to Domoticz meter readings via LAN.

I don't know if the hardware device "P1 Smart Meter with LAN interface" is ment for that.

In the Utillity screen are no sensors shown.

I can read the data via LAN in my browser via

http://enelogic:1000/cgi/electricityMeter/update (or replace enelogic with the IP-address).

Here some details on the device XML output:
  • <update>
    <detected>true</detected>
    <reading id="e_consumed_1" unit="kWh">2730.905000</reading>
    <reading id="e_consumed_2" unit="kWh">3302.332000</reading>
    <reading id="e_produced_1" unit="kWh">0.000000</reading>
    <reading id="e_produced_2" unit="kWh">0.000000</reading>
    <reading id="p_consumed" unit="kW">0.457000</reading>
    <reading id="p_produced" unit="kW">0.000000</reading>
    <text id="e_switch">in</text>
    </update>
For the gasmeter via the Enelogic P1 : http://enelogic:1000/cgi/gasMeter/update
  • <update>
    <detected>true</detected>
    <reading id="consumed" unit="m3">915.831000</reading>
    <text id="valve">on</text>
    </update>
Anybody familiar with this? Can't find a topic.

Image

Greetings Ben

Running a NAS DS214
Windows 10 laptop, Synology DS214 + DSM6.1, Zwave.me USB, Neo CoolCam powerplugs & dual wall switches, Heiman gasdetector, Eurotronic Spirit heatvalve, Samsung SmartThings hub v2 UK
ThinkPad
Posts: 890
Joined: Tuesday 30 September 2014 8:49
Target OS: Linux
Domoticz version: beta
Location: The Netherlands
Contact:

Re: Enelogic P1 port adapter LAN

Post by ThinkPad »

It seems a virtual P1 device can be made, but it only mentions electricity: http://domoticz.com/wiki/Domoticz_API/J ... mart_meter
I don't know about gas......

But why not just sell that device and buy a P1 USB smart meter cable? Much easier, and works fine on Synology.....

If you really want to get this one working i thik the P1 option from the API wikipage is the best option.... Shouldn't be too hard to make a Bash (or Python) that can strip the values from the Enelogic device and put them in the correct place in the URL for the API.
I'm doing something similar with a Ubiquiti WiFi smartplug. With a Bash script i scrape the values from the plug and them put them into virtual sensors in Domoticz. You can find my script here.

I think a PHP-script would be the easiest for you: http://www.w3schools.com/php/php_xml_simplexml_get.asp
With Bash / Python you would probably require extra libraries to be installed, that aren't available on your Synology without 'jailbreaking' it.

I will try to see if i can make something with PHP, i think i can help you with this :) But it will be later, leaving tomorrow for a few days off. But i have subscribed to this topic, so i don't forget it.
I am not active on this forum anymore.
berkens
Posts: 34
Joined: Tuesday 06 October 2015 13:03
Target OS: NAS (Synology & others)
Domoticz version: 3.8891
Location: Amsterdam
Contact:

Re: Enelogic P1 port adapter LAN

Post by berkens »

Couldn't find info in the wiki or docs about the P1 power meter Lan setting that can be selected in the hardware device menu.

Because I have the NAS not near the smart power meter, I have choosen the Lan solution for the P1 adapter. Can read it even without Domoticz! :-)
Windows 10 laptop, Synology DS214 + DSM6.1, Zwave.me USB, Neo CoolCam powerplugs & dual wall switches, Heiman gasdetector, Eurotronic Spirit heatvalve, Samsung SmartThings hub v2 UK
ThinkPad
Posts: 890
Joined: Tuesday 30 September 2014 8:49
Target OS: Linux
Domoticz version: beta
Location: The Netherlands
Contact:

Re: Enelogic P1 port adapter LAN

Post by ThinkPad »

I think this little PHP-script will work:

Code: Select all

<!DOCTYPE html>
<html>
<body>

<?php
$xml=simplexml_load_file("http://enelogic:1000/cgi/electricityMeter/update") or die("Error: Cannot create object");

$DomoticzIP = "192.168.1.25";
$DomoticzPort = "8084";
$IDX = "303";

$used_high = floatval($xml->reading[0]);
$used_low = floatval($xml->reading[1]);
$produced_high = floatval($xml->reading[2]);
$produced_low = floatval($xml->reading[3]);
$actual_consumed = floatval($xml->reading[4])*1000;
$actual_produced = floatval($xml->reading[5])*1000;

$curl = curl_init();
    curl_setopt ($curl, CURLOPT_URL, "http://{$DomoticzIP}:{$DomoticzPort}/json.htm?type=command&param=udevice&idx={$IDX}&nvalue=0&svalue={$used_high};{$used_low};{$produced_high};{$produced_low};{$actual_consumed};{$actual_produced}");
    curl_exec ($curl);
    curl_close ($curl);

?>  

</body>
</html>
- Create new hardware in Domoticz, Setup > Hardware, create hardware of type 'Dummy'.
- Then click the blue button behind it to create virtual device (P1 Smart Meter Electric) and look under Setup > Devices to add it to your Dashboard (click the green arrow).
- Note the IDX and change it in the script (also the URL & Port to your Domoticz & URL to the Enelogic device).

Copy the script to a webserver in your network (like your NAS or so, or install PHP support for the default ngingx on Domoticz) and then call the script ('enelogic.php') every minute or so (even faster, like 10sec, may also work but i'm not sure) from your cron (something like 'curl http://ip/path/to/enelogic.php'). But first try calling the URL by hand from your browser, you should see something like "OK: Device updated" which is a notification from Domoticz.

Maybe it will also work from commandline:

Code: Select all

php /put/path/to/script/here/enelogic.php 
If you don't have PHP yet: sudo apt-get install php5-cli

I will have a look on the gas part later. Not very difficult i think, same approach, only a different virtual device.

Let me know if this works for you! :mrgreen:
I am not active on this forum anymore.
berkens
Posts: 34
Joined: Tuesday 06 October 2015 13:03
Target OS: NAS (Synology & others)
Domoticz version: 3.8891
Location: Amsterdam
Contact:

Re: Enelogic P1 port adapter LAN

Post by berkens »

I tried on my Windows laptop with Domoticz:

I made the virtual device with the correct settings for Energy Meter.

Edit IP and IDX.

C:\php>php enelogic.php
<!DOCTYPE html>
<html>
<body>
Fatal error: Call to undefined function curl_init() in C:\php\enelogic.php on line 19
C:\php>[/list]

Code: Select all

$curl = curl_init();
So far.

Greetings Ben...
Windows 10 laptop, Synology DS214 + DSM6.1, Zwave.me USB, Neo CoolCam powerplugs & dual wall switches, Heiman gasdetector, Eurotronic Spirit heatvalve, Samsung SmartThings hub v2 UK
berkens
Posts: 34
Joined: Tuesday 06 October 2015 13:03
Target OS: NAS (Synology & others)
Domoticz version: 3.8891
Location: Amsterdam
Contact:

Re: Enelogic P1 port adapter LAN

Post by berkens »

Found in example.lua about curl_init():

Code: Select all

-- Example of parser handling data with the following format
-- TEMPERATURE,HUMIDITY,HUMIDITY_STATUS

-- A test with curl would be : curl -X POST -d "28,48,2" 'http://192.168.1.17:8080/json.htm?type=command&param=udevices&script=example.lua'

-- This function split a string according to a defined separator
-- Entries are returned into an associative array with key values 1,2,3,4,5,6...
local function split(str, sep)
	if sep == nil then
		sep = "%s"
	end
	local t={} ; i=1
	local regex = string.format("([^%s]+)", sep)
		for str in str:gmatch(regex) do
			t[i] = str
			i = i + 1
		end
	return t
end

-- Retrieve the request content
s = request['content'];

-- Split the content into an array of values
local values = split(s, ",");

-- Update some devices (index are here for this example)
domoticz_updateDevice(19,'',values[1])
domoticz_updateDevice(20,values[2],values[2] .. ";" .. values[3])

Windows 10 laptop, Synology DS214 + DSM6.1, Zwave.me USB, Neo CoolCam powerplugs & dual wall switches, Heiman gasdetector, Eurotronic Spirit heatvalve, Samsung SmartThings hub v2 UK
ThinkPad
Posts: 890
Joined: Tuesday 30 September 2014 8:49
Target OS: Linux
Domoticz version: beta
Location: The Netherlands
Contact:

Re: Enelogic P1 port adapter LAN

Post by ThinkPad »

Try the script with a webserver like XAMPP on Windows. It seems the PHP-version you are now using is missing the 'curl_init' part.
I am not active on this forum anymore.
berkens
Posts: 34
Joined: Tuesday 06 October 2015 13:03
Target OS: NAS (Synology & others)
Domoticz version: 3.8891
Location: Amsterdam
Contact:

Re: Enelogic P1 port adapter LAN

Post by berkens »

Here the result:
  • D:\xampp\php>php enelogic.php
    <!DOCTYPE html>
    <html>
    <body>

    {
    "status" : "OK",
    "title" : "Update Device"
    }

    </body>
    </html>
    D:\xampp\php>
So far, so good.

Where can I find the output of this PHP?

Greetings Ben...
Windows 10 laptop, Synology DS214 + DSM6.1, Zwave.me USB, Neo CoolCam powerplugs & dual wall switches, Heiman gasdetector, Eurotronic Spirit heatvalve, Samsung SmartThings hub v2 UK
ThinkPad
Posts: 890
Joined: Tuesday 30 September 2014 8:49
Target OS: Linux
Domoticz version: beta
Location: The Netherlands
Contact:

Re: Enelogic P1 port adapter LAN

Post by ThinkPad »

That looks better indeed.

The only thing the PHP-script does, is:
- Getting the values from the Enelogic device
- Extracting the relevant numbers
- Putting them in a URL that puts them into Domoticz virtual P1-device
- Calling the URL (curl_init) so the values are put in Domoticz.

No output is shown further, besides the output you are now seeing. If the script works correctly, the virtual P1 device that you created in Domoticz should be updated everytime you call the script (which we will further automate once you got things running).
I am not active on this forum anymore.
berkens
Posts: 34
Joined: Tuesday 06 October 2015 13:03
Target OS: NAS (Synology & others)
Domoticz version: 3.8891
Location: Amsterdam
Contact:

Re: Enelogic P1 port adapter LAN

Post by berkens »

The output is even shown on the Utility page in the Log -> Report !! And there is data shown in a meter on the Dashboard.

Counter T1=2.766 and T2=3.353

That is correct data from my meter. Will try to post screenshot from Domoticz later.

Running the PHP script for a second time fails. So there are no updates.
D:\xampp\php>php enelogic.php
<!DOCTYPE html>
<html>
<body>


Warning: simplexml_load_file(http://enelogic:1000/cgi/electricityMeter/update):
failed to open stream: Kan geen verbinding maken omdat de doelcomputer de verbin
ding actief heeft geweigerd.
in D:\xampp\php\enelogic.php on line 6

Warning: simplexml_load_file(): I/O warning : failed to load external entity "ht
tp://enelogic:1000/cgi/electricityMeter/update" in D:\xampp\php\enelogic.php on
line 6
Error: Cannot create object
I need to reset the Enelogic and then one or two times I can run the script. After that it fails.

In the Setup -> Hardware the IDX=5 and on the Hardware -> Device page the IDX=14 for the same item. Don't know what is best.
Last edited by berkens on Sunday 11 October 2015 22:37, edited 1 time in total.
Windows 10 laptop, Synology DS214 + DSM6.1, Zwave.me USB, Neo CoolCam powerplugs & dual wall switches, Heiman gasdetector, Eurotronic Spirit heatvalve, Samsung SmartThings hub v2 UK
berkens
Posts: 34
Joined: Tuesday 06 October 2015 13:03
Target OS: NAS (Synology & others)
Domoticz version: 3.8891
Location: Amsterdam
Contact:

Re: Enelogic P1 port adapter LAN

Post by berkens »

Windows 10 laptop, Synology DS214 + DSM6.1, Zwave.me USB, Neo CoolCam powerplugs & dual wall switches, Heiman gasdetector, Eurotronic Spirit heatvalve, Samsung SmartThings hub v2 UK
berkens
Posts: 34
Joined: Tuesday 06 October 2015 13:03
Target OS: NAS (Synology & others)
Domoticz version: 3.8891
Location: Amsterdam
Contact:

Re: Enelogic P1 port adapter LAN

Post by berkens »

It shows also the current power in Watt and the total energy since the measuring started in kWh

Image

http://nl.tinypic.com/usermedia.php?uo= ... hrL5eztmko
Windows 10 laptop, Synology DS214 + DSM6.1, Zwave.me USB, Neo CoolCam powerplugs & dual wall switches, Heiman gasdetector, Eurotronic Spirit heatvalve, Samsung SmartThings hub v2 UK
ThinkPad
Posts: 890
Joined: Tuesday 30 September 2014 8:49
Target OS: Linux
Domoticz version: beta
Location: The Netherlands
Contact:

Re: Enelogic P1 port adapter LAN

Post by ThinkPad »

Why is your Domoticz looking so messed up :shock: ?

And i think the script is not closing the connection to the Enelogic device (the 'curl_close' part is not working correctly i think). Will come back at that later, i also have a normal paid job :lol:

But from your screenshots it looks like the script is doing what it should?
P.s. i normally use www.imgur.com for posting images. TinyPic is loaded with spam stuff.
I am not active on this forum anymore.
berkens
Posts: 34
Joined: Tuesday 06 October 2015 13:03
Target OS: NAS (Synology & others)
Domoticz version: 3.8891
Location: Amsterdam
Contact:

Re: Enelogic P1 port adapter LAN

Post by berkens »

ThinkPad wrote:Why is your Domoticz looking so messed up :shock: ?
The browser I used? I also were suprised by the layout of the weather info I see on the Dashboard.
Not logical.
And i think the script is not closing the connection to the Enelogic device (the 'curl_close' part is not working correctly i think).
The lan-adapter sends every 10 secondes to Enelogic. Could give a collision? The adapter is busy with Enelogic?
Will come back at that later, i also have a normal paid job :lol:
I knpw that "problem" too.
But from your screenshots it looks like the script is doing what it should?
Yes, it looks very well. It can read the data from the power meter via the Enelogic adapter and use it into the Dashboard and more.
P.s. i normally use http://www.imgur.com for posting images. TinyPic is loaded with spam stuff.
Tnx, will try. Used ImageShack, but that needs a subscription by now.

Greetings Ben...
Windows 10 laptop, Synology DS214 + DSM6.1, Zwave.me USB, Neo CoolCam powerplugs & dual wall switches, Heiman gasdetector, Eurotronic Spirit heatvalve, Samsung SmartThings hub v2 UK
ThinkPad
Posts: 890
Joined: Tuesday 30 September 2014 8:49
Target OS: Linux
Domoticz version: beta
Location: The Netherlands
Contact:

Re: Enelogic P1 port adapter LAN

Post by ThinkPad »

Does your Domoticz always looks like that? I sometimes have it, but then a refresh (F5) of the pages fixes it (cache loaded again).

Maybe you can contact Enelogic about this. They are nice guys, had contact with them a few times. It could indeed be the problem that the device is too busy with sending updates to Enelogic.
I am not active on this forum anymore.
berkens
Posts: 34
Joined: Tuesday 06 October 2015 13:03
Target OS: NAS (Synology & others)
Domoticz version: 3.8891
Location: Amsterdam
Contact:

Re: Enelogic P1 port adapter LAN

Post by berkens »

Enelogic also has an API. Is another option.

https://enelogic.uservoice.com/knowledg ... rkt-de-api

Will ask them about the frequentie of updates (10 seconds interval I read).
Windows 10 laptop, Synology DS214 + DSM6.1, Zwave.me USB, Neo CoolCam powerplugs & dual wall switches, Heiman gasdetector, Eurotronic Spirit heatvalve, Samsung SmartThings hub v2 UK
berkens
Posts: 34
Joined: Tuesday 06 October 2015 13:03
Target OS: NAS (Synology & others)
Domoticz version: 3.8891
Location: Amsterdam
Contact:

Re: Enelogic P1 port adapter LAN

Post by berkens »

Hi @Thinkpad,

I did some homework with your script and now...I can readout my gasmeter E350 via the Enelogic P1 adapter.

Here the code that works:

Code: Select all

<!DOCTYPE html>
<html>
<body>

<?php
$xml=simplexml_load_file("http://enelogic:1000/cgi/gasMeter/update") or die("Error: Cannot create object");

$DomoticzIP = "127.0.0.1";
$DomoticzPort = "8080";
$IDX = "16";

$actual_consumed = floatval($xml->reading[0])*1000;

$curl = curl_init();
    curl_setopt ($curl, CURLOPT_URL, "http://{$DomoticzIP}:{$DomoticzPort}/json.htm?type=command&param=udevice&idx={$IDX}&nvalue=0&svalue={$actual_consumed}");
    curl_exec ($curl);
    curl_close ($curl);

?>  

</body>
</html>
The only problem that is still there: the adapter can lock-up and fails after 1 or 2 attemps. For that I asked Enelogic for help.

I added an extra virtual device, the electricity meter uses another call so I think it can not be combined in 1 script.
The virtuel device is defined as a gasmeter, the icon is a gasmeter and the unit of measurement is M3.

Will supply a printscreen.

Greetings Ben...
Windows 10 laptop, Synology DS214 + DSM6.1, Zwave.me USB, Neo CoolCam powerplugs & dual wall switches, Heiman gasdetector, Eurotronic Spirit heatvalve, Samsung SmartThings hub v2 UK
berkens
Posts: 34
Joined: Tuesday 06 October 2015 13:03
Target OS: NAS (Synology & others)
Domoticz version: 3.8891
Location: Amsterdam
Contact:

Re: Enelogic P1 port adapter LAN

Post by berkens »

Here the printscreen with the electricity- and gasmeter via the Enelogic P1 adapter LAN

Image

http://i58.tinypic.com/352ekb5.jpg

Later on I will dump tinypic ! :lol:
Windows 10 laptop, Synology DS214 + DSM6.1, Zwave.me USB, Neo CoolCam powerplugs & dual wall switches, Heiman gasdetector, Eurotronic Spirit heatvalve, Samsung SmartThings hub v2 UK
User avatar
tcviper
Posts: 89
Joined: Monday 30 June 2014 13:34
Target OS: Raspberry Pi / ODroid
Domoticz version:
Location: Netherlands
Contact:

Re: Enelogic P1 port adapter LAN

Post by tcviper »

Could we ask support for the API or through local calls from Enelogic p1 meter in Domoticz please? :) Would love to see full support for this device.
ThinkPad
Posts: 890
Joined: Tuesday 30 September 2014 8:49
Target OS: Linux
Domoticz version: beta
Location: The Netherlands
Contact:

Re: Enelogic P1 port adapter LAN

Post by ThinkPad »

tcviper wrote:Could we ask support for the API or through local calls from Enelogic p1 meter in Domoticz please? :) Would love to see full support for this device.
Why? A USB P1-cable is much cheaper.

And if you prefer LAN you could also built something with this module: http://domoticz.com/forum/viewtopic.php?f=30&t=8505
Domoticz already has support for P1 over LAN.

But support in Domoticz shouldn't be too hard, i don't even have the device and already figured out 90% of the working, as you can see in my posts from October :p
I am not active on this forum anymore.
Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests