コード例 #1
0
def on_motion_triggered(event):
    logger.info("Landing motion detected")

    timer_manager.cancel_timer("landing_motion_timer")

    if not state_machine.is_enabled(
            "indoor_movie_mode") and state_machine.is_enabled(
                "motion_lighting"):
        LightAction().add_light("landing_light").turn_on()
コード例 #2
0
def on_motion_triggered(event):
    logger.info("Hallway motion detected")

    timer_manager.cancel_timer("hallway_motion_timer")
    if not state_machine.is_enabled(
            "indoor_movie_mode",
            "privacy_mode") and state_machine.is_enabled("motion_lighting"):
        if not state_machine.is_enabled("sleep_mode"):
            LightAction().add_light("hallway_lights").turn_on()
        else:
            LightAction().add_lights(["first_floor_staircase_led"]).turn_on()
コード例 #3
0
def on_single_click(event):
    logger.info("Master Bedroom Button single clicked")

    if state_machine.is_enabled("sleep_mode"):
        SwitchAction().add_switch("master_bedroom_whitenoise").toggle()
    else:
        SwitchAction().add_switch("privacy_mode").toggle()
コード例 #4
0
def on_nhl_goal(event):
    if not state_machine.is_enabled("sleep_mode"):
        speech = f"{event.team} goal scored by number {event.scorer_number}, {event.scorer}."
        if event.primary_assist:
            speech = speech + f" Assisted by number {event.primary_number}, {event.primary_assist}"
        if event.secondary_assist:
            speech = speech + f" and number {event.secondary_number}, {event.secondary_assist}"
        TTSAction().add_assistant("living_room").say(speech)
コード例 #5
0
def on_washer_finished():
    PushNotifyAction().add_targets(
        "jim_cell",
        "erica_cell").set_message("Washing Machine has finished").notify()

    if not state_machine.is_enabled("sleep_mode"):
        TTSAction().add_assistants(["living_room_mpd", "master_bedroom_mpd"
                                    ]).say("Washer has finished")
コード例 #6
0
def callback():
    if not hassutil.is_weekend() and state_machine.is_heating_enabled():
        if state_machine.is_enabled("jim_wfh_calendar"):
            LightAction().add_light("office_lights").turn_on()
            if state_machine.is_heating_enabled():
                _enable_office_heat()
        else:
            timer_manager.schedule_oneoff_task("office_heatup",
                                               _enable_office_heat, "08:00:00")
コード例 #7
0
def handle_nobody_home():
    logger.info("Nobody home...")

    if not state_machine.is_enabled("guest_mode"):
        hassutil.activate_scene("nobody_home")

        if state_machine.is_heating_enabled():
            heat_action = ThermostatAction().add_thermostat("oil_thermostat")
            heat_action.set_temperature(state_machine.get_number("away_heat"), 'heat')
コード例 #8
0
def callback():
    if state_machine.is_enabled("jim_wfh_calendar"):

        LightAction().add_light("office_lights").turn_on()

        if state_machine.is_heating_enabled():
            heat_action = ThermostatAction().add_thermostat("office_heat")
            heat_action.turn_on()
            heat_action.set_temperature("74", "heat")
コード例 #9
0
def _notify_dryer_finish():
    global dryer_start

    if not state_machine.is_enabled("sleep_mode"):
        TTSAction().add_assistants(["living_room_mpd", "master_bedroom_mpd"
                                    ]).say("Dryer has finished")

    PushNotifyAction().add_targets(
        "jim_cell", "erica_cell").set_message("Dryer has finished").notify()
    dryer_start = None
コード例 #10
0
def on_motion_triggered(event):
    logger.info("Kitchen motion detected")

    timer_manager.cancel_timer("landing_motion_timer")
    timer_manager.cancel_timer("kitchen_motion_timer")

    if not state_machine.is_enabled(
            "indoor_movie_mode") and state_machine.is_enabled(
                "motion_lighting"):
        LightAction().add_light("landing_light").turn_on()

    if not state_machine.is_enabled(
            "outdoor_movie_mode", "indoor_movie_mode"
    ) and state_machine.is_enabled("motion_lighting"):
        LightAction().add_light("kitchen_cabinet_lights").turn_on(
            color_temp=400)

        if not state_machine.is_enabled("sleep_mode"):
            LightAction().add_light("kitchen_lights").turn_on()
コード例 #11
0
def on_motion_cleared(event):
    logger.info("Basement stairs motion cleared")

    timer_manager.start_timer("landing_motion_timer",
                              landing_light_off,
                              minutes=5)
    if not state_machine.is_enabled("workout_mode"):
        timer_manager.start_timer("basement_stairs_motion_timer",
                                  basement_lights_off,
                                  minutes=10)
コード例 #12
0
def on_sleep_state_enabled(event):
    logger.info("Sleep state enabled")
    hassutil.activate_scene("sleep_mode")
    JoinAction().add_target("jim_cell").send_taker_command("bed_command")

    if state_machine.is_heating_enabled():
        heat_action = ThermostatAction().add_thermostat("oil_thermostat")
        heat_action.set_temperature(state_machine.get_number("sleep_mode_heat"), 'heat')

    if state_machine.is_enabled("christmas_lights_mode"):
        LightAction().add_light("christmas_tree_lights").turn_off()
コード例 #13
0
def on_sleep_state_disabled(event):
    logger.info("Sleep state disabled")
    
    SwitchAction().add_switch("master_bedroom_whitenoise").turn_off()
    JoinAction().add_target("jim_cell").send_taker_command("awake_command")
    LightAction().add_lights(["first_floor_staircase_led"]).turn_off()
    ThermostatAction().add_thermostat("master_bedroom_ac").turn_off()

    if state_machine.is_heating_enabled():
        heat_action = ThermostatAction().add_thermostat("oil_thermostat")
        heat_action.set_temperature(state_machine.get_number("normal_heat"), 'heat')

    if state_machine.is_enabled("christmas_lights_mode"):
        LightAction().add_light("christmas_tree_lights").turn_on_no_brightness()
コード例 #14
0
def landing_light_off():
    if state_machine.is_enabled("motion_lighting"):
        LightAction().add_light("landing_light").turn_off()
コード例 #15
0
def on_motion_triggered(event):
    logger.info("Garage motion detected")

    timer_manager.cancel_timer("garage_motion_timer")
    if state_machine.is_enabled("motion_lighting"):
        LightAction().add_light("garage_lights").turn_on()
コード例 #16
0
def lights_off():
    if state_machine.is_enabled("motion_lighting"):
        LightAction().add_light("erica_closet_light").turn_off()
コード例 #17
0
def on_motion_triggered(event):
    logger.info("Erica closet motion detected")

    timer_manager.cancel_timer("erica_closet_motion_timer")
    if state_machine.is_enabled("motion_lighting"):
        LightAction().add_light("erica_closet_light").turn_on()
コード例 #18
0
def lights_off():
    if state_machine.is_enabled("motion_lighting"):
        LightAction().add_light("garage_lights").turn_off()
コード例 #19
0
def on_motion_triggered(event):
    logger.info("Fourth bedroom motion detected")
    
    timer_manager.cancel_timer("fourth_bedroom_motion_timer")
    if state_machine.is_enabled("motion_lighting"):
        LightAction().add_light("fourth_bedroom_fixture").turn_on()
コード例 #20
0
def on_nhl_game_end(event):
    if not state_machine.is_enabled("sleep_mode"):
        TTSAction().add_assistant("living_room").say("The game has ended")
コード例 #21
0
def on_nhl_period_end(event):
    if not state_machine.is_enabled("sleep_mode"):
        TTSAction().add_assistant("living_room").say("End of {}".format(
            _get_period_num(event.period)))
コード例 #22
0
def kitchen_lights_off():
    if state_machine.is_enabled("motion_lighting"):
        LightAction().add_lights(["kitchen_lights",
                                  "kitchen_cabinet_lights"]).turn_off()
コード例 #23
0
def on_sunset(event):
    if state_machine.is_enabled("christmas_lights_mode"):
        SwitchAction().add_switches(["frontyard_outlet", "backyard_outlet", "porch_outlet"]).turn_on()
    LightAction().add_light("front_garden_lights").turn_on()
コード例 #24
0
def lights_off():
    if state_machine.is_enabled("motion_lighting"):
        LightAction().add_light("fourth_bedroom_fixture").turn_off()
コード例 #25
0
def basement_lights_off():
    if state_machine.is_enabled("motion_lighting"):
        LightAction().add_light("basement_lights").turn_off()
コード例 #26
0
def on_motion_triggered(event):
    logger.info("Office motion detected")
    
    if not state_machine.is_enabled("sleep_mode") and state_machine.is_enabled("motion_lighting"):
        LightAction().add_light("office_lights").turn_on()
コード例 #27
0
def on_nhl_penalty(event):
    if not state_machine.is_enabled("sleep_mode"):
        speech = f"{event.team} penalty on number {event.number}, {event.player}.  "
        speech = speech + f"{event.duration} minute {event.severity} for {event.penalty}."
        TTSAction().add_assistant("living_room").say(speech)
コード例 #28
0
def lights_off():
    if state_machine.is_enabled("motion_lighting"):
        if not state_machine.is_enabled("sleep_mode"):
            LightAction().add_lights(["hallway_lights"]).turn_off()
        else:
            LightAction().add_lights(["first_floor_staircase_led"]).turn_off()