rorr73 / LifeSOSpy_MQTT

MQTT Client to communicate with LifeSOS alarm systems.
MIT License
5 stars 2 forks source link

Auto Reset Interval in config results in PIR sensor not being auto reset #13

Closed rorr73 closed 5 years ago

rorr73 commented 5 years ago

After a PIR sensor is triggered, and an auto reset interval has been explicitly defined in the configuration file, the app will not automatically reset the motion sensor value. The following error is logged when it attempts to return to the 'no motion' state:

2019-10-18 08:00:42 ERROR (MainThread) [lifesospy.device] Unhandled exception in on_event callback
Traceback (most recent call last):
  File "/usr/local/lib/python3.5/dist-packages/lifesospy/device.py", line 231, in _handle_device_event
    self._on_event(self, device_event.event_code)
  File "/usr/local/lib/python3.5/dist-packages/lifesospy_mqtt/translator.py", line 461, in _device_on_event
    self._auto_reset, device.device_id)
  File "/usr/lib/python3.5/asyncio/base_events.py", line 541, in call_later
    timer = self.call_at(self.time() + delay, callback, *args)
TypeError: unsupported operand type(s) for +: 'float' and 'str'

Tracked the issue down to a change in previous release 0.11.4; by changing yaml.load to use the BaseLoader, it no longer deserializes the non-string values correctly. The 'auto_reset_interval' setting (defined as an 'int') is loaded only as a string, which results in the error when the app attempts to perform arithmetic on the string value.

rorr73 commented 5 years ago

Replaced BaseLoader with SafeLoader - appears to be deserializing auto_reset_interval correctly now.