Exemple #1
0
    def testOnSwitchTurnedOff_withNonApplicableZone_returnsFalse(self):
        zone = Zone('ff', [self.light, self.motionSensor])
        self.zm.addZone(zone)

        self.assertFalse(
            self.zm.onSwitchTurnedOff(scope.events,
                                      PE.createStringItem(INVALID_ITEM_NAME)))
Exemple #2
0
    def testOnMotionSensorTurnedOn_withNonApplicableZone_returnsFalse(self):
        zone = Zone('ff', [self.light, self.motionSensor])
        self.zm.addZone(zone)

        self.assertFalse(
            self.zm.dispatchEvent(ZoneEvent.MOTION, scope.events,
                                  PE.createStringItem(INVALID_ITEM_NAME)))
    def __init__(self, prefix, sinkName):
        '''
        Ctor

        :param str prefix: the item name prefix, as defined in the .item file. By\
            convention, other channels of this device will have this naming \
            pattern: {prefix}Idling, {prefix}Title, {prefix}Player, and so on.
        :param str sinkName: the sink name for voice and audio play. The sink \
            name can be retrieved by running "openhab-cli console" and then \
            "smarthome:audio sinks".
        :raise ValueError: if any parameter is invalid
        '''
        Device.__init__(self, PE.createStringItem(
                    'Chromecast-{}-{}'.format(prefix, sinkName)))

        self.sinkName = sinkName
        self.prefix = prefix
        self.streamUrl = None
        self.lastTtsMessage = None

        self._testMode = False
        self._testLastCommand = None

        self._lastCommandTimestamp = time.time()
        self._lastCommand = None
    def __init__(self, timeRangeMap):
        '''
        Ctor

        :param dictionary timeRangeMap: a map from activity string to time \
            range string \
            The supported activities are 'lunch', 'dinner', 'sleep', 'quiet', \
            'wakeup'.
            A time range string can be a single or multiple \
            ranges in the 24-hour format.\
            Example: '10-12', or '6-9, 7-7, 8:30 - 14:45', or '19 - 8' \
            (wrap around)
        :raise ValueError: if any parameter is invalid
        '''
        Device.__init__(self, PE.createStringItem('ActivityTimesItem'))

        acceptableKeys = ['lunch', 'dinner', 'sleep', 'quiet', 'wakeup']
        for key in timeRangeMap.keys():
            if key not in acceptableKeys:
                raise ValueError('Invalid time range key {}'.format(key))

        self.timeRangeMap = timeRangeMap
Exemple #5
0
    def testOnTimerExpired_invalidTimerItem_returnsFalse(self):
        zone = Zone('ff', [self.light])

        isProcessed = zone.onTimerExpired(self.getMockedEventDispatcher(),
                                          PE.createStringItem('dummy name'))
        self.assertFalse(isProcessed)
Exemple #6
0
 def testOnSwitchTurnedOff_noZone_returnsFalse(self):
     self.assertFalse(
         self.zm.onSwitchTurnedOff(scope.events,
                                   PE.createStringItem(INVALID_ITEM_NAME)))
Exemple #7
0
 def testOnTimerExpired_noZone_returnsFalse(self):
     self.assertFalse(
         self.zm.onTimerExpired(scope.events,
                                PE.createStringItem(INVALID_ITEM_NAME)))
Exemple #8
0
 def testOnMotionSensorTurnedOn_noZone_returnsFalse(self):
     self.assertFalse(
         self.zm.dispatchEvent(ZoneEvent.MOTION, scope.events,
                               PE.createStringItem(INVALID_ITEM_NAME)))