mirror of
https://github.com/alexhopeoconnor/SunGather.git
synced 2026-10-04 02:48:12 +10:00
Fix Home Assistant Autodiscovery
This commit is contained in:
@@ -46,7 +46,7 @@ class export_mqtt(object):
|
||||
|
||||
for ha_topic in self.ha_topics:
|
||||
msg = discovery_payload.format( ha_topic.get('name'), "inverter_" + ha_topic.get('name').lower().replace(' ','_'), self.sensor_topic, self.sensor_topic, ha_topic.get('unit'), ha_topic.get('dev_class'), ha_topic.get('state_class'), ha_topic.get('register'), inverter.get('device_type_code', 'unknown').replace('.',''))
|
||||
result = self.mqtt_client.publish(discovery_topic.format(ha_topic.get('name').lower().replace(' ','_')), msg)
|
||||
result = self.mqtt_client.publish(discovery_topic.format(ha_topic.get('name').lower().replace(' ','_')), msg, retain=True)
|
||||
result.wait_for_publish()
|
||||
self.ha_discovery = False
|
||||
|
||||
|
||||
@@ -311,7 +311,7 @@ registers:
|
||||
# address: 5037
|
||||
# datatype: "U16"
|
||||
- name: "work_state_1" # See Appendix 1
|
||||
level: 2
|
||||
level: 1
|
||||
address: 5038
|
||||
datatype: "U16"
|
||||
datarange:
|
||||
|
||||
@@ -242,7 +242,7 @@ def scrape_inverter():
|
||||
# to help with graphing.
|
||||
try:
|
||||
if inverter.get('start_stop'):
|
||||
if inverter.get('start_stop') == 'Start':
|
||||
if inverter.get('start_stop', False) == 'Start' and inverter.get('work_state_1', False) == 'Run':
|
||||
inverter["is_running"] = True
|
||||
else:
|
||||
if inverter.get('start_stop') == 'Stop':
|
||||
|
||||
Reference in New Issue
Block a user