This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm that you accept these cookies being set.

Calculated montly kwh from relay status
#1
Hi.

I want to make a simple and cost efficiant way to have an montly overview of kwh for usage of underfloor heatingcables.
How much kW the heatingcable is delivering is easily measured with instruments and the measured kW is accurate enough for most uses.

My plan is to count the time while the relay for the heating cable is active, and multiply this time with the cables kW for every hour of active relay.
Then i want to extract the kWh for each previous month, and add it to a trend.
This will when time goes by show the last 2 years of heating cable kWh usage.

Does anybody have a script with something similar that can help me on my way?

BR
Kai-Roger
BR
Kai-Roger
Reply
#2
You could use something like below. This is for event-based script connected to the status of your heating load. It automatically generates data of your consumption in kWh. You can also add the cost parameter to have it in same place.

All current calculations are available in storage. Value is refreshed on every change or update of status.
Code:
123456789101112131415161718192021222324252627282930313233343536373839
// Event based script // Connect with load status status = event.getvalue() now = os.time() -- power in kW power = 2 -- price per kWh price = 0.5 currency = '$' energyCounter = storage.get('energy_counter', {price = price, currency = currency, consumers = {}}) -- load should have "status", "power", "lastChange", "counter" load = energyCounter.consumers['heating-cables'] if not load then     load = {status = status, power = 2000, lastChange = now, counter = 0} end function updateConsumption()     -- consumed kWh value of last not calculated period     local delta = (now - load.lastChange) / 3600 * load.power          if load.status then         -- add current consumption to the counter         load.counter = load.counter + delta         load.status = status         load.lastChange = now     end          energyCounter.consumers['heating-cables'] = load     storage.set('energy_counter', energyCounter) end updateConsumption()


And below example is how to use data in your monthly script:
Code:
1234567
energyCounter = storage.get('energy_counter', {price = price, currency = currency, consumers = {}}) -- load should have "status", "power", "lastChange", "counter" load = energyCounter.consumers['heating-cables'] counter = load.counter // in kWh log(counter)
Done is better than perfect
Reply
#3
Thanks. I will try to understand the code better tomorrow (:
Reply


Forum Jump: