コード例 #1
0
def playMusicAtDinnerTime(event):
    global inDinnerSession
    activity = zm.getDevicesByType(ActivityTimes)[0]
    if activity.isDinnerTime():
        if not inDinnerSession:
            casts = cast_manager.getFirstFloorCasts()
            cast_manager.playStream("Meditation - Yimago Radio 4", casts, 40)

            inDinnerSession = True
コード例 #2
0
def saySecondNotice(event):
    if switch_manager.isAnyFirstFloorLightOn():
        cast_manager.playMessage(
            createMessageWithTime(
                'Kids, it is {}:{}; please go upstairs now.'),
            cast_manager.getFirstFloorCasts())
        switch_manager.changeFirstFloorLightsTo('OFF')
        time.sleep(2)
        switch_manager.changeFoyerLightTo('ON')
コード例 #3
0
    def testPlayMessage_validMessage_returnsTrue(self):
        casts = cast_manager.getFirstFloorCasts()

        result = cast_manager.playMessage(TEST_MESSAGE, casts)
        self.assertTrue(result)
        self.assertEqual(TEST_MESSAGE, casts[0].getLastTtsMessage())

        time.sleep(1)  # sleep for 1 sec for the pause message to go through
        for cast in casts:
            self.assertFalse(cast.isActive())
コード例 #4
0
def playAnnouncementAndMusicInTheMorning(event):
    global morningMusicStartCount
    global inMorningSession

    if isInMorningTimeRange() and \
            morningMusicStartCount < MAX_MORNING_MUSIC_START_COUNT:
        if not inMorningSession:
            PE.logInfo('{} Playing morning annoucement.'.format(LOG_PREFIX))
            inMorningSession = True
            msg = getMorningAnnouncement()
            casts = cast_manager.getFirstFloorCasts()

            cast_manager.playMessage(msg, casts)
            cast_manager.playStream("WWFM Classical", casts, 35)
            morningMusicStartCount += 1
コード例 #5
0
    def testPlayStream_validStreamName_returnsTrue(self):
        casts = cast_manager.getFirstFloorCasts()
        for cast in casts:  # reset the stream first
            cast.setStream('', '')

        streams = cast_manager.getAllStreamNames()

        try:
            streamName = streams[0]
            result = cast_manager.playStream(streamName, casts)
            self.assertTrue(result)

            for cast in casts:
                self.assertEqual(streamName, cast.getStreamName())
                self.assertEqual(cast_manager.getStreamUrl(streamName),
                                 cast.getStreamUrl())
        finally:
            cast_manager.pause(casts)
コード例 #6
0
def playMindfullnessBell(event):

    # not triggered if house is armed away
    if SM.isArmedAway(zm):
        return

    volume = 40

    activity = zm.getDevicesByType(ActivityTimes)[0]
    if activity.isSleepTime():
        return
    elif activity.isQuietTime():
        volume = 40
    else:
        volume = 60

    casts = cast_manager.getFirstFloorCasts()
    cast_manager.playSoundFile(
            BELL_URL, BELL_DURATION_IN_SECS, casts, volume)
コード例 #7
0
def sayFirstNotice(event):
    if switch_manager.isAnyFirstFloorLightOn():
        cast_manager.playMessage(
            createMessageWithTime(
                'Kids, it is {}:{}; please put away everything and prepare to go upstairs.'
            ), cast_manager.getFirstFloorCasts())
コード例 #8
0
 def testGetFirstFloorCasts_noParams_returnsNormally(self):
     casts = cast_manager.getFirstFloorCasts()
     self.assertTrue(len(casts) > 0)