mirror of
https://github.com/MBombeck/HealthLog.git
synced 2026-11-15 15:02:04 +00:00
The room-climate guide said both to create one automation per room and to track only one; it now recommends the bedroom and says why a second room cannot work (no room name, same-minute pushes collide on 409). The blueprint offers 5, 10, 15, 20, 30 or 60 minutes, so the push lands on the stated minutes, and it and the guide's examples use the triggers, conditions and actions keys of Home Assistant 2024.10 and later. A test holds all three.
98 lines
3.2 KiB
YAML
98 lines
3.2 KiB
YAML
# Push a room's CO2, temperature and humidity to HealthLog every few minutes.
|
|
#
|
|
# Use it for one room. The readings carry no room name, so a second room would
|
|
# land in the same series, and a push in the same minute is refused (409).
|
|
#
|
|
# Needs the `healthlog_room_climate` rest_command from
|
|
# docs/integrations/home-assistant.md ("Room climate") and a measurement
|
|
# ingest token. Every sensor is optional; a sensor that reports `unknown`,
|
|
# `unavailable` or a non-number is left out of that push, and a push with
|
|
# nothing left is skipped. Temperatures in °F are converted to °C.
|
|
blueprint:
|
|
name: HealthLog room climate
|
|
description: >-
|
|
Sends indoor CO2 (ppm), temperature (°C) and relative humidity (%) to
|
|
HealthLog through a measurement ingest token. HealthLog keeps each
|
|
reading and shows the day's mean, low and high.
|
|
domain: automation
|
|
homeassistant:
|
|
min_version: 2024.10.0
|
|
source_url: https://github.com/MBombeck/HealthLog/blob/main/docs/integrations/blueprints/healthlog-room-climate.yaml
|
|
input:
|
|
co2_sensor:
|
|
name: CO2 sensor
|
|
description: A sensor reporting carbon dioxide in ppm.
|
|
default: ""
|
|
selector:
|
|
entity:
|
|
domain: sensor
|
|
device_class: carbon_dioxide
|
|
temperature_sensor:
|
|
name: Temperature sensor
|
|
description: A sensor reporting the room temperature (°C or °F).
|
|
default: ""
|
|
selector:
|
|
entity:
|
|
domain: sensor
|
|
device_class: temperature
|
|
humidity_sensor:
|
|
name: Humidity sensor
|
|
description: A sensor reporting relative humidity in %.
|
|
default: ""
|
|
selector:
|
|
entity:
|
|
domain: sensor
|
|
device_class: humidity
|
|
interval_minutes:
|
|
name: Interval
|
|
description: >-
|
|
Minutes between pushes, on the hour and every interval after it.
|
|
15 is plenty for a daily picture.
|
|
default: "15"
|
|
selector:
|
|
select:
|
|
options: ["5", "10", "15", "20", "30", "60"]
|
|
|
|
mode: single
|
|
|
|
variables:
|
|
co2_sensor: !input co2_sensor
|
|
temperature_sensor: !input temperature_sensor
|
|
humidity_sensor: !input humidity_sensor
|
|
interval_minutes: !input interval_minutes
|
|
# A list of readings (Home Assistant keeps a rendered list a list).
|
|
readings: >-
|
|
{% set at = now().replace(second=0, microsecond=0).isoformat() %}
|
|
{% set ns = namespace(items=[]) %}
|
|
{% for type, entity in [
|
|
('INDOOR_CO2', co2_sensor),
|
|
('INDOOR_TEMPERATURE', temperature_sensor),
|
|
('INDOOR_HUMIDITY', humidity_sensor)
|
|
] %}
|
|
{% if entity and is_number(states(entity)) %}
|
|
{% set v = states(entity) | float %}
|
|
{% if type == 'INDOOR_TEMPERATURE'
|
|
and state_attr(entity, 'unit_of_measurement') == '°F' %}
|
|
{% set v = ((v - 32) * 5 / 9) | round(2) %}
|
|
{% endif %}
|
|
{% set ns.items = ns.items
|
|
+ [{'type': type, 'value': v, 'measuredAt': at}] %}
|
|
{% endif %}
|
|
{% endfor %}
|
|
{{ ns.items }}
|
|
|
|
triggers:
|
|
- trigger: time_pattern
|
|
minutes: "/5"
|
|
|
|
conditions:
|
|
- condition: template
|
|
value_template: >-
|
|
{{ now().minute % (interval_minutes | int(15)) == 0
|
|
and readings | count > 0 }}
|
|
|
|
actions:
|
|
- action: rest_command.healthlog_room_climate
|
|
data:
|
|
readings: "{{ readings }}"
|