예제 #1
0
def next_scene() -> None:
    """select the next scene"""

    global sceneIdx
    sceneIdx += 1
    sceneIdx %= len(scenes)
    lights.set_scene(scenes[sceneIdx][0])
예제 #2
0
def prev_scene() -> None:
    """select the previous scene"""

    global sceneIdx
    sceneIdx -= 1
    sceneIdx %= len(scenes)
    lights.set_scene(scenes[sceneIdx][0])
예제 #3
0
def wait_for_movement():
    global _is_probably_leaving, _at_home
    print('wait_for_movement')
    if not _is_probably_leaving:
        print('USER STILL HERE')
        return
    
    # Turn on warning lights, so user sees that he has to move
    prev_scene = lights.get_scene()
    lights.set_scene(lights.LightScene.WARNING)

    # Check if there is movement in the next 90 seconds
    now = datetime.datetime.now()
    end = now + datetime.timedelta(seconds=90)
    while (now < end):
        if not _is_probably_leaving:
            print('User is still at home')
            lights.set_scene(prev_scene)
            return
        now = datetime.datetime.now()
        time.sleep(0.2)

    # User is not present any more
    _at_home = False
    on_leaving()
예제 #4
0
def set_scene(sceneName: str) -> None:
    global sceneIdx
    try:
        idx = sceneNames.index(sceneName)
        sceneIdx = idx
        lights.set_scene(scenes[sceneIdx][0])
    except ValueError as e:
        pass
예제 #5
0
def next_fav() -> None:
    """go to the next favorite scene"""

    global sceneIdx
    origIdx = sceneIdx
    while True:
        sceneIdx += 1
        sceneIdx %= len(scenes)
        if sceneNames[sceneIdx] in sceneFav:
            break
        if sceneIdx == origIdx:
            return
    lights.set_scene(scenes[sceneIdx][0])
예제 #6
0
def reset_scene() -> None:
    """reset scene to last selected"""

    global sceneIdx
    lights.set_scene(scenes[sceneIdx][0])
예제 #7
0
def on_leaving():
    print('on_leaving')
    lights.set_scene(lights.LightScene.OFF)