Skip to content

Instantly share code, notes, and snippets.

View thejeffreystone's full-sized avatar

Jeffrey Stone thejeffreystone

View GitHub Profile
@thejeffreystone
thejeffreystone / configuration.yaml
Created September 10, 2022 14:00
Home Assistant Zone Counter Sensor
# Include this in the confiuration,yaml, or any yaml file where you have sensor data
sensor:
# This sensor will count how many times I was in the
# "Work" zone in the last 7 days
- platform: history_stats
name: Jeff Time at Work
entity_id: person.jeffrey # The Device/person entity
state: 'Work' # The name of the Zone
type: count # This will give you the count, use time if you want duration
end: '{{ now() }}' # When the count should End
@thejeffreystone
thejeffreystone / automations.yaml
Last active September 10, 2022 14:37
IFTTT Webhook Automation
- id: '1662424449450'
alias: IFTT Wenhook Example
description: ''
trigger:
- platform: webhook
webhook_id: ifttt_webhook
condition: []
action:
- choose:
@thejeffreystone
thejeffreystone / gist:41d67f03891c04b3b2cbdc47d83ad570
Created September 16, 2022 14:29
Mqtt Device Tracker Example
mqtt:
device_tracker:
- name: phone1
state_topic: "home/myphone"
- name: phone2
state_topic: "home/yourphone"
service: notify.alexa_media
data:
message: >
<voice name="{{ voice }}"> <amazon:auto-breaths> <prosody rate="medium"> I
know a Haiku. This one is called,
{{ [
'Good Morning From The Cat',
'Tee Rex Hug.',
'It Fits.',
'Minecraft Creepers.'
@thejeffreystone
thejeffreystone / lovelace_card.txt
Last active September 24, 2022 01:09
Home Assistant Stat Sensors
# Create a lovelace card with these entities after addubg the above sensors and restarting home assistant
entities:
- entity: sensor.binary_sensor_count
- entity: sensor.tracker_count
- entity: sensor.lights_count
- entity: sensor.sensor_count
- entity: sensor.script_count
- entity: sensor.automation_count
- entity: sensor.entities_count
alias: Webhook Lock
description: ""
trigger:
- platform: webhook
webhook_id: door_lock
condition: []
action:
- service: input_text.set_value
target:
entity_id: input_text.bedroom
@thejeffreystone
thejeffreystone / google_calendars.yaml
Created February 4, 2023 13:50
Example google_calendars.yaml file for Home Assistant
- cal_id: yourgooglecalemail@gmail.com
entities:
- device_id: mdl_holidays
name: MaisonDesLunes Holidays
search: "#mh"
track: true
max_results: 30
- device_id: kid_events
name: Kid Events
search: "#se"
# Get State of entity
{{ states('light.desk_backlight')}}
# Get Attribute Value
{{ state_attr('light.desk_backlight','energy')}}
# Do Mathy stuff - remeber PEMDAS
{{ ((states('sensor.basement_air_device_temperature') | int - 32) / 1.8) | round }}
# Get list of cameras, remove unavailable ones, list them and count them
@thejeffreystone
thejeffreystone / gist:187e943ec5d32cba461460fdb7dbe6e6
Last active May 9, 2023 23:11
State Based Template Framework - Sensor and Binary Sensor
template: # Not needed if you are saving this in a template.yaml. But required in configuration.yaml or a package
- sensor:
- name: sensor_1 # not required, but should be - used as entity_id and friendly_name
unique_id: sensor_1 # not required, but is if you want to be able to manage this via the UI
icon: mdi:cat # not required
device_class: none # Can be helpful when displaying state, if not included default is none
# All Device Classes -> https://www.home-assistant.io/integrations/sensor/#device-class
state: > # required
{{ states('sensor.cat_count') | int }}
# For more on these and more visit: https://ttl255.com/jinja2-tutorial-part-4-template-filters/
# Covert Previous value to integter
| int
# Convert previous value to a decimal number,
# Replace 0 with number of decimals to include
| float(0)