Energy Management in Home Assistant

I use DBeaver (from https://dbeaver.io) on my Windows PC to connect back to HA’s mariadb and it is magic (which means no CLI required).

  1. Configure your mariadb addon to expose TCP 3306
  2. Restart
  3. Point DBeaver to: [HA IP Address]:3306

DBeaver is completely free and allows direct in table edits so you can literally overtype data and then save it so for little tweaks you don’t need to write SQL - just find it, edit it, commit it. Handy if you need to tidy up a few things.

CP.

2 Likes

Yes, it’s good, multiplatform. Also HeidiSQL, free too. Only for Windows, thought.

1 Like

I’m pulling my hair out with this one. I have a serial sensor that gets parsed to show me instant watts. Which works fine.

image

I used this yaml to turn that into a kWh meter.

  - platform: integration
    source: sensor.powerw
    name: House Energy kWh
    unit_prefix: k
    unit_time: h
    round: 2

And that seems to work a treat:

image

You would think that it would just show up in the list and I’d be off to the races with energy right? Well it’s not in the list for some reason. And I can’t figure out why.

Try:

  - platform: integration
    source: sensor.powerw
    name: House Energy kWh
    unit_prefix: k
    unit_time: h
    round: 2
    method: left

Show the attributes. You are most likely missing a required one and will have to customise it in yaml.

This?

Yes you are missing device_class: energy

Use manual customisation to fix Customizing entities - Home Assistant

Thank you very much for this detailed answer!
I came up with another idea which is working at the moment:

    - unique_id: total_solar_producing
      name: 'total_solar_producing'
      device_class: energy
      state_class: total_increasing
      unit_of_measurement: "kWh"
      state: >
        {% if states('sensor.pv_gen_meter')|float != 0.0 and states('sensor.pv_gen_meter_2')|float != 0.0 %}
          {{ states('sensor.pv_gen_meter')|float + states('sensor.pv_gen_meter_2')|float}}
        {% endif %}

Not really sure if this solves my problem but for now I haven’t got a peak or anything else. If I do so again I will definetly try your solution!

I’ve tried that but I get this error when I do it:

Invalid config for [sensor.integration]: [device_class] is an invalid option for [sensor.integration]. Check: sensor.integration->device_class. (See ?, line ?).

You have to edit it in customize.yaml not in sensor.yaml

You need to show your yaml (formatted) and tell us exactly which file it is in for us to help. It looks like you have modified the wrong file or indentation is wrong.

This is my /config/configuration.yaml


# Configure a default setup of Home Assistant (frontend, api, etc)
default_config:

# Text to speech
tts:
  - platform: google_translate

group: !include groups.yaml
automation: !include automations.yaml
script: !include scripts.yaml
scene: !include scenes.yaml
no_ip:
  domain: ***
  username: ***
  password: ***
sensor:
  - platform: serial
    serial_port: /dev/ttyACM0
    baudrate: 38400
  - platform: template
    sensors:
      powerw:
        friendly_name: 'House Energy Instant'
        unit_of_measurement: "W"
        value_template: "{{ states.sensor.serial_sensor.state.split(',')[2].split(':')[1]|regex_replace(find='}', replace='', ignorecase=False)}}"
  - platform: integration
    source: sensor.powerw
    device_class: energy
    name: House Energy kWh
    unit_prefix: k
    unit_time: h
    round: 2

You can’t add the device class there. Look at the manual customisation link I posted earlier

Also for completeness I think you should have device_class: power in your setup for powerw

Adding stuff to the energy dashboard never works on the first try. It’s always a edit/customize/reload/restart/Ctrl+F5 struggle back and forth. :sweat_smile:

I now copy paste this block for every sensor into customize.yaml:

sensor.house_energy_kwh:
  device_class: energy
  unit_of_measurement: kWh
  state_class: total_increasing
  last_reset: '2000-01-01T00:00:00'

state_class could also be “total” or “measurement”. Never fully understood it. Trial and error if one of them works for you

I read this again and I don’t see it saying about putting that information in a different file than /config/configuration.yaml.

Am I blind? Can you screenshot the piece of information that I’m missing?

@allocater2 showed an example of what to put in customization.yaml which is the same as what could go in configuration.yaml

homeassistant:
  name: Home
  unit_system: metric
  # etc

  customize:
    # Add an entry for each entity that you want to overwrite.
    sensor.house_energy_kwh:
      device_class: energy
     

Ok I added that to the end of my /config/configuration.yaml

image

I must be missing something fundamental here.

Look at your indenting. Make it exactly the same as the example. It must be two spaces in under the homeassistant section.

Hi, is there any way to add fixed monthly prices to spot hourly prices per kWh? At the moment, it only shows me the price of purchased clean electricity.
It is not necessary for it to appear in the energy panel, but I cannot find the entity for the month in which the total costs are, so that I can add other items per kWh and monthly and view the calculation elsewhere.
Thank you