Page 2 of 3
Re: Measure device consumption cheap way? >SOLVED, Bought Z-
Posted: Friday 31 July 2015 9:45
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
Re: Measure device consumption cheap way?
Posted: Friday 31 July 2015 13:49
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
Re: Measure device consumption cheap way?
Posted: Friday 31 July 2015 13:51
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.
Re: Measure device consumption cheap way?
Posted: Saturday 01 August 2015 14:50
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
Now i can see the usage in the webinterface (https://IP_OF_PLUG/power)
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!
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:
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.
Re: Measure device consumption cheap way?
Posted: Saturday 01 August 2015 22:50
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.
Re: Measure device consumption cheap way?
Posted: Sunday 02 August 2015 9:50
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.
Re: Measure device consumption cheap way?
Posted: Sunday 02 August 2015 14:39
by gizmocuz
What is cheap ? Where did you bought it ?
Is it cheaper then the nuon greenwave ? (50 euro for 6 outlets)
Re: Measure device consumption cheap way?
Posted: Sunday 02 August 2015 16:21
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.
Re: Measure device consumption cheap way?
Posted: Tuesday 04 August 2015 7:43
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.
Re: Measure device consumption cheap way?
Posted: Friday 07 August 2015 13:02
by dorenberg
Do you see fluctuations in the voltage of the grid during the day in your graphs?
Re: Measure device consumption cheap way?
Posted: Friday 07 August 2015 13:03
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.
Re: Measure device consumption cheap way?
Posted: Friday 07 August 2015 16:52
by ThinkPad
This is from one day:
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
Re: Measure device consumption cheap way?
Posted: Tuesday 18 August 2015 14:31
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.
Re: Measure device consumption cheap way?
Posted: Thursday 20 August 2015 21:14
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
Re: Measure device consumption cheap way?
Posted: Saturday 17 October 2015 16:24
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?
Re: Measure device consumption cheap way?
Posted: Monday 18 January 2016 11:11
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.
Re: Measure device consumption cheap way?
Posted: Monday 18 January 2016 11:24
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.
Re: Measure device consumption cheap way?
Posted: Monday 18 January 2016 12:36
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?
Re: Measure device consumption cheap way?
Posted: Monday 18 January 2016 12:57
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....
Re: Measure device consumption cheap way?
Posted: Monday 18 January 2016 13:11
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?