mpepping / solarman-mqtt

Send Solarman Smart PV inverter metrics to MQTT
Apache License 2.0
61 stars 21 forks source link

HA configuration.yaml example is using deprecated features #18

Closed mhoogenbosch closed 2 years ago

mhoogenbosch commented 2 years ago

Starting yesterday I have been trying to integrate my solar panels into HA. I'm struggling a bit with getting everything working.

I had to create another template sensor:

template:

  - sensor:
      - name: SoFar_Solar_Power_Generation
        unit_of_measurement: 'Wh'
        state: >
          {{ (states("sensor.solarmanpv_station_generationPower") | float) | round(2) }}
        device_class: energy
        state_class: measurement
        attributes:
          last_reset: '1970-01-01T00:00:00+00:00'

To get it to be able to use in the energy tab.

Together with this I had to comment the entity_id's because these are deprecated. Don't exactly know what they do.

mpepping commented 2 years ago

Nice! The device_class, state_class and attributes are definitely required to use these sensors in the Energy view. Just for comparison, this is the sensor I use for that purpose:

template:
  - sensor:
      - name: "Solarman energy daily"
        unit_of_measurement: 'kWh'
        state: "{{ state_attr('sensor.solarmanpv_inverter', 'Daily_Production_(Active)') }}"
        device_class: energy
        state_class: measurement
        attributes:
          last_reset: '1970-01-01T00:00:00+00:00'

Thanks for the heads-up on the entity_id's. The README will be updated.