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()
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()
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()
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)
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")
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")
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')
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")
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
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()
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)
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()
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()
def landing_light_off(): if state_machine.is_enabled("motion_lighting"): LightAction().add_light("landing_light").turn_off()
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()
def lights_off(): if state_machine.is_enabled("motion_lighting"): LightAction().add_light("erica_closet_light").turn_off()
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()
def lights_off(): if state_machine.is_enabled("motion_lighting"): LightAction().add_light("garage_lights").turn_off()
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()
def on_nhl_game_end(event): if not state_machine.is_enabled("sleep_mode"): TTSAction().add_assistant("living_room").say("The game has ended")
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)))
def kitchen_lights_off(): if state_machine.is_enabled("motion_lighting"): LightAction().add_lights(["kitchen_lights", "kitchen_cabinet_lights"]).turn_off()
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()
def lights_off(): if state_machine.is_enabled("motion_lighting"): LightAction().add_light("fourth_bedroom_fixture").turn_off()
def basement_lights_off(): if state_machine.is_enabled("motion_lighting"): LightAction().add_light("basement_lights").turn_off()
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()
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)
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()