Skip to content

Instantly share code, notes, and snippets.

@misterdorm
Created December 4, 2023 17:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save misterdorm/b43a0aa163451e91199c0f706d753a37 to your computer and use it in GitHub Desktop.
Save misterdorm/b43a0aa163451e91199c0f706d753a37 to your computer and use it in GitHub Desktop.
apiVersion: v1
kind: ConfigMap
metadata:
name: homeassistant-config
data:
config: |
# Loads default set of integrations. Do not remove.
default_config:
# Load frontend themes from the themes folder
frontend:
themes: !include_dir_merge_named themes
automation: !include automations.yaml
homeassistant: !include homeassistant.yaml
http: !include http.yaml
notify: !include notify.yaml
scene: !include scenes.yaml
script: !include scripts.yaml
twilio: !include twilio.yaml
automations: |
- id: '1700369618654'
alias: Sump Water SMS Notification
description: ''
trigger:
- platform: state
entity_id:
- binary_sensor.sump_water
to: 'on'
condition: []
action:
- service: notify.twilio_sms
data:
target: <redacted>
message: 🚨 Home Assistant Security 🚨
{{ trigger.to_state.attributes.friendly_name }} detected {{ trigger.to_state.state }}
{{ as_timestamp(trigger.to_state.last_changed) | timestamp_custom("%a %b %d, %Y %I:%M:%S %p") }}
mode: single
- id: '1700370239017'
alias: SMS when door security zone faults
description: ''
trigger:
- platform: state
entity_id:
- binary_sensor.front_entry
- binary_sensor.mud_room_big_garage_entry
- binary_sensor.mud_room_rear_entry
- binary_sensor.garage_service_door
- binary_sensor.sliding_entry
- binary_sensor.small_garage_entry
to: 'on'
condition: []
action:
- service: notify.twilio_sms
data:
target: <redacted>
message: 🚨 Home Assistant Security 🚨
{{ trigger.to_state.attributes.friendly_name }} {{ trigger.to_state.state }}
{{ as_timestamp(trigger.to_state.last_changed) | timestamp_custom("%a %b %d, %Y %I:%M:%S %p") }}
mode: single
- id: '1700373658548'
alias: SMS when UPS changes state
description: ''
trigger:
- platform: state
entity_id:
- sensor.ups_status
condition: []
action:
- service: notify.twilio_sms
data:
target: <redacted>
message: ⚡️ Home Assistant Power ⚡
{% if trigger.to_state.state == "ONBATT" -%}
⚠️ {{ trigger.to_state.attributes.friendly_name }} went {{ trigger.to_state.state }}
{% else -%}
✅ {{ trigger.to_state.attributes.friendly_name }} went {{ trigger.to_state.state }}
{% endif %}
⏰ Esimated run time {{ states('sensor.ups_time_left', rounded=True, with_unit=True) }}
🔋 Battery charge {{ states('sensor.ups_battery', rounded=True, with_unit=True) }}
{{ as_timestamp(trigger.to_state.last_changed) | timestamp_custom("%a %b %d, %Y %I:%M:%S %p") }}
mode: single
- id: '1700374517063'
alias: Notify SMS when UPS battery charged
description: ''
trigger:
- platform: numeric_state
entity_id: sensor.ups_battery
above: 99
condition: []
action:
- service: notify.twilio_sms
data:
message: ⚡️ Home Assistant Power ⚡
🔋 {{ trigger.to_state.attributes.friendly_name }} is charged to {{ states('sensor.ups_battery', rounded=True, with_unit=True) }}
{{ as_timestamp(trigger.to_state.last_changed) | timestamp_custom("%a %b %d, %Y %I:%M:%S %p") }}
target: <redacted>
mode: single
- id: '1700374517064'
alias: Notify SMS when UPS run time running out
description: ''
trigger:
- platform: numeric_state
entity_id: sensor.ups_time_left
value_template: "{{ (states('sensor.ups_time_left') | float) - (states('sensor.ups_shutdown_time') | float) }}"
below: 2
condition: []
action:
- service: notify.twilio_sms
data:
message: ⚡️ Home Assistant Power ⚡
⚠️ {{ trigger.to_state.attributes.friendly_name }} ({{ states('sensor.ups_time_left', rounded=True, with_unit=True) }}) nearing shutdown time ({{ states('sensor.ups_shutdown_time', rounded=True, with_unit=True) }}), shutdown is imminent.
{{ as_timestamp(trigger.to_state.last_changed) | timestamp_custom("%a %b %d, %Y %I:%M:%S %p") }}
target: <redacted>
mode: single
- id: '1700374517065'
alias: Notify SMS when UPS battery running low
description: ''
trigger:
- platform: numeric_state
entity_id: sensor.ups_battery
value_template: "{{ (states('sensor.ups_battery') | float) - (states('sensor.ups_battery_shutdown') | float) }}"
below: 5
condition: []
action:
- service: notify.twilio_sms
data:
message: ⚡️ Home Assistant Power ⚡
🪫 {{ trigger.to_state.attributes.friendly_name }} ({{ states('sensor.ups_battery', rounded=True, with_unit=True) }}) nearing shutdown threshold ({{ states('sensor.ups_battery_shutdown', rounded=True, with_unit=True) }}), shutdown is imminent.
{{ as_timestamp(trigger.to_state.last_changed) | timestamp_custom("%a %b %d, %Y %I:%M:%S %p") }}
target: <redacted>
mode: single
- id: '1700374517066'
alias: Notify SMS when UPS has been ONBATT for half the remaining time
description: ''
trigger:
- platform: state
entity_id: sensor.ups_status
to: "ONBATT"
for:
minutes: "{{ states.sensor.ups_time_left.state | float / 2 }}"
action:
- service: notify.twilio_sms
data:
target: <redacted>
message: ⚡️ Home Assistant Power ⚡
⏰ {{ trigger.to_state.attributes.friendly_name }} remaining run time is {{ states('sensor.ups_time_left', rounded=True, with_unit=True) }}.
🔋 Battery at {{ states('sensor.ups_battery', rounded=True, with_unit=True) }}.
{{ as_timestamp(now()) | timestamp_custom("%a %b %d, %Y %I:%M:%S %p") }}
mode: single
homeassistant: |
name: Home
latitude: <redacted>
longitude: <redacted>
elevation: 1866
unit_system: us_customary
currency: USD
country: US
time_zone: "America/Denver"
external_url: <redacted>
internal_url: <redacted>
http: |
use_x_forwarded_for: true
trusted_proxies: 10.1.0.0/16
notify: |
- name: twilio_sms
platform: twilio_sms
from_number: <redacted>
- name: emaildorm
platform: smtp
server: smtp.default.svc.cluster.local
port: 25
encryption: none
sender: <redacted>
recipient: <redacted>
twilio: |
account_sid: <redacted>
auth_token: <redacted>
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: homeassistant
labels:
app: homeassistant
spec:
selector:
matchLabels:
app: homeassistant
replicas: 1
template:
metadata:
labels:
app: homeassistant
spec:
initContainers:
- name: wait-for-apsupsd
image: busybox
command: ['sh', '-c', 'while ! nc -z apcupsd-nis.default.svc.cluster.local 3551; do sleep 1; done;']
containers:
- name: homeassistant
image: ghcr.io/home-assistant/home-assistant:stable
ports:
- name: ha-ui
containerPort: 8123
protocol: TCP
env:
- name: TZ
value: America/Denver
volumeMounts:
- name: homeassistant
mountPath: /config
subPath: config
- name: homeassistant-config
mountPath: /config/configuration.yaml
subPath: config
- name: homeassistant-config
mountPath: /config/automations.yaml
subPath: automations
- name: homeassistant-config
mountPath: /config/homeassistant.yaml
subPath: homeassistant
- name: homeassistant-config
mountPath: /config/http.yaml
subPath: http
- name: homeassistant-config
mountPath: /config/notify.yaml
subPath: notify
- name: homeassistant-config
mountPath: /config/twilio.yaml
subPath: twilio
volumes:
- name: homeassistant
hostPath:
path: /opt/k8s-apps/homeassistant
type: DirectoryOrCreate
- name: homeassistant-config
configMap:
name: homeassistant-config
---
apiVersion: v1
kind: Service
metadata:
name: homeassistant-ui
spec:
selector:
app: homeassistant
type: ClusterIP
ports:
- name: homeassistant-ui
port: 8123
protocol: TCP
---
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: homeassistant-ingress
annotations:
cert-manager.io/cluster-issuer: lets-encrypt
spec:
tls:
- hosts:
- <redacted>
secretName: internal-ingress-tls
- hosts:
- <redacted>
secretName: external-ingress-tls
rules:
- host: <redacted>
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: homeassistant-ui
port:
number: 8123
- host: <redacted>
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: homeassistant-ui
port:
number: 8123
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment