GithubHelp home page GithubHelp logo

Power to kWh about mhi-ac-ctrl-esphome HOT 5 CLOSED

ginkage avatar ginkage commented on August 22, 2024
Power to kWh

from mhi-ac-ctrl-esphome.

Comments (5)

sanderlv avatar sanderlv commented on August 22, 2024 1

Got it like this:

sensor:
  - platform: custom
    lambda: |-
      return ((MhiAcCtrl*)id(${deviceid}))->get_sensors();
    # Sensor names in HA, you can change these if you want
    # Don't delete them or change their position in the list
    sensors:
      - name: ${devicename} - Error Code
      - name: ${devicename} - Outdoor Temperature
      - name: ${devicename} - Return Air Temperature
      - name: ${devicename} - Outdoor Unit Fan Speed
      - name: ${devicename} - Indoor Unit Fan Speed
      - name: ${devicename} - Current Amperage
        id: ampere
      - name: ${devicename} - Compressor Frequency
      - name: ${devicename} - Indoor Unit Total Run Time
      - name: ${devicename} - Compressor Total Run Time
    
  - platform: template
    name: ${devicename} - Current Power
    id: "power"
    unit_of_measurement: W
    lambda: return id(ampere).state * 230;

  - platform: total_daily_energy
    name: "${devicename} - Dagverbruik"
    power_id: "power"
    filters:
        # Multiplication factor from W to kW is 0.001
        - multiply: 0.001
        - throttle: 300s
    unit_of_measurement: kWh
    icon: mdi:clock-alert

image

It does it for now. To get an "idea". Later I will import the actual voltage but for now this is fine.

thanks!

from mhi-ac-ctrl-esphome.

arpiecodes avatar arpiecodes commented on August 22, 2024

That 'power' attribute is not energy (Kwh like you're after) but current. So amperage. What you want to do is technically impossible. You could however set up some complex formula that also takes into consideration the actual voltage and then calculate the watts, poll that value and take the average to sum up as Kwh, but it's just not going to be anywhere near reliable this way. Better to just insert a CT clamp/Kwh meter between the unit and your mains power.

from mhi-ac-ctrl-esphome.

sanderlv avatar sanderlv commented on August 22, 2024

Thank you, and yes, stupid A is not W, I will make that P=U*I :-).

But apart from that, will the "id:power" in esphome provide me the value? to be usable in templates etc.?
And why is is even called "power" if it Amps :-), shouldnt it be "Amperage"?

from mhi-ac-ctrl-esphome.

arpiecodes avatar arpiecodes commented on August 22, 2024

Very valid point. I guess I doubted there a bit when I refactored the sensor name(s)/id(s). The library we use calls it 'power' internally, I guess I made 'current power' of that just to keep a reference for the people that used the library natively before.

But yes, current (so not current power) would be the more accurate label/sensor ID.

EDIT: sorry, missed your last question. You could do something like this in HA automations by using a template (value_template or payload_value for example). Do not forget to replace sensor.mhi_current_power with the unique sensor id from the mhi unit based on your own yaml contents and sensor.energy_meter_volts with a recent volt reading of the phase the mhi unit is on from your home energy meter (or use a static value like 230 but it will not be very accurate).

{{ states('sensor.mhi_current_power') | int * states('sensor.energy_meter_volts') | int  }}

from mhi-ac-ctrl-esphome.

arpiecodes avatar arpiecodes commented on August 22, 2024

Actually, someone already posted a pretty complete example here as well; #21 (comment). You can also do it in ESPHome (like you are trying to do), but that requires polling the volt value from your smart meter into the ESP. Which is kind of cumbersome to say the least. If you just want to use a static volt reading/number, doing the calculation in the ESP is absolutely fine.

from mhi-ac-ctrl-esphome.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.