Creating/modifying entity parameters to make them visible in the "energy" tab

hello!

I managed to download data from my steca inverter via modbus tcp. Here is the configuration:
modbus:

  • name: modbus_tcp
    type: tcp
    host: 192.168.2.43
    port: 1502
    timeout: 10

sensors:

  • name: “Moc_AC”
    slave: 71
    address: 40084
    data_type: uint16
    scale: 0.001
    precision: 3
    scan_interval: 10
    unit_of_measurement: “kW”

The sensor currently shows the energy sent to the grid by the inverter. I would like this statistic to be added to the “energy” tab but I can’t find it there, I know it has to meet certain criteria.
I asked chat gpt and he said that the solution would be to create a new entity based on this and add the necessary values ​​such as device_class, state_class. Can I count on your help with this? I tried to deal with it but the entity was not visible in the tab.

It might also be worth changing the unit “kw” to “kWh” - apparently it is possible directly in the yaml file but I was unable to do it.

Please advise.

I would like to add the electricity consumption of the entire house and the production from the photovoltaic inverter and be able to check the balance.
The easiest way would be to add the necessary parameters directly to the current modbus code but I don’t know if this is possible

You have to specify a device_class: energy for your sensor if it actually is an energy sensor (kWh).

If it’s actually a power sensor, use device_class: power and add a Rieman integration to create an energy sensor.