@@ -39,9 +39,10 @@ def _handle_xml(cls, _event_bus: EventBus, _xml: Element) -> HandlingResult:
3939
4040 b"<ctl td='CleanSt' a='21' s='1743945874' l='1595' t='' type='auto'/>"
4141
42+ We currently ignore this message as we prefer to use CleanReport
4243 :return: A message response
4344 """
44- return HandlingResult .analyse ()
45+ return HandlingResult .success ()
4546
4647
4748class CleanReport (XmlMessage ):
@@ -93,29 +94,34 @@ def _handle_xml(cls, event_bus: EventBus, xml: Element) -> HandlingResult:
9394 :return: A message response
9495 """
9596 event_reported = False
96- if act := xml .attrib .get ("act" ):
97+ if (
98+ (act := xml .attrib .get ("act" )) is not None
99+ and (last := xml .attrib .get ("last" )) is not None
100+ and (area := xml .attrib .get ("area" )) is not None
101+ ):
97102 clean_session = xml .attrib .get ("cs" )
98- last = xml .attrib .get ("last" )
99- area = xml .attrib .get ("area" )
100- type = xml .attrib .get ("type" )
103+ clean_type = xml .attrib .get ("type" )
104+
101105 clean_action = CleanAction .from_xml (act )
102106 if clean_action == CleanAction .STOP :
103- event_bus .notify (StatsEvent (area = area , time = last , type = type ))
107+ event_bus .notify (
108+ StatsEvent (area = int (area ), time = int (last ), type = clean_type )
109+ )
104110 event_reported = True
105111 if clean_session :
106112 if clean_action == CleanAction .STOP :
107113 job_status = CleanJobStatus .FINISHED
108114 elif clean_action == CleanAction .START :
109115 job_status = CleanJobStatus .CLEANING
110116 elif clean_action == CleanAction .PAUSE :
111- job_status = CleanJobStatus .PAUSED
117+ job_status = CleanJobStatus .MANUALLY_STOPPED
112118 else :
113119 job_status = CleanJobStatus .NO_STATUS
114120 event_bus .notify (
115121 ReportStatsEvent (
116- area = area ,
117- time = last ,
118- type = type ,
122+ area = int ( area ) ,
123+ time = int ( last ) ,
124+ type = clean_type ,
119125 cleaning_id = clean_session ,
120126 status = job_status ,
121127 content = [],
0 commit comments