Skip to content

Instantly share code, notes, and snippets.

View xbmcnut's full-sized avatar

xbmcnut

View GitHub Profile
@xbmcnut
xbmcnut / shelly_pir.yaml
Last active May 20, 2024 01:01
Making an outdoor motion sensor smart using a Shelly 1
/**
* I figured out you can fit a Shelly 1 inside the case of many outdoor motion sensors.
* Coupled with that fact that recently, Shelly added a feature to de-couple the switch from the relay
* so they act independently, makes this a great combo! Simply wire the output of the PIR motion sensor
* (the wire that normally goes to your outdoor light) to the switch input of the Shelly and wire
* the lightbulb to the L output of the Shelly. Then, in the Shelly app or directly via the devices webpage,
* select the button type as 'Detached Switch' and use the code below to make it work normally.
* Don't forget to adjust the daylight sensitivity to full daylight if you want the motion detection to work 24/7.
*/
@xbmcnut
xbmcnut / petdash.yaml
Created August 25, 2023 04:13
Sureflap cat flap integration complete with dashboard code
- theme: Backend-selected
icon: mdi:paw
path: sureflap
badges: []
cards:
- type: grid
cards:
- type: picture-glance
entities: []
title: []
@xbmcnut
xbmcnut / ghm_tts.yaml
Created June 22, 2020 10:58
How to get TTS announcements without interrupting Google speakers that are already being used.
# ghm_tts:
alias: 'Google Home Notifier'
sequence:
- service: media_player.volume_set
data_template:
entity_id: >-
{%- set players = ['media_player.kitchen_home', 'media_player.lounge_home', 'media_player.bathroom_speaker', 'media_player.ensuite_speaker'] %}
{{ states.media_player | selectattr('state','!=','playing') | selectattr('entity_id', 'in', players) | map(attribute='entity_id') | join(', ') }}
volume_level: '{{volume}}'
- service: tts.google_say
@xbmcnut
xbmcnut / ask_google.yaml
Created February 5, 2019 00:40
Package to allow Google TTS to advise of HA states for key devices. Scripts added directly to Cloud config.
script:
speak_garage_status:
alias: 'Ask Google for Garage Status'
sequence:
- delay:
seconds: 2
- service: tts.google_say
entity_id:
- media_player.kitchen_home
- media_player.insignia_speaker
@xbmcnut
xbmcnut / tablet_dashboard.yaml
Created December 15, 2020 09:29
Full config for my Home Assistant photo frame dashboard
views:
- badges: []
cards:
- cards:
- cards:
- entity: sensor.time
style: |
ha-card {
color: yellow;
#--paper-item-icon-color: green;
@xbmcnut
xbmcnut / shellypm1_fan.yaml
Last active March 12, 2021 08:19
How to make a dumb device smart using a Shelly PM1 | Fan Template example in Home Assistant
fan:
- platform: template
fans:
template_bedroom_fan:
friendly_name: "Master Bedroom Fan"
# Measures the power use from a Shelly1 PM and if over 3W, marks the fan as on
value_template: "{% if states('sensor.bedroom_fan_shelly_power') | float > 3 %}on{% else %}off{% endif %}"
# Uses the Shelly1 PM sensor value to determine what speed the fan is going at. Only set to measure 1, 2 & 3
speed_template: "{{ states('sensor.template_fan_speed_master') }}"
# Uses a fake switch from an input_boolean as the fan has no way of reporting direction back to HA
@xbmcnut
xbmcnut / fire_alarm.yaml
Created August 31, 2020 05:26
WIP. Code that speaks which smoke sensor went off and which door to exit. Needs modifying to account for new loop feature added in 0.113.x
automation:
- alias: Announce Fire Alarms
trigger:
platform: state
entity_id:
# Upstairs
- binary_sensor.smoke_sensor_landing
- binary_sensor.smoke_sensor_lounge
# Downstairs south
- binary_sensor.smoke_sensor_davids_bedroom
@xbmcnut
xbmcnut / arilux.yaml
Last active August 31, 2020 05:21
Arilux RGB Smart Bulb with Tasmota
Light is now picked up using setoption 19 1 (discovery)
@xbmcnut
xbmcnut / sunset_notifier.yaml
Created August 31, 2020 05:17
Turn PTZ to sunset, take a snapshot and if the TV is on, send it to the TV
automation:
- alias: 'Take sunset snapshot and send to TV'
initial_state: true
trigger:
platform: numeric_state
entity_id: sun.sun
value_template: "{{ state_attr('sun.sun', 'elevation') }}"
below: 0.3
condition:
- condition: template
@xbmcnut
xbmcnut / hot_water_cylinder.yaml
Last active August 31, 2020 05:10
Control my Hot Water element during peak power times.
# ###################################
# ## Automations
# ###################################
automation:
- alias: Turn off Hot Water Cylinder Mid-Week
id: 1d494c80-41eb-42eb-8e22-60a3606c29d9
trigger:
- platform: time
at: '00:01:00'
- platform: time