Skip to content

Instantly share code, notes, and snippets.

@MXMLN-sec
Last active October 18, 2021 10:06
Show Gist options
  • Save MXMLN-sec/49d747bda67ab346fbc3afeab915e55f to your computer and use it in GitHub Desktop.
Save MXMLN-sec/49d747bda67ab346fbc3afeab915e55f to your computer and use it in GitHub Desktop.
blueprint:
name: Controll thermostat temperature at night owers
description:
domain: automation
input:
threshold:
name: Set temperature at night
description:
default: 16
selector:
number:
min: 5.0
max: 30.0
unit_of_measurement: '°C'
mode: slider
step: 0.5
time:
name: Time when the temperature should be adjusted
description:
default: '22:00:00'
selector:
time: {}
source_url: https://gist.github.com/MXMLN-sec/49d747bda67ab346fbc3afeab915e55f
variables:
threshold: !input 'threshold'
sensors: >-
{% set result = namespace(sensors=[]) %}
{% for state in states.sensor | selectattr('attributes.device_class', '==', 'battery') %}
{% if 0 <= state.state | int(-1) < threshold | int and not state.entity_id in exclude.entity_id %}
{% set result.sensors = result.sensors + [state.name ~ ' (' ~ state.state ~ ' %)'] %}
{% endif %}
{% endfor %}
{% for state in states.binary_sensor | selectattr('attributes.device_class', '==', 'battery') | selectattr('state', '==', 'on') %}
{% if not state.entity_id in exclude.entity_id %}
{% set result.sensors = result.sensors + [state.name] %}
{% endif %}
{% endfor %}
{{result.sensors|join(', ')}}
trigger:
- platform: time
at: !input 'time'
condition:
- '{{ sensors != '''' and (day | int == 0 or day | int == now().isoweekday()) }}'
action:
- choose: []
default: !input 'actions'
mode: single
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment