Skip to content

Instantly share code, notes, and snippets.

@swilson
swilson / frigate_notification.yaml
Last active April 27, 2022 23:27 — forked from hunterjm/frigate_notification.yaml
Frigate Notification Blueprint
blueprint:
name: Frigate Notification
description: |
## Frigate Mobile App Notification
This blueprint will send a notification to your device when a Frigate event for the selected camera is fired. The notification will initially include the thumbnail of the detection, but will update to include actionable notifications allowing you to view the saved clip/snapshot when available, or silence the notification for a configurable amount of time.
With this blueprint, you may send the notification to multiple devices by leaving "Device" blank and instead use a [notification group][1].
### Required entities:
@swilson
swilson / check_zwave_devices.py
Last active November 23, 2020 17:53
Home Assistant python script to check for dead Z-Wave devices
checkTime = datetime.datetime.now() - datetime.timedelta(hours=24)
for entity_id in hass.states.get('group.zwave').attributes['entity_id']:
entity = hass.states.get(entity_id)
if entity is not None:
lastSeen = datetime.datetime.strptime(entity.attributes['receivedTS'][:-5], '%Y-%m-%d %H:%M:%S')
if entity.attributes['is_failed'] or lastSeen < checkTime:
msg = entity.attributes['friendly_name'] + ' is AWOL'
@swilson
swilson / Dockerfile
Created December 1, 2019 19:40
Home Assistant with X10 (heyu) integration
FROM homeassistant/home-assistant:stable
# Install dev tools
RUN apk add --update alpine-sdk
# Grab heyu
RUN wget -O heyu.zip https://codeload.github.com/HeyuX10Automation/heyu/zip/v2.10.1
RUN unzip heyu.zip
# Build it (the 'darwin' configuration seems to work on Alpine)
@swilson
swilson / HT1635B.py
Last active December 4, 2018 21:14
HT1635B driver (ported from https://github.com/alotaiba/HT1635B)
#!/usr/bin/python
import smbus
import time
bus = smbus.SMBus(1)
class HT1635B():
DEVICE_ADDRESS = 0x68
CMD_RAM_W = 0b10000000
@swilson
swilson / configuration.yaml
Created November 17, 2018 22:04
Home Assistant switch to toggle Foscam IR lights
switch:
- platform: command_line
switches:
front_door_camera_ir:
command_on: 'curl -k "https://192.168.1.XXX:443/cgi-bin/CGIProxy.fcgi?cmd=openInfraLed&usr=XXX&pwd=XXX"'
command_off: 'curl -k "https://192.168.1.XXX:443/cgi-bin/CGIProxy.fcgi?cmd=closeInfraLed&usr=XXX&pwd=XXX"'
@swilson
swilson / configuration.yaml
Created November 17, 2018 21:22
Home Assistant sunrise/sunset sensors
sensor:
- platform: template
sensors:
sunrise:
value_template: '{% set timestamp = as_timestamp(states.sun.sun.attributes.next_rising) | timestamp_custom("%I:%M %p") %} {{ timestamp.lstrip("0") }}'
friendly_name: "Sunrise"
sunset:
value_template: '{% set timestamp = as_timestamp(states.sun.sun.attributes.next_setting) | timestamp_custom("%I:%M %p") %} {{ timestamp.lstrip("0") }}'
friendly_name: "Sunset"
@swilson
swilson / configuration.yaml
Last active July 5, 2020 13:07
Home Assistant switch to trigger ZoneMinder recording
# Make sure OPT_TRIGGERS is enabled in ZoneMinder, and the camera is set to Nodect
switch:
- platform: telnet
switches:
front_door_camera_trigger:
resource: 'localhost'
port: 6802
command_on: '1|on|123|MotionOn|on'
command_off: '1|off|123|MotionOff|off'
@swilson
swilson / configuration.yaml
Created November 17, 2018 21:10
Home Assistant motion sensor for Foscam camera motion detection
binary_sensor:
- platform: command_line
name: "Front Door Motion Sensor"
command: 'curl -k --silent "https://192.168.1.XXX:443/cgi-bin/CGIProxy.fcgi?cmd=getDevState&usr=XXXX&pwd=XXXX" | grep -oP "(?<=motionDetectAlarm>).*?(?=</motionDetectAlarm>)"'
device_class: motion
payload_on: "2"
payload_off: "1"
scan_interval: 3
@swilson
swilson / tou.yaml
Created June 4, 2018 20:33
Home Assistant Ontario Hydro Time-Of-Use sensor
- platform: template
sensors:
hydro_rate:
# TODO account for holidays
value_template: >-
{% if now().weekday() > 4 or now().hour < 7 or now().hour >= 19 %}
off_peak
{% elif now().hour >= 7 and now().hour < 11 %}
{% if now().month >= 5 and now().month <= 10 %}
mid_peak
@swilson
swilson / raidar.py
Created December 11, 2017 17:13
Netgear RAIDar query
import sys, select, socket, time
bufferSize = 1024 # whatever you need
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
s.bind(('', 0))
s.setsockopt(socket.SOL_SOCKET, socket.SO_BROADCAST, 1)
sock_recv = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
sock_recv.bind(('', 22081))