growatt2mqtt icon indicating copy to clipboard operation
growatt2mqtt copied to clipboard

Publish Home Assistant auto-discovery sensors

Open That-Dude opened this issue 2 years ago • 4 comments

First of all I just want to say thank you for this project. I've got it working with my Growatt inverter and learned so much in the process.

I use Home Assistant and the trickiest part was figuring out how to import the values, I achieved this by adding MQTT sensors to my configuration.yaml but it's a hacky solution.

sensor:
- platform: mqtt
  name: 'Growatt Solarpower'
  state_topic: 'growatt/data'
  value_template: '{{ value_json.solarpower }}'
  unit_of_measurement: 'W'
  device_class: power

- platform: mqtt
  name: 'Growatt Enery Today'
  state_topic: 'growatt/data'
  value_template: '{{ value_json.energytoday }}'
  unit_of_measurement: 'kWh'
  device_class: energy

I was wondering if you might add the functionality to publish the sensors from your sketch into the `homeassistant/sensor/growatt' topic, as this would allow Home Assistant auto-discovery:

I borrowed this example from another solution:

Topic :homeassistant/sensor/inverter_1_pv_power/config

{"device":{"ids":["sa_inverter"],"mdl":"Growatt MIN/MIC","mf":"Growatt","name":"Growatt MIN/MIC"},"device_class":"power","name":"PV power","state_topic":"solar/inverter_1/pv_power/state","uniq_id":"inverter_1_pv_power","unit_of_measurement":"W"}

That-Dude avatar Aug 14 '22 16:08 That-Dude

Hmmm, I have seen these homeassisant topic in my MQTT server, but never really paid much attention to them. But it does not look too complicated. But it will be a hell of a large big configuration message considering the high number of fields. I am in a middle of a large project, but I have some tidy up work to do here, so I think I will come back to this somewhere during the fall and add the homeassistant part as well.

nygma2004 avatar Aug 14 '22 20:08 nygma2004

ok that sounds great, I'm looking forward to seeing the results.

I'm super pleased with your sketch, it's been working flawlessly for a week now.

That-Dude avatar Aug 16 '22 10:08 That-Dude

For large configurations yaml it's easier to manage.

One advantage of discovery, it's create a device on HA

nikito7 avatar Sep 13 '22 05:09 nikito7

https://github.com/nikito7/easyhan/blob/dev/growatt/pv1-discovery.txt

nikito7 avatar Jan 26 '23 14:01 nikito7