207 lines
7.7 KiB
YAML
207 lines
7.7 KiB
YAML
template:
|
|
- sensor:
|
|
- name: Bedroom bed occupied probability
|
|
state: "{{ (state_attr('binary_sensor.bedroom_bed_occupied', 'probability') * 100)|round() }}"
|
|
unit_of_measurement: "%"
|
|
state_class: measurement
|
|
icon: mdi:percent
|
|
availability: "{{ state_attr('binary_sensor.bedroom_bed_occupied', 'probability') is not none }}"
|
|
- name: Rachel asleep probability
|
|
state: "{{ (state_attr('binary_sensor.rachel_asleep', 'probability') * 100)|round() }}"
|
|
unit_of_measurement: "%"
|
|
state_class: measurement
|
|
icon: mdi:percent
|
|
availability: "{{ state_attr('binary_sensor.rachel_asleep', 'probability') is not none }}"
|
|
- name: Dan asleep probability
|
|
state: "{{ (state_attr('binary_sensor.dan_asleep', 'probability') * 100)|round() }}"
|
|
unit_of_measurement: "%"
|
|
state_class: measurement
|
|
icon: mdi:percent
|
|
availability: "{{ state_attr('binary_sensor.dan_asleep', 'probability') is not none }}"
|
|
|
|
sensor:
|
|
- platform: history_stats
|
|
name: Rachel hours asleep
|
|
entity_id: binary_sensor.rachel_asleep
|
|
state: "on"
|
|
end: "{{ (now() + timedelta(hours=5)).replace(hour=19, minute=0, second=0, microsecond=0) }}"
|
|
duration: "24:00"
|
|
- platform: history_stats
|
|
name: Rachel hours asleep yesterday
|
|
entity_id: binary_sensor.rachel_asleep
|
|
state: "on"
|
|
end: "{{ (now() - timedelta(hours=19)).replace(hour=19, minute=0, second=0, microsecond=0) }}"
|
|
duration: "24:00"
|
|
- platform: history_stats
|
|
name: Dan hours asleep
|
|
entity_id: binary_sensor.dan_asleep
|
|
state: "on"
|
|
end: "{{ (now() + timedelta(hours=5)).replace(hour=19, minute=0, second=0, microsecond=0) }}"
|
|
duration: "24:00"
|
|
- platform: history_stats
|
|
name: Dan hours asleep yesterday
|
|
entity_id: binary_sensor.dan_asleep
|
|
state: "on"
|
|
end: "{{ (now() - timedelta(hours=19)).replace(hour=19, minute=0, second=0, microsecond=0) }}"
|
|
duration:
|
|
hours: 24
|
|
# TODO: do history_stats on each of these to average over longer time period!
|
|
# TODO: also measure variation over longer time period and possibly remove those that vary too much from the bayesian sensor
|
|
# TODO: only show long-term ratios in UI once they settle
|
|
# For sleep statistics, assume asleep from 11PM to 6AM
|
|
- platform: history_stats
|
|
name: Bedroom occupancy ratio while asleep # unused
|
|
entity_id: binary_sensor.bedroom_presence_sensor_occupancy
|
|
state: "on"
|
|
type: ratio
|
|
end: "{{ today_at('06:00') - timedelta(days=1) }}"
|
|
duration: "07:00"
|
|
- platform: history_stats
|
|
name: Bedroom presence sensor distance in bed range ratio while asleep
|
|
entity_id: binary_sensor.bedroom_presence_sensor_distance_in_bed_range
|
|
state: "on"
|
|
type: ratio
|
|
end: "{{ today_at('06:00') - timedelta(days=1) }}"
|
|
duration: "07:00"
|
|
- platform: history_stats
|
|
name: Anyone asleep ratio while asleep
|
|
entity_id: binary_sensor.anyone_asleep
|
|
state: "on"
|
|
type: ratio
|
|
end: "{{ today_at('06:00') - timedelta(days=1) }}"
|
|
duration: "07:00"
|
|
- platform: history_stats
|
|
name: Bedroom bed occupied ratio while asleep
|
|
entity_id: binary_sensor.bedroom_bed_occupied
|
|
state: "on"
|
|
type: ratio
|
|
end: "{{ today_at('06:00') - timedelta(days=1) }}"
|
|
duration: "07:00"
|
|
- platform: history_stats
|
|
name: Bedroom light off ratio while asleep
|
|
entity_id: light.bedroom
|
|
state: "off"
|
|
type: ratio
|
|
end: "{{ today_at('06:00') - timedelta(days=1) }}"
|
|
duration: "07:00"
|
|
- platform: history_stats
|
|
name: Rachel was asleep within the last 5 minutes ratio while asleep # unused
|
|
entity_id: binary_sensor.rachel_was_asleep_within_last_5_minutes
|
|
state: "on"
|
|
type: ratio
|
|
end: "{{ today_at('06:00') - timedelta(days=1) }}"
|
|
duration: "07:00"
|
|
- platform: history_stats
|
|
name: Rachel's phone's still ratio while asleep
|
|
entity_id: binary_sensor.rachel_s_phone_s_still
|
|
state: "on"
|
|
type: ratio
|
|
end: "{{ today_at('06:00') - timedelta(days=1) }}"
|
|
duration: "07:00"
|
|
- platform: history_stats
|
|
name: Rachel's phone's sleep confidence high ratio while asleep
|
|
entity_id: binary_sensor.rachel_s_phone_s_sleep_confidence_high
|
|
state: "on"
|
|
type: ratio
|
|
end: "{{ today_at('06:00') - timedelta(days=1) }}"
|
|
duration: "07:00"
|
|
- platform: history_stats
|
|
name: Dan's phone still ratio while asleep
|
|
entity_id: binary_sensor.dan_s_phone_still
|
|
state: "on"
|
|
type: ratio
|
|
end: "{{ today_at('06:00') - timedelta(days=1) }}"
|
|
duration: "07:00"
|
|
- platform: history_stats
|
|
name: Dan's phone plugged in ratio while asleep
|
|
entity_id: binary_sensor.dan_s_phone_unplugged
|
|
state: "off"
|
|
type: ratio
|
|
end: "{{ today_at('06:00') - timedelta(days=1) }}"
|
|
duration: "07:00"
|
|
- platform: history_stats
|
|
name: Dan's computer inactive ratio while asleep
|
|
entity_id: binary_sensor.dan_s_computer_active
|
|
state: "off"
|
|
type: ratio
|
|
end: "{{ today_at('06:00') - timedelta(days=1) }}"
|
|
duration: "07:00"
|
|
# For wake statistics, assume awake from 9AM to 9PM
|
|
- platform: history_stats
|
|
name: Bedroom occupancy ratio while awake # unused
|
|
entity_id: binary_sensor.bedroom_presence_sensor_occupancy
|
|
state: "on"
|
|
type: ratio
|
|
start: "{{ today_at('09:00') - timedelta(days=1) }}"
|
|
duration: "12:00"
|
|
- platform: history_stats
|
|
name: Bedroom presence sensor distance in bed range ratio while awake
|
|
entity_id: binary_sensor.bedroom_presence_sensor_distance_in_bed_range
|
|
state: "on"
|
|
type: ratio
|
|
start: "{{ today_at('09:00') - timedelta(days=1) }}"
|
|
duration: "12:00"
|
|
- platform: history_stats
|
|
name: Anyone asleep ratio while awake
|
|
entity_id: binary_sensor.anyone_asleep
|
|
state: "on"
|
|
type: ratio
|
|
start: "{{ today_at('09:00') - timedelta(days=1) }}"
|
|
duration: "12:00"
|
|
- platform: history_stats
|
|
name: Bedroom bed occupied ratio while awake
|
|
entity_id: binary_sensor.bedroom_bed_occupied
|
|
state: "on"
|
|
type: ratio
|
|
start: "{{ today_at('09:00') - timedelta(days=1) }}"
|
|
duration: "12:00"
|
|
- platform: history_stats
|
|
name: Bedroom light off ratio while awake
|
|
entity_id: light.bedroom
|
|
state: "off"
|
|
type: ratio
|
|
start: "{{ today_at('09:00') - timedelta(days=1) }}"
|
|
duration: "12:00"
|
|
- platform: history_stats
|
|
name: Rachel was asleep within the last 5 minutes ratio while awake # unused
|
|
entity_id: binary_sensor.rachel_was_asleep_within_last_5_minutes
|
|
state: "on"
|
|
type: ratio
|
|
start: "{{ today_at('09:00') - timedelta(days=1) }}"
|
|
duration: "12:00"
|
|
- platform: history_stats
|
|
name: Rachel's phone's still ratio while awake
|
|
entity_id: binary_sensor.rachel_s_phone_s_still
|
|
state: "on"
|
|
type: ratio
|
|
start: "{{ today_at('09:00') - timedelta(days=1) }}"
|
|
duration: "12:00"
|
|
- platform: history_stats
|
|
name: Rachel's phone's sleep confidence high ratio while awake
|
|
entity_id: binary_sensor.rachel_s_phone_s_sleep_confidence_high
|
|
state: "on"
|
|
type: ratio
|
|
start: "{{ today_at('09:00') - timedelta(days=1) }}"
|
|
duration: "12:00"
|
|
- platform: history_stats
|
|
name: Dan's phone still ratio while awake
|
|
entity_id: binary_sensor.dan_s_phone_still
|
|
state: "on"
|
|
type: ratio
|
|
start: "{{ today_at('09:00') - timedelta(days=1) }}"
|
|
duration: "12:00"
|
|
- platform: history_stats
|
|
name: Dan's phone plugged in ratio while awake
|
|
entity_id: binary_sensor.dan_s_phone_unplugged
|
|
state: "off"
|
|
type: ratio
|
|
start: "{{ today_at('09:00') - timedelta(days=1) }}"
|
|
duration: "12:00"
|
|
- platform: history_stats
|
|
name: Dan's computer inactive ratio while awake
|
|
entity_id: binary_sensor.dan_s_computer_active
|
|
state: "off"
|
|
type: ratio
|
|
start: "{{ today_at('09:00') - timedelta(days=1) }}"
|
|
duration: "12:00"
|