Skip to content

Commit

Permalink
move message formats to docstring and bump to 0.2.11
Browse files Browse the repository at this point in the history
  • Loading branch information
barbudor committed Jun 20, 2021
1 parent 078bbdb commit ece97e1
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 17 deletions.
22 changes: 11 additions & 11 deletions GUI/Timers.py
Original file line number Diff line number Diff line change
Expand Up @@ -222,15 +222,22 @@ def saveTimer(self):

@pyqtSlot(str, str)
def parseMessage(self, topic, msg):
"""
Tasmota < 9.4.0.5 : There are a total of 4 messages in reply to `Timers` command:
{"Timers": "ON" }
{"Timers1" : {"Timer1":{"Enable":0,"Mode":0,"Time":"00:00","Window":0,"Days":"0000000","Repeat":0,"Action":0}, ....
...
{"Timers4" : {"Timer13":{"Enable":0,"Mode":0,"Time":"00:00","Window":0,"Days":"0000000","Repeat":0,"Action":0}, ....
Tasmota >= 9.4.0.5 : There is only 1 message that covers all
{ "Timers": "ON", "Timer1":{"Enable":0,"Mode":0,"Time":"00:00","Window":0,"Days":"0000000","Repeat":0,"Action":0}, ....
"""
if self.device.matches(topic):
if self.device.reply == "RESULT" or self.device.reply == "TIMERS":
try:
payload = loads(msg)
all = list(payload)
first = all[0]
#logging.debug("TIMERS payload: %s", payload)
#logging.debug("TIMERS list: %s", list(payload))
#logging.debug("TIMERS first : %s", first)

except JSONDecodeError as e:
error = "Timer loading error", "Can't load the timer from device.\n{}".format(e)
Expand All @@ -241,18 +248,11 @@ def parseMessage(self, topic, msg):
if first == 'Timers':
self.gbTimers.setChecked(payload[first] == "ON")

# Tasmota >= 9.4.0.5 : There is only 1 message that covers all
# { "Timers": "ON", "Timer1":{"Enable":0,"Mode":0,"Time":"00:00","Window":0,"Days":"0000000","Repeat":0,"Action":0}, ....
if len(all) > 1: # If first is "Timers" but there are more, then it is Tasmota >= 9.4.0.5
if len(all) > 1:
payload.pop("Timers")
self.timers.update(payload)
self.loadTimer(self.cbTimer.currentText())

# Tasmota < 9.4.0.5 : There are a total of 4 messages in reply to `Timers` command:
# {"Timers": "ON" }
# {"Timers1" : {"Timer1":{"Enable":0,"Mode":0,"Time":"00:00","Window":0,"Days":"0000000","Repeat":0,"Action":0}, ....
# ...
# {"Timers4" : {"Timer13":{"Enable":0,"Mode":0,"Time":"00:00","Window":0,"Days":"0000000","Repeat":0,"Action":0}, ....
elif first.startswith('Timers'):
self.timers.update(payload[first])
if first == 'Timers4':
Expand Down
4 changes: 2 additions & 2 deletions tdmgr.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@

# TODO: rework device export

__version__ = "0.2.10"
__version__ = "0.2.11"
__tasmota_minimum__ = "6.6.0.17"


Expand Down Expand Up @@ -88,7 +88,7 @@ def __init__(self, *args, **kwargs):
for k in self.devices.childKeys():
device.history.append(self.devices.value(k))
self.devices.endGroup()

self.devices.endGroup()

self.device_model = TasmotaDevicesModel(self.env)
Expand Down
2 changes: 1 addition & 1 deletion tdmgr.spec
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ exe = EXE(pyz,
a.zipfiles,
a.datas,
[],
name='tdmgr_0.2.10',
name='tdmgr_0.2.11',
debug=False,
bootloader_ignore_signals=False,
strip=False,
Expand Down
2 changes: 1 addition & 1 deletion tdmgr32.spec
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ exe = EXE(pyz,
a.zipfiles,
a.datas,
[],
name='tdmgr_0.2.10_x86',
name='tdmgr_0.2.11_x86',
debug=False,
bootloader_ignore_signals=False,
strip=False,
Expand Down
4 changes: 2 additions & 2 deletions tdmgr_mac.spec
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@ exe = EXE(pyz,
a.binaries,
a.zipfiles,
a.datas,
name='tdmgr_0.2.10',
name='tdmgr_0.2.11',
debug=False,
strip=False,
upx=True,
console=False , icon='tdmgr.icns')
app = BUNDLE(exe,
name='tdmgr_0.2.10.app',
name='tdmgr_0.2.11.app',
icon='tdmgr.icns',
bundle_identifier='com.tasmota.tdmgr')

0 comments on commit ece97e1

Please sign in to comment.