Skip to content

Instantly share code, notes, and snippets.

# Put in automations.yaml
- id: door_close_fan_off
alias: Door Close Fan Off
initial_state: 'on'
trigger:
platform: state
entity_id: binary_sensor.door_window_sensor_158d0001ab56bd
from: 'on'
to: 'off'
# Put in automations.yaml
- id: morning_begins
alias: Morning Begins
initial_state: 'on'
trigger:
platform: time
at: "5:00:00"
action:
- service: automation.turn_off
# This part goes in automations.yaml
- id: night_living_room
alias: Nighttime Living Room
trigger:
platform: state
entity_id: binary_sensor.door_window_sensor_158d0001e59f8e
from: 'off'
to: 'on'
action:
# These go in automations.yaml
- id: night_light_toggle_on
alias: Night Light Toggle ON
initial_state: 'off'
trigger:
- platform: state
entity_id: binary_sensor.door_window_sensor_158d0001ab573f
from: 'off'
to: 'on'
bedtime:
alias: Bedtime
sequence:
- service: homeassistant.turn_off
entity_id:
- switch.tv
- switch.air_conditioner
- service: homeassistant.turn_on
entity_id: light.bedroom_lamp
data:
# These scripts can be called from Home Assitant or reached using Alexa
# If the connected TV is off when they're used, the script will likely turn the TV on
roku_home:
alias: Roku Home
sequence:
- service: media_player.select_source
data:
entity_id: media_player.living_room
source: Home
# I like to stop the Discovery component from searching for the Roku and instead, add it manually.
# Add these to your configuration.yaml file
discovery:
ignore:
- roku
media_player:
- platform: roku
host: your_roku_host
# This creates a sensor that detects if the TV is on, if the Chromecast is powered and pingable
binary_sensor: #goes in configuration.yaml
- platform: ping
count: 5
scan_interval: 10
name: chromecast_status
host: your_chromecast_host
# In your switches.yaml file you can create a switch template. This one will show the TV as 'ON' if the Chromecast is found by the ping component
binary_sensor:
- platform: ping
count: 5
scan_interval: 10
name: chromecast_status
host: !secret chromecast_host
switch:
- platform: template
switches:
- id: empty_dustbin
alias: Empty Dustbin
initial_state: 'on'
trigger:
- platform: state
entity_id: sensor.vacuum_state
to: 'Charging'
action:
service: ifttt.trigger
data: {"event":"alexa_notification", "value1":"Empty the dustbin."