Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View thejeffreystone's full-sized avatar

Jeffrey Stone thejeffreystone

View GitHub Profile
script:
get_room_services:
sequence:
- variables:
room: >
{% if room is defined %}
{{ room }}
{% else %}
{{ states('sensor.room_audio') }}
{% endif %}
@thejeffreystone
thejeffreystone / configuration.yaml
Created June 9, 2023 14:08
where to put sensors
# There are three ways you can add your sensors to Home Assistant, and they all start in the configuration.yaml file
#
# First you can just add them directly:
sensor:
- platform:
name:
# Or you can create a seperate file like sensors.yaml,
# you will need to of course create the sensors.yaml file first but add this to your configuration.yaml:
sensor: !include sensor.yaml
# 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)
@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 }}
# 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 / 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"
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 / 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
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 / 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"