parent
511b83fc71
commit
66a98d065d
@ -0,0 +1,74 @@
|
||||
######################################################################
|
||||
# @CCOSTAN - Follow Me on X
|
||||
# For more info visit https://www.vcloudinfo.com/click-here
|
||||
# Original Repo : https://github.com/CCOSTAN/Home-AssistantConfig
|
||||
# -------------------------------------------------------------------
|
||||
# Hydration - Attribute a shared cooler tag or manual refill to its owner.
|
||||
# Related Issue: 2033
|
||||
######################################################################
|
||||
blueprint:
|
||||
name: Personal water bottle refill
|
||||
description: Count one full bottle from the registered phone or the owner's dashboard button. Repeated entries within 30 seconds count once per person.
|
||||
domain: automation
|
||||
source_url: https://github.com/CCOSTAN/Home-AssistantConfig/blob/master/config/blueprints/automation/bearstone/water_bottle_refill.yaml
|
||||
input:
|
||||
tag_id:
|
||||
name: Cooler tag ID
|
||||
selector:
|
||||
text:
|
||||
scanner:
|
||||
name: Phone registered with the Companion App
|
||||
selector:
|
||||
entity:
|
||||
filter:
|
||||
- domain: device_tracker
|
||||
integration: mobile_app
|
||||
person:
|
||||
name: Person linked to the dashboard account
|
||||
selector:
|
||||
entity:
|
||||
filter:
|
||||
- domain: person
|
||||
manual_button:
|
||||
name: Manual refill button
|
||||
selector:
|
||||
entity:
|
||||
filter:
|
||||
- domain: input_button
|
||||
counter:
|
||||
name: Lifetime refill counter
|
||||
selector:
|
||||
entity:
|
||||
filter:
|
||||
- domain: counter
|
||||
|
||||
variables:
|
||||
scanner: !input scanner
|
||||
person: !input person
|
||||
triggers:
|
||||
- trigger: tag
|
||||
id: sticker
|
||||
tag_id: !input tag_id
|
||||
- trigger: state
|
||||
id: manual
|
||||
entity_id: !input manual_button
|
||||
to: null
|
||||
conditions:
|
||||
- condition: template
|
||||
value_template: >-
|
||||
{% if trigger.id == 'sticker' %}
|
||||
{% set phone = device_id(scanner) %}
|
||||
{{ phone is string and trigger.event.data.get('device_id') == phone }}
|
||||
{% else %}
|
||||
{% set account = state_attr(person, 'user_id') %}
|
||||
{{ account is string and trigger.from_state is not none and trigger.to_state is not none
|
||||
and trigger.to_state.context.user_id == account }}
|
||||
{% endif %}
|
||||
- condition: template
|
||||
value_template: >-
|
||||
{{ as_timestamp(now()) - as_timestamp(this.attributes.get('last_triggered'), 0) >= 30 }}
|
||||
actions:
|
||||
- action: counter.increment
|
||||
target:
|
||||
entity_id: !input counter
|
||||
mode: single
|
||||
@ -0,0 +1,105 @@
|
||||
######################################################################
|
||||
# @CCOSTAN - Follow Me on X
|
||||
# For more info visit https://www.vcloudinfo.com/click-here
|
||||
# Original Repo : https://github.com/CCOSTAN/Home-AssistantConfig
|
||||
# -------------------------------------------------------------------
|
||||
# Hydration - Record each person's full water bottles at refill time.
|
||||
# Related Issue: 2033
|
||||
# -------------------------------------------------------------------
|
||||
# Each accepted scan represents one full 40 US fl oz bottle at refill time.
|
||||
# Overview Health uses sensor.carlo_water_refilled_today, sensor.carlo_water_refilled_this_week,
|
||||
# sensor.stacey_water_refilled_today and sensor.stacey_water_refilled_this_week.
|
||||
######################################################################
|
||||
|
||||
counter:
|
||||
carlo_water_bottle_refills:
|
||||
name: Carlo Water Bottle Refills
|
||||
icon: mdi:cup-water
|
||||
restore: true
|
||||
stacey_water_bottle_refills:
|
||||
name: Stacey Water Bottle Refills
|
||||
icon: mdi:cup-water
|
||||
restore: true
|
||||
|
||||
input_button:
|
||||
carlo_water_bottle_refill:
|
||||
name: Log Carlo Water Bottle Refill
|
||||
icon: mdi:cup-water
|
||||
stacey_water_bottle_refill:
|
||||
name: Log Stacey Water Bottle Refill
|
||||
icon: mdi:cup-water
|
||||
|
||||
template:
|
||||
- variables:
|
||||
bottle_capacity_fl_oz: 40
|
||||
sensor:
|
||||
- name: Carlo Water Refilled Total
|
||||
unique_id: carlo_water_refilled_total
|
||||
unit_of_measurement: "fl oz"
|
||||
state_class: total_increasing
|
||||
icon: mdi:cup-water
|
||||
availability: "{{ is_number(states('counter.carlo_water_bottle_refills')) }}"
|
||||
state: "{{ states('counter.carlo_water_bottle_refills') | int(0) * bottle_capacity_fl_oz }}"
|
||||
attributes:
|
||||
bottle_capacity_fl_oz: "{{ bottle_capacity_fl_oz }}"
|
||||
last_refill_at: "{{ state_attr('automation.carlo_count_water_bottle_refill', 'last_triggered') }}"
|
||||
- name: Stacey Water Refilled Total
|
||||
unique_id: stacey_water_refilled_total
|
||||
unit_of_measurement: "fl oz"
|
||||
state_class: total_increasing
|
||||
icon: mdi:cup-water
|
||||
availability: "{{ is_number(states('counter.stacey_water_bottle_refills')) }}"
|
||||
state: "{{ states('counter.stacey_water_bottle_refills') | int(0) * bottle_capacity_fl_oz }}"
|
||||
attributes:
|
||||
bottle_capacity_fl_oz: "{{ bottle_capacity_fl_oz }}"
|
||||
last_refill_at: "{{ state_attr('automation.stacey_count_water_bottle_refill', 'last_triggered') }}"
|
||||
|
||||
utility_meter:
|
||||
carlo_water_refilled_today:
|
||||
name: Carlo Water Refilled Today
|
||||
unique_id: carlo_water_refilled_today
|
||||
source: sensor.carlo_water_refilled_total
|
||||
cycle: daily
|
||||
periodically_resetting: false
|
||||
carlo_water_refilled_this_week:
|
||||
name: Carlo Water Refilled This Week
|
||||
unique_id: carlo_water_refilled_this_week
|
||||
source: sensor.carlo_water_refilled_total
|
||||
cycle: weekly
|
||||
periodically_resetting: false
|
||||
|
||||
stacey_water_refilled_today:
|
||||
name: Stacey Water Refilled Today
|
||||
unique_id: stacey_water_refilled_today
|
||||
source: sensor.stacey_water_refilled_total
|
||||
cycle: daily
|
||||
periodically_resetting: false
|
||||
stacey_water_refilled_this_week:
|
||||
name: Stacey Water Refilled This Week
|
||||
unique_id: stacey_water_refilled_this_week
|
||||
source: sensor.stacey_water_refilled_total
|
||||
cycle: weekly
|
||||
periodically_resetting: false
|
||||
|
||||
automation:
|
||||
- id: carlo_count_water_bottle_refill
|
||||
alias: Carlo Count Water Bottle Refill
|
||||
use_blueprint:
|
||||
path: bearstone/water_bottle_refill.yaml
|
||||
input:
|
||||
tag_id: &cooler_tag 48c1e7b5-bd08-4629-b649-f4ba9f994971
|
||||
scanner: device_tracker.carlo_maxpro
|
||||
person: person.carlo
|
||||
manual_button: input_button.carlo_water_bottle_refill
|
||||
counter: counter.carlo_water_bottle_refills
|
||||
|
||||
- id: stacey_count_water_bottle_refill
|
||||
alias: Stacey Count Water Bottle Refill
|
||||
use_blueprint:
|
||||
path: bearstone/water_bottle_refill.yaml
|
||||
input:
|
||||
tag_id: *cooler_tag
|
||||
scanner: device_tracker.stacey_iphone11
|
||||
person: person.stacey
|
||||
manual_button: input_button.stacey_water_bottle_refill
|
||||
counter: counter.stacey_water_bottle_refills
|
||||
Loading…
Reference in new issue