klaasnicolaas / home-assistant-glow

⚡ The power of energy measurements in your house
https://glow-energy.io/
MIT License
1.05k stars 157 forks source link

Calculating Remaining Units #19

Open jacauc opened 3 years ago

jacauc commented 3 years ago

I love this integration. Got it working quite well with an LDR since I don't have access to photodiode.

I have a prepaid meter where I load e.g 500 units at the beginning of the month. Since I can look on the display to see there are currently 537.1 units left, I'm looking for tips on how I can manually enter this into HA and then expose/calculate the remaining units in HA (since glow is able to tell me how many times the light blinked - i.e. how many units I have consumed.)

Any nifty ways for achieving this in HA?

fourtrax01 commented 3 years ago

I would use the monthly utility meter on your sensor data from your glow it will reset every month but will not reset your overall consumption from your glow. It will count up but with a quick calculation you should be able to get it to count down. either way you will be able to see how much you have used and it automatically resets every month.

iamvlanone commented 2 years ago

I am doing this with a template sensor in HA. I have a input-number helper for the starting units, where I will enter the starting units and then subtract the total usage from that. I still need to decide if I want to reset my total usage everytime I enter the starting units for the month, but got it working in principle.

image

template sensor config:

iamjb commented 2 years ago

@iamvlanone

template sensor config:

I am trying to get this to work. I have created the input-number helper, but i am a little lost as to where the template sensor config goes. I get errors when i put it in config.yaml

Would you mind giving me a little more insight?

iamvlanone commented 2 years ago

Did you indent your config correctly? I could not figure out how to paste the code with indents.

My config is split into different files. You can test the value_template using the template option in developer tools. Do you mind sharing your code and include the sensor names for the input_number and the energy value. I will see if I can assist as much of my coding is by trial and error

input_number.yaml starting_kwh_units: name: Starting kWh Units mode: box min: 0.00 max: 1000.00 unit_of_measurement: kWh step: 0.01

sensors.yaml platform: template sensors: kwh_available: value_template: '{{ ((states.input_number.starting_kwh_units.state | float | round(2))) - ((states.sensor.power_total_energy.state | float | round(2))) }} ' friendly_name: Available kWh Units unit_of_measurement: kWh

Available KWh config.txt

iamjb commented 2 years ago

Sorry for the late reply @iamvlanone . Thank you for your reply. Now that I had some time i had a look at the log file and noticed that there was an error on the template sensor where your sensor was: states.sensor.power_total_energy.state Mine was: states.sensor.house_total_energy.state

Now it seems to be working perfectly.

Thank you! JB