Measure kWh used in 1 minute.

Discussions about RaZberry - Z-Wave board for Raspberry computer
Rappo
Posts: 26
Joined: 01 Dec 2014 15:25

Re: Measure kWh used in 1 minute.

Post by Rappo »

I'm not using javascript, but I poll the JSON interface and read the 'current power' number instead of the 'kwh used'.
How exactly are you doing this? You are using the Home Automation right?

The Z Wave Expert UI reports a resolution of 0.001kW, and the Fibaro reports 0.01kW as far as I remember. I do not have access to the Fibaro right now.

I am very interested in seeing your setup on the tea kettle...
Rappo
Posts: 26
Joined: 01 Dec 2014 15:25

Re: Measure kWh used in 1 minute.

Post by Rappo »

If I could reset the kWh every 60 seconds I guess that would help. But I am not sure how to do this.
I managed to reset the kWh every 60 seconds setting up at http device with this url http://IP:8083/JS/Run/zway.devices[4].i ... [50].Reset()
Rappo
Posts: 26
Joined: 01 Dec 2014 15:25

Re: Measure kWh used in 1 minute.

Post by Rappo »

Mirar: But I am still interested in your setup ;)
Mirar
Posts: 113
Joined: 19 Oct 2014 16:54
Location: Stockholm

Re: Measure kWh used in 1 minute.

Post by Mirar »

Rappo wrote:Mirar: But I am still interested in your setup ;)
I call the JSON interface for updates,

http://172.16.0.72:8083/ZWaveAPI/Data/0

where 172.16.0.72 is the IP number to my razberry, and 0 is the unix timestamp I want the updates since. The answer is a fairly easily parse-able JSON. It's basically Java-object-formatted same thing as you would use in home automation, so you should be able to use the same principles.

My meters come in as node.instance.50.2 with type "Electric "[sic][2] and unit "W".

The algoritm is very simple:
* measure the time when you read the value (probably .last or something?), save this as old_time
* on a new reading (not the first one), power usage will be (time_this_reading - time_previous_reading) * current value [1]

An example:
* reading 1, W_1 = 50W (watt), T_1 = 10000s (seconds)
* reading 2, W_2 = 2000W, T_2 = 10030s
* reading 3, W_3 = 400W, T_3 = 10100s

Between reading 1 and reading 2, the power usage is (10030-10000)*2000 Ws = 30*2000Ws = 30*2000/3600/1000kWh = 0.0167kWh.
Between reading 2 and reading 3, the power usage is (10100-10030)*400 Ws = 70*400Ws = 70*200/3600/1000kWh = 0.0038kWh.

Over longer time (if you don't reset the meter), you can correlate your number with the kWh-meter.

I don't know if your unit reports watt as well. Maybe it doesn't, then this is useless. :)


([1] not exactly true, since you don't know what happened between previous reading and this reading, but close enough. You could also do average between the readings, but it will amount to the same sum eventually.
[2] is the space in "Electric " a z-wave.me bug or a bug in the unit?)

edit: As for using the JSON interface, it's for two reasons: 1) because I want to script in another language (Pike in my case), and 2) separation of automation and network - I use telldus (433MHz) as well as apcupsd and other scripted sources for handling things like receivers (Yamaha webapi).
Rappo
Posts: 26
Joined: 01 Dec 2014 15:25

Re: Measure kWh used in 1 minute.

Post by Rappo »

Thank you so much for a detailed description. My unit reports watt ;)
Post Reply