From c32146400684cc17d352272e0dd90bec04b27e0e Mon Sep 17 00:00:00 2001 From: "ESPL_001\\braunj" Date: Mon, 11 Nov 2024 13:05:47 +0100 Subject: [PATCH 1/2] Add entry for device name for Home Assistant --- SunGather/config-example.yaml | 1 + SunGather/exports/mqtt.py | 5 +++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/SunGather/config-example.yaml b/SunGather/config-example.yaml index 2484180..351206c 100644 --- a/SunGather/config-example.yaml +++ b/SunGather/config-example.yaml @@ -67,6 +67,7 @@ exports: # password: # [Optional] Password is MQTT server requires it # client_id: # [Optional] Client id for mqtt connection. Defaults to Serial Number. homeassistant: True + # ha_device_name: "new PV" # [Optional] This is the Name shown in Home Assistant ha_sensors: - name: "Daily Generation" sensor_type: sensor diff --git a/SunGather/exports/mqtt.py b/SunGather/exports/mqtt.py index 8d5c44e..3e11394 100644 --- a/SunGather/exports/mqtt.py +++ b/SunGather/exports/mqtt.py @@ -23,7 +23,8 @@ def configure(self, config, inverter): 'topic': config.get('topic', f"SunGather/{self.serial_number}"), 'username': config.get('username', None), 'password': config.get('password',None), - 'homeassistant': config.get('homeassistant',False) + 'homeassistant': config.get('homeassistant',False), + 'ha_device_name': config.get('ha_device_name',self.model) } self.ha_sensors = [{}] @@ -93,7 +94,7 @@ def publish(self, inverter): if self.mqtt_config['homeassistant'] and not self.ha_discovery_published: # Build Device, this will be the same for every message - ha_device = { "name":f"Sungrow {self.model}", "manufacturer":"Sungrow", "model":self.model, "identifiers":self.serial_number, "via_device": "SunGather", "connections":[["address", inverter.getHost() ]]} + ha_device = { "name":f"{self.mqtt_config['ha_device_name']}", "manufacturer":"Sungrow", "model":self.model, "identifiers":self.serial_number, "via_device": "SunGather", "connections":[["address", inverter.getHost() ]]} for ha_sensor in self.ha_sensors: config_msg = {} From 880c6bbd904bc0126b5252321012da84995ffdd2 Mon Sep 17 00:00:00 2001 From: "ESPL_001\\braunj" Date: Mon, 11 Nov 2024 13:10:14 +0100 Subject: [PATCH 2/2] Consistent view in config example --- SunGather/config-example.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SunGather/config-example.yaml b/SunGather/config-example.yaml index 351206c..ee88f93 100644 --- a/SunGather/config-example.yaml +++ b/SunGather/config-example.yaml @@ -67,7 +67,7 @@ exports: # password: # [Optional] Password is MQTT server requires it # client_id: # [Optional] Client id for mqtt connection. Defaults to Serial Number. homeassistant: True - # ha_device_name: "new PV" # [Optional] This is the Name shown in Home Assistant + # ha_device_name: "Sungrow new PV" # [Optional] This is the Name shown in Home Assistant ha_sensors: - name: "Daily Generation" sensor_type: sensor