Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rename Device for Home Assistant #208

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions SunGather/config-example.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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: "Sungrow new PV" # [Optional] This is the Name shown in Home Assistant
ha_sensors:
- name: "Daily Generation"
sensor_type: sensor
Expand Down
5 changes: 3 additions & 2 deletions SunGather/exports/mqtt.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [{}]
Expand Down Expand Up @@ -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 = {}
Expand Down