2020-03-08 23:37:57 +01:00
|
|
|
from typing import Optional
|
|
|
|
|
2018-04-29 23:51:53 +02:00
|
|
|
from platypush.message.event import Event
|
|
|
|
|
|
|
|
|
|
|
|
class SensorDataChangeEvent(Event):
|
2018-07-09 22:37:54 +02:00
|
|
|
"""
|
|
|
|
Event triggered when a sensor has new data
|
|
|
|
"""
|
|
|
|
|
2020-03-08 23:37:57 +01:00
|
|
|
def __init__(self, data, source: Optional[str] = None, *args, **kwargs):
|
2018-07-09 22:37:54 +02:00
|
|
|
"""
|
|
|
|
:param data: Sensor data
|
|
|
|
"""
|
|
|
|
|
2020-03-08 23:37:57 +01:00
|
|
|
super().__init__(data=data, source=source, *args, **kwargs)
|
2018-06-11 21:07:54 +02:00
|
|
|
self.data = data
|
2020-03-08 23:37:57 +01:00
|
|
|
self.source = source
|
2018-06-11 21:07:54 +02:00
|
|
|
|
|
|
|
|
|
|
|
class SensorDataAboveThresholdEvent(Event):
|
2018-07-09 22:37:54 +02:00
|
|
|
"""
|
|
|
|
Event triggered when a sensor's read goes above a configured threshold
|
|
|
|
"""
|
|
|
|
|
2018-06-11 21:07:54 +02:00
|
|
|
def __init__(self, data, *args, **kwargs):
|
2018-07-09 22:37:54 +02:00
|
|
|
"""
|
|
|
|
:param data: Sensor data
|
|
|
|
"""
|
|
|
|
|
2018-06-11 21:07:54 +02:00
|
|
|
super().__init__(data=data, *args, **kwargs)
|
|
|
|
self.data = data
|
|
|
|
|
|
|
|
|
|
|
|
class SensorDataBelowThresholdEvent(Event):
|
2018-07-09 22:37:54 +02:00
|
|
|
"""
|
|
|
|
Event triggered when a sensor's read goes below a configured threshold
|
|
|
|
"""
|
|
|
|
|
2018-06-11 21:07:54 +02:00
|
|
|
def __init__(self, data, *args, **kwargs):
|
2018-07-09 22:37:54 +02:00
|
|
|
"""
|
|
|
|
:param data: Sensor data
|
|
|
|
"""
|
|
|
|
|
2018-06-11 21:07:54 +02:00
|
|
|
super().__init__(data=data, *args, **kwargs)
|
|
|
|
self.data = data
|
2018-04-29 23:51:53 +02:00
|
|
|
|
|
|
|
|
|
|
|
# vim:sw=4:ts=4:et:
|