Skip to content

Instantly share code, notes, and snippets.

@bessarabov
Created August 7, 2020 18:14
Show Gist options
  • Save bessarabov/6c4daf3f66ab840f159b365fc4883283 to your computer and use it in GitHub Desktop.
Save bessarabov/6c4daf3f66ab840f159b365fc4883283 to your computer and use it in GitHub Desktop.
- title: water
path: water
icon: mdi:water-outline
panel: true
badges: []
cards:
- type: custom:layout-card
layout: vertical
cards:
- type: entities
show_header_toggle: false
entities:
- entity: binary_sensor.0x00158d0004470939_contact
- type: custom:template-entity-row
state: '{{ states("input_number.water_counter") | int }} L'
name: Counter
icon: mdi:water
- type: custom:multiple-entity-row
entity: sensor.hourly_water
entities:
- attribute: last_period
unit: L
name: 1h Water
icon: mdi:clock
unit: L
- type: custom:multiple-entity-row
entity: sensor.daily_water
entities:
- attribute: last_period
unit: L
name: 1d Water
icon: mdi:earth
unit: L
- type: custom:multiple-entity-row
entity: sensor.monthly_water
entities:
- attribute: last_period
unit: L
name: 1m Water
icon: mdi:calendar-blank
unit: L
- type: entities
show_header_toggle: false
entities:
- entity: input_number.current_water_counter
- type: custom:button-card
name: Set water counter
confirmation:
text: '[[[ return `Are you sure?` ]]]'
tap_action:
action: call-service
service: automation.trigger
service_data:
entity_id: automation.set_water_counter
- break
- type: history-graph
hours_to_show: 48
refresh_interval: 0
entities:
- entity: input_number.water_counter
- type: 'custom:bar-card'
entities:
- entity: sensor.water_filter_1_usage
name: Filter 1
icon: 'mdi:filter'
decimal: 1
- entity: sensor.water_filter_2_usage
name: Filter 2
icon: 'mdi:filter'
decimal: 1
- entity: sensor.water_filter_3_usage
name: Filter 3
icon: 'mdi:filter'
decimal: 1
- type: entities
show_header_toggle: false
entities:
- entity: input_text.water_filter_1_name
- entity: input_datetime.water_filter_1_install_date
- entity: input_number.water_filter_1_capacity
- entity: input_number.water_filter_1_install_counter_value
- type: divider
- entity: input_text.water_filter_2_name
- entity: input_datetime.water_filter_2_install_date
- entity: input_number.water_filter_2_capacity
- entity: input_number.water_filter_2_install_counter_value
- type: divider
- entity: input_text.water_filter_3_name
- entity: input_datetime.water_filter_3_install_date
- entity: input_number.water_filter_3_capacity
- entity: input_number.water_filter_3_install_counter_value
input_number:
water_counter:
min: 0
max: 100000000
step: 10
unit_of_measurement: liter
icon: mdi:water
current_water_counter:
mode: box
min: 0
max: 100000000
unit_of_measurement: liter
icon: mdi:water
automation:
- id: increase_water_counter
alias: Increase water counter
trigger:
- platform: state
entity_id: binary_sensor.0x00158d0004470939_contact
to: 'off'
action:
- service: input_number.increment
data:
entity_id: input_number.water_counter
- id: set_water_counter
alias: Set water counter
trigger:
action:
- service: notify.bessarabov
data_template:
message: "Установка счетчика воды. Было: {{ states('input_number.water_counter') | int }} Стало: {{ states('input_number.current_water_counter') | int }} Разница: {{ states('input_number.current_water_counter') | int - states('input_number.water_counter') | int }}"
- service: input_number.set_value
data_template:
entity_id: input_number.water_counter
value: "{{ states('input_number.current_water_counter') | int }}"
utility_meter:
hourly_water:
source: input_number.water_counter
cycle: hourly
daily_water:
source: input_number.water_counter
cycle: daily
monthly_water:
source: input_number.water_counter
cycle: monthly
~
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment