Skip to content

Commit

Permalink
add esphome contribution
Browse files Browse the repository at this point in the history
  • Loading branch information
gcormier committed Nov 13, 2022
1 parent 7bdcd0d commit e77f152
Show file tree
Hide file tree
Showing 4 changed files with 117 additions and 0 deletions.
2 changes: 2 additions & 0 deletions misc/esphome/readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# User-contributed samples
For esphome, not vetted but hopefully can provide ideas.
37 changes: 37 additions & 0 deletions misc/esphome/sample1/automations.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
- id: '1665206728980'
alias: Stand Every Workday
description: ''
trigger:
- platform: time
at: 07:55:00
condition:
- condition: state
entity_id: binary_sensor.workday_sensor
state: 'on'
- condition: device
device_id: 24637765d54f431d8aabcc70fea8d9e3
domain: device_tracker
entity_id: device_tracker.iphone
type: is_home
action:
- device_id: dcc5e28a83dac013a370ee84060e0f3b
domain: button
entity_id: button.standing
type: press
mode: single
- id: '1665206778134'
alias: Sit at End of Workday
description: Set desk to sitting to keep 'standing' stats accurate
trigger:
- platform: time
at: '17:00:00'
condition:
- condition: state
entity_id: binary_sensor.workday_sensor
state: 'on'
action:
- device_id: dcc5e28a83dac013a370ee84060e0f3b
domain: button
entity_id: button.sitting
type: press
mode: single
49 changes: 49 additions & 0 deletions misc/esphome/sample1/configuration.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
Custom Sensor to detect when standing

template:
- binary_sensor:
- name: "standing"
state: >
{{ states('number.megadesk_height_cm')|float > 100 }}
sensor:
# time spent standing
- platform: history_stats
name: standing_today
entity_id: binary_sensor.standing
state: 'on'
type: time
start: '{{ now().replace(hour=0, minute=0, second=0) }}'
end: '{{ now().replace(hour=23, minute=59, second=59) }}'
- platform: template
sensors:
time_standing:
unit_of_measurement: "Hours"
value_template: "{{ (states('sensor.standing_today') | float) }}"
friendly_name: 'Time Standing'

# time TV is on Today
- platform: history_stats
name: roku_on_today
entity_id: media_player.55_tcl_roku_tv
state: 'on'
type: time
start: '{{ now().replace(hour=0, minute=0, second=0) }}'
end: '{{ now().replace(hour=23, minute=59, second=59) }}'
- platform: template
sensors:
tv_consumption:
unit_of_measurement: "Hours"
value_template: "{{ (states('sensor.roku_on_today') | float) }}"
friendly_name: 'TV Consumption'


# work day sensor targeted to BC (used by automation for standing desk)

binary_sensor:
- platform: workday
country: CA
province: BC
workdays: [mon, tue, wed, thu, fri]
excludes: [sat, sun, holiday]
29 changes: 29 additions & 0 deletions misc/esphome/sample1/readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Notes
The only other changes I've made from the files checked into GitHub are to remove buttons 3-4 and rename button 1 to 'sitting' and button 2 to 'standing'

## automations.yaml
This checks to see if it's a work day (not a holiday) and if my iPhone is home and then sets the desk to standing. At the end of the day it sets it to sitting (to avoid skewing any stats)

## Mini graph card
```
type: custom:mini-graph-card
entities:
- entity: sensor.standing_today
name: Time Spent Standing
hours_to_show: 168
group_by: date
aggregate_func: max
show:
graph: bar
tap_action:
action: more-info
entity: button.standing
color_thresholds:
- color: '#e45e65'
value: 0
- color: '#e0b400'
value: 1
- color: '#0da035'
value: 2
color_thresholds_transition: hard
```

0 comments on commit e77f152

Please sign in to comment.