Skip to content

Commit

Permalink
Added GlassbreakSensorMessage
Browse files Browse the repository at this point in the history
  • Loading branch information
bggardner committed Apr 24, 2017
1 parent 302ab1b commit b8ef080
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions SimpliSafe.py
Expand Up @@ -88,6 +88,7 @@ class OriginType(UniqueEnum):
KEYCHAIN_REMOTE = 0x2
MOTION_SENSOR = 0x4
ENTRY_SENSOR = 0x5
GLASSBREAK_SENSOR = 0x6

def __init__(self, plc: int, sn: str, payload: bytes, footer: bytes):
if len(sn) != 5:
Expand Down Expand Up @@ -1817,3 +1818,22 @@ def factory(cls, msg: SensorMessage):
raise InvalidMessageBytesError
event_type = EntrySensorMessage.EventType(msg.event_type)
return cls(msg.sn, msg.sequence, event_type)

class GlassbreakSensorMessage(SensorMessage):

origin_type = Message.OriginType.GLASSBREAK_SENSOR

class EventType(SensorMessage.EventType):
HEARTBEAT = 0x00
GLASSBREAK = 0x01

def __init__(self, sn: str, sequence: int, event_type: 'GlassbreakSensorMessage.EventType'):
self.event_type = GlassbreakSensorMessage.EventType(event_type)
super().__init__(sn, self.origin_type, sequence, event_type)

@classmethod
def factory(cls, msg: SensorMessage):
if msg.origin_type != cls.origin_type:
raise InvalidMessageBytesError
event_type = GlassbreakSensorMessage.EventType(msg.event_type)
return cls(msg.sn, msg.sequence, event_type)

0 comments on commit b8ef080

Please sign in to comment.