Measure device consumption cheap way?

Others (MiLight, Hue, Toon etc...)

Moderator: leecollings

ThinkPad
Posts: 890
Joined: Tuesday 30 September 2014 8:49
Target OS: Linux
Domoticz version: beta
Location: The Netherlands
Contact:

Re: Measure device consumption cheap way? >SOLVED, Bought Z-

Post by ThinkPad »

I can't get Z-Wave to work stable for more than a few days on my Synology (due to the, in my opinion, crappy Openzwave library), so i looked for alternatives. I was triggered by this topic: Domoticaforum.eu: Looking for an 'open' Wifi smartplug.

I just bought a Ubiquiti mPower plug for 45 euros, which is highly hackable. You can control the outlets and read the voltage/amps/power etc over HTTP or just login to the unit directly with telnet/SSH.

I expect my unit tomorrow. They also sell a 3-port version and a 6-port version
I am not active on this forum anymore.
tlpeter
Posts: 191
Joined: Wednesday 26 November 2014 18:43
Target OS: Raspberry Pi / ODroid
Domoticz version: Beta
Location: Netherlands
Contact:

Re: Measure device consumption cheap way?

Post by tlpeter »

Can you let me know if it can be integrated with Domoticz ?
I am looking for one with the 3 or 6 outlets but per socket switching.
The switching is possible but i want to do it from Domoticz.
Power consumption is a nice to have option too :)
ThinkPad
Posts: 890
Joined: Tuesday 30 September 2014 8:49
Target OS: Linux
Domoticz version: beta
Location: The Netherlands
Contact:

Re: Measure device consumption cheap way?

Post by ThinkPad »

It has an easy API: http://community.ubnt.com/t5/mFi/mPower ... -p/1076449 so making a script to grab the data and control the switches shouldn't be too hard. Maybe gizmocuz can implement it....
Or grab the data/control outlet over SSH.

If i look at this 8-port version: http://hilo90mhz.com/ubiquiti-mfi-mpower-pro-teardown/ (i think a EU version of that one doesn't exist) you can control each outlet individually & also measure individually. Great device i think.
I am not active on this forum anymore.
ThinkPad
Posts: 890
Joined: Tuesday 30 September 2014 8:49
Target OS: Linux
Domoticz version: beta
Location: The Netherlands
Contact:

Re: Measure device consumption cheap way?

Post by ThinkPad »

Got my Ubiquiti mPower plug today. First i was a bit disapointed because i couldn't access any webpage on the plug like they showed in blogs, but it turned out it had a really old firmware (1.2.6)
I upgraded the firmware over SSH, with this tutorial: http://www.fhemwiki.de/wiki/Ubiquit_mFi ... r_Firmware
Be careful to take the time for it, i waited around 5 minutes. You don't want to brick the device. When done, it has firmware 2.18 and after logging in (ubnt/ubnt) i could see the power consumption of the load on the internal webserver + turn it on/off :D

Now i can see the usage in the webinterface (https://IP_OF_PLUG/power)
Image

and also access the JSON output at: https://IP_OF_PLUG/sensors

Code: Select all

{
    "sensors": [
        {
            "port": 1,
            "output": 1,
            "power": 45.691894292,
            "enabled": 0,
            "current": 0.199029862,
            "voltage": 230.170126676,
            "powerfactor": 0.997405968,
            "relay": 1,
            "lock": 0,
            "thismonth": 0
        }
    ],
    "status": "success"
}
(Valid JSON according to http://jsonlint.com/)

I also need a way to kill the watchdog, the plug does a kind of restart or so every few minutes, because it can't reach the controller software. You can see this when having a ping running constantly to the device.
There was some way to work around this, i thought it was something like connecting to the controller, then shutting down controller software. Will take a look at this later.

But the measurements seems very promising, look at that accuracy behind the comma! :shock:

I used the code from here: http://piatwork.blogspot.nl/2015/07/blog-post.html and adapted it, so it sends its data to Domoticz:
Image

My code can be found here:
http://pastebin.com/9pNShAeg

I will later have a look on how to add the consumption data (kWh) to Domoticz, i'm not sure how to do that, ideas are welcome.
I am not active on this forum anymore.
dorenberg
Posts: 110
Joined: Monday 22 June 2015 20:18
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.10982
Location: Veghel, The Netherlands
Contact:

Re: Measure device consumption cheap way?

Post by dorenberg »

Very interesting! How often do you update the status? Every minute or so? My plugwise plugs are integrated in domoticz since this week and they are showing similar readings. However, the consumption shown is the average of 10 minutes, so not current consumption. Consumption data is also a topic for me how to achieve this.
ThinkPad
Posts: 890
Joined: Tuesday 30 September 2014 8:49
Target OS: Linux
Domoticz version: beta
Location: The Netherlands
Contact:

Re: Measure device consumption cheap way?

Post by ThinkPad »

dorenberg wrote:Very interesting! How often do you update the status? Every minute or so? My plugwise plugs are integrated in domoticz since this week and they are showing similar readings. However, the consumption shown is the average of 10 minutes, so not current consumption. Consumption data is also a topic for me how to achieve this.
I have not yet running this in 'production'. The screenshots are only a test-setup to see if i could get it working in Domoticz. Like i said: the energy consumed (kWh) is still too be added. The plug shows a total for 'this month'. I'm not sure yet how to integrate that into Domoticz.

But i think the fastest interval could be to measure it every 10 seconds or so... Time will tell if the plug can handle it that fast. Otherwise every 30 sec is also fine for me.
I am not active on this forum anymore.
User avatar
gizmocuz
Posts: 2352
Joined: Thursday 11 July 2013 18:59
Target OS: Raspberry Pi / ODroid
Domoticz version: beta
Location: Top of the world
Contact:

Re: Measure device consumption cheap way?

Post by gizmocuz »

What is cheap ? Where did you bought it ?

Is it cheaper then the nuon greenwave ? (50 euro for 6 outlets)
Quality outlives Quantity!
ThinkPad
Posts: 890
Joined: Tuesday 30 September 2014 8:49
Target OS: Linux
Domoticz version: beta
Location: The Netherlands
Contact:

Re: Measure device consumption cheap way?

Post by ThinkPad »

See my post here: http://domoticz.com/forum/viewtopic.php ... 189#p50053

45 euro for a single out
59 euro for a 3port
99 euro for a 6 port

But this is IP-based, not Z-wave :) These boxes have a webserver on board + you can enter them with SSH and telnet.
I am not active on this forum anymore.
ThinkPad
Posts: 890
Joined: Tuesday 30 September 2014 8:49
Target OS: Linux
Domoticz version: beta
Location: The Netherlands
Contact:

Re: Measure device consumption cheap way?

Post by ThinkPad »

It seems the plug isn't monitoring the usage in kWh, it is still zero after two days (load is using 40W constantly, so it should have +1 kwh at least).

Maybe it only does this when it is connected to the controller software... :( will have a look at that later. Maybe it will start doing that once it has been connected once.
I am not active on this forum anymore.
dorenberg
Posts: 110
Joined: Monday 22 June 2015 20:18
Target OS: Raspberry Pi / ODroid
Domoticz version: 4.10982
Location: Veghel, The Netherlands
Contact:

Re: Measure device consumption cheap way?

Post by dorenberg »

Do you see fluctuations in the voltage of the grid during the day in your graphs?
ThinkPad
Posts: 890
Joined: Tuesday 30 September 2014 8:49
Target OS: Linux
Domoticz version: beta
Location: The Netherlands
Contact:

Re: Measure device consumption cheap way?

Post by ThinkPad »

Yes, actually quite big variations (225 - 238V or so, 10%). I'm at work now, but will post a screenshot of it later.

Still no consumption measured in kWh btw. I think it really needs the controller for that. Will have a look at that when i have some more time. Maybe it needs to be connected once, and after that it also works without the controller software.
I am not active on this forum anymore.
ThinkPad
Posts: 890
Joined: Tuesday 30 September 2014 8:49
Target OS: Linux
Domoticz version: beta
Location: The Netherlands
Contact:

Re: Measure device consumption cheap way?

Post by ThinkPad »

This is from one day:
Image
Lowest point (13:40) it's 225,126V.

I don't know why it has this dip around that time, i would expect the evening. Other days have dips around ~7:00 and ~18:00 and ~22:00
I am not active on this forum anymore.
ThinkPad
Posts: 890
Joined: Tuesday 30 September 2014 8:49
Target OS: Linux
Domoticz version: beta
Location: The Netherlands
Contact:

Re: Measure device consumption cheap way?

Post by ThinkPad »

Ok, last weekend i attached it to the controller software, which was quite a pain in the ***, because it doesn't run with latest Java. I used a 32-bit W7 VM with Java 7 (update 79) and managed to get it working.

The plug now measures consumption, it also spits this out through JSON. But i'm not sure what this number means. It is called 'thismonth'. It now has the value '75'.
The controller software says: 0,05kWh and 0,012 euro (unit price: 0,22euro/kwh).

I have no clue how to translate the 'thismonth' to a kWh reading or so.... Can somebody help me with this?

In this post: http://forum.fhem.de/index.php/topic,35 ... #msg279888 the 'thismonth' value is also filled, but does not correspond to any of the values that can be seen in his screenshot. I couldn't find any API documentation either...
The FHEM module does something with this field, but i don't understand what. See here: https://github.com/mhop/fhem-mirror/blo ... MP.pm#L572
The value seems to be multiplied by 0,3125 but what does that number mean? If i do that calculation by hand, the outcome is still a number that doesn't make any sense to me.

And i am interested in if will continue monitoring if i shutdown the VM... It seems to do so for now....

By the way, when you link the plug to the controller, three extra fields are added (marked red below). As you can see the existing fields will shift.
In my script i could get the voltage reading with

Code: Select all

MPVOLTAGE=$(echo $SENSOR | cut -d "," -f6 | cut -d ":" -f2 | awk '{printf("%.3f\n", $1)}')
but the field has now changed to position 9
Same for power, power factor etc.

Image
I am not active on this forum anymore.
ThinkPad
Posts: 890
Joined: Tuesday 30 September 2014 8:49
Target OS: Linux
Domoticz version: beta
Location: The Netherlands
Contact:

Re: Measure device consumption cheap way?

Post by ThinkPad »

Ok, i got it i guess..... the '0,3125' from: https://github.com/mhop/fhem-mirror/blo ... MP.pm#L572 makes sense now.
When i access https://ipofplug/sensors it says: "thismonth":13333
But in the webinterface it shows 4,17kWh

The formula is: (value*0,3125)/1000 = kWh for this month

(13333*0,3125) = 4166,563
divide it by 1000 = 4,1666 which rounds to 4,17 kWh

Now i can edit the script to use a electricity counter in Domoticz :mrgreen:
I am not active on this forum anymore.
digiwiz
Posts: 1
Joined: Sunday 11 October 2015 10:42
Target OS: Raspberry Pi / ODroid
Domoticz version: 2.3353
Contact:

Re: Measure device consumption cheap way?

Post by digiwiz »

I use dlink dsp-w215 which are pretty good and cheap. (I bought them 25€ / plug)
Is there a way to use them through domoticz?
Rpi - Domoticz v2.3353
Hardware:
Razpberry Zwave - openzwave 1.3-509-g74a898d
RFXcom RFXtrx433E
Philips Hue bridge
Fritzbox 7390 callmonitor
Ferno2000
Posts: 7
Joined: Friday 08 January 2016 16:22
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Measure device consumption cheap way?

Post by Ferno2000 »

Hi Thinkpad,

I wanted to send a PM but am not allowed.

I used you script to add power measuring in domoticz of my power 6 socket power block.
It is working perfectly, thank you very much for the script.

Are you planning on enhancing this script?
I wonder if it is possible to add different grating styles to the utility blocks in Domoticz.
For example with my fibaro wall plugs I get the day totals as a Bar diagram, I would love to have the same option with the Mpower measuring.

Also, I know that the sockets can be switched on or of through webcalls, I want to implement this through a a script and a switch in domoticz, do you have any examples for this?
Otherwise I will start on one but if there is something out there that I can use it will save me a lot of time.
ThinkPad
Posts: 890
Joined: Tuesday 30 September 2014 8:49
Target OS: Linux
Domoticz version: beta
Location: The Netherlands
Contact:

Re: Measure device consumption cheap way?

Post by ThinkPad »

Ferno2000 wrote:Hi Thinkpad,
[...]
Are you planning on enhancing this script?
[...]
Unfortunately not, i have sold my plug and switched to Z-Wave for these kind of tasks.
Switching the plug on can't be that hard. Have a look at the sourcecode of the embedded webserver of the plug. In Google Chrome (and Firefox also i thought) you can 'record' what happens when a button is clicked. I'm quite confident you can get the needed URL from there.

P.S. sending PM's will get enabled automatically when you make more posts i thought.
I am not active on this forum anymore.
Ferno2000
Posts: 7
Joined: Friday 08 January 2016 16:22
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Measure device consumption cheap way?

Post by Ferno2000 »

Hi Thinkpad,

Thanks for the reply, Yeah, there is a url/webcall how to switch it, already taste it and it works well.
Just trying to find out how to implement that in Domoticz as a switch.

So why did you move away from the Mpower, I am pretty impressed by it.

Which Zwave plus do you use?

Also, I hav seen you talk in other forums about Rfxcom, do you use one? I am planning o buying one so I can move away from Homewizard but am not sure if I should go for FRFXcom of RFlink. Any ideas on that?
ThinkPad
Posts: 890
Joined: Tuesday 30 September 2014 8:49
Target OS: Linux
Domoticz version: beta
Location: The Netherlands
Contact:

Re: Measure device consumption cheap way?

Post by ThinkPad »

You can put a URL in the 'On action' of a virtual switch. This can be done by clicking 'Edit' beneath a switch.
Otherwise (if it is a bit more difficult than a simple URL that is needed to activate) create a Lua script that executes the desired action when the state of a virtual switch has changed.

I use Everspring AN158 plugs and a POPP and Aeon plug.

Also a RFXCOM yes, but only for temperature sensors a some cheap 433Mhz motion sensors. In the past few months i have replaced most of my lightswitches by Z-Wave variants, because of the better reliability of them responding to commands initiated by Domoticz.
I don't have experience with the RFLink, but maybe it also works good. Only way to find out is by trying it....
I am not active on this forum anymore.
Ferno2000
Posts: 7
Joined: Friday 08 January 2016 16:22
Target OS: Raspberry Pi / ODroid
Domoticz version:
Contact:

Re: Measure device consumption cheap way?

Post by Ferno2000 »

Hi Thinkpad,

Thank, totally forgot about the on action option.

Will use that, any idea about getting the power readings form you script as a daily BAR graph instead of the line graph option?


And what about rfxlink, any thoughts on that?
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest