mirror of
https://github.com/lumapu/ahoy.git
synced 2025-07-04 10:07:15 +02:00
fixed mqtt client usage with sun timings; fixed null pointer when sun times are disabled
This commit is contained in:
parent
bf7b122cea
commit
ba7d3e8b8b
1 changed files with 5 additions and 4 deletions
|
@ -103,10 +103,11 @@ class SunsetHandler:
|
||||||
def sun_status2mqtt(self, dtu_ser, dtu_name):
|
def sun_status2mqtt(self, dtu_ser, dtu_name):
|
||||||
if not mqtt_client or not self.suntimes:
|
if not mqtt_client or not self.suntimes:
|
||||||
return
|
return
|
||||||
local_sunrise = self.suntimes.riselocal(datetime.now()).strftime("%d.%m.%YT%H:%M")
|
|
||||||
local_sunset = self.suntimes.setlocal(datetime.now()).strftime("%d.%m.%YT%H:%M")
|
|
||||||
local_zone = self.suntimes.setlocal(datetime.now()).tzinfo._key
|
|
||||||
if self.suntimes:
|
if self.suntimes:
|
||||||
|
local_sunrise = self.suntimes.riselocal(datetime.now()).strftime("%d.%m.%YT%H:%M")
|
||||||
|
local_sunset = self.suntimes.setlocal(datetime.now()).strftime("%d.%m.%YT%H:%M")
|
||||||
|
local_zone = self.suntimes.setlocal(datetime.now()).tzinfo._key
|
||||||
mqtt_client.info2mqtt({'topic' : f'{dtu_name}/{dtu_ser}'}, \
|
mqtt_client.info2mqtt({'topic' : f'{dtu_name}/{dtu_ser}'}, \
|
||||||
{'dis_night_comm' : 'True', \
|
{'dis_night_comm' : 'True', \
|
||||||
'local_sunrise' : local_sunrise, \
|
'local_sunrise' : local_sunrise, \
|
||||||
|
@ -409,7 +410,7 @@ if __name__ == '__main__':
|
||||||
str(g_inverter_ser),
|
str(g_inverter_ser),
|
||||||
g_inverter.get('mqtt', {}).get('topic', f'hoymiles/{g_inverter_ser}') + '/command'
|
g_inverter.get('mqtt', {}).get('topic', f'hoymiles/{g_inverter_ser}') + '/command'
|
||||||
)
|
)
|
||||||
mqtt_client.subscribe(topic_item[1])
|
mqtt_client.client.subscribe(topic_item[1])
|
||||||
mqtt_command_topic_subs.append(topic_item)
|
mqtt_command_topic_subs.append(topic_item)
|
||||||
|
|
||||||
# start main-loop
|
# start main-loop
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue