Some hardware links on this page are affiliate links. As an Amazon Associate I earn from qualifying purchases. We may earn a commission if you buy through them, at no extra cost to you. See the affiliate disclosure.
A contact that only flips a dashboard icon does not tell you the window is still open, how long it has been, or what the room was doing. This workflow sends one Telegram message per opening. On open it includes the room’s temperature and humidity and, if you want, a camera snapshot. On close it edits the same message with the close time and how long it was open. The edit is quiet. A second push is not sent.
You set it up once per room: pick that room’s door and window contacts, its climate sensors, and optionally a camera.
Entity ids are blueprint inputs. Do not publish a live contact name, a chat id, or which camera looks at which opening.
Turning heat or cool off while a sash is open is a different pack: window-open climate pause. A push only when someone walks into an empty room is office entry while empty. This one is the open/close message.
What problem it solves
You want a single message per opening — when it opened, the room climate at the time, an optional picture, and later the total open time — without a new push every time something closes.
How it works
- Open — any selected contact goes from closed to open. The automation runs once per opening (
mode: parallel), so two windows in the same room get two messages. - Message —
telegram_bot.send_messagesends “Bedroom window opened at 14:02. Room: 21.4 °C, 48% RH”. The temperature and humidity inputs are optional; a missing or unavailable sensor is left out of the line. - Camera — optional.
camera.snapshotwrites one file per camera under/media/openings/(overwritten each time) and sends it as a photo reply to the open message. - When to send — always, or only while a helper you pick is on (a group that is on when everyone is away, or an armed-alarm template binary sensor).
- Close — the run waits for that contact to close (up to a limit you set, default 24 hours), then calls
telegram_bot.edit_messageon the stored message id: “Closed at 14:19 (open 17 min 4 s).” - Restart — the wait lives inside the running automation. An opening that is still open when Home Assistant restarts keeps its open message but gets no close edit.
Needs Home Assistant 2025.10 or newer and the Telegram integration (its send action returns the message id the close edit needs). A normal Companion push cannot be edited after the fact. The Telegram token stays in that integration’s config. Never paste it into a blueprint.
Hardware notes
- Contact. Any binary sensor that is
onwhen the opening is open. The message uses the entity name, so name it after the opening (“Bedroom window”), not after a person. - Climate. A temperature and a humidity sensor in that room. The ESP32-C6 climate sensor is the build if the room does not have one yet. A Zigbee climate sensor you already own is enough.
- Camera. Any camera entity that can snapshot. Do not publish which lens covers which door.
- Files. Snapshots go under
/media/openings/, which Home Assistant already allows. One file per camera, overwritten on each opening. - Notify. One Telegram chat id per automation. A second chat gets its own automation.
Snippet
The pack ships a blueprint. Inputs replace real entity ids. This is the shape of the open message and the close edit:
actions:
- action: telegram_bot.send_message
data:
target: "{{ chat }}"
message: "{{ open_text }}"
response_variable: sent
- variables:
msg_id: "{{ sent.chats[0].message_id }}"
- wait_template: "{{ is_state(contact_e, 'off') }}"
timeout:
hours: "{{ max_h | int }}"
continue_on_timeout: false
- action: telegram_bot.edit_message
data:
chat_id: "{{ chat }}"
message_id: "{{ msg_id }}"
message: "{{ open_text }}\nClosed at {{ now().strftime('%H:%M') }} (open {{ dur }})."
Setup outline
- Set up the Telegram integration and allow your chat id. Send a test message from Developer Tools > Actions (
telegram_bot.send_message). - Import the blueprint. Create one automation per room: pick the room’s contacts, temperature and humidity sensors, an optional camera, and the chat id.
- Optional: pick an “only when” helper (away group, alarm armed).
- Test with an
input_booleanwrapped in a template binary sensor (device_class: window). Toggle it on: one message, climate line, photo if a camera is set. Toggle it off: the same message gains the close time and duration.
Troubleshooting
- No message. The contact is not in the automation’s list, the “only when” helper is off, or the Telegram chat id is not allowed in the integration. Check the automation trace.
- No climate line. The temperature or humidity input is empty, or that sensor is unavailable.
- No snapshot. The camera is unavailable or cannot snapshot. Check the trace for the
camera.snapshotstep. - Close never edits. Home Assistant restarted while it was open, the open lasted longer than the wait limit, or the Telegram integration is too old to return a message id (update Home Assistant).
- Two messages per opening. Two automations list the same contact. Keep each contact in one room’s automation.
Security note
This is an opening log, not an alarm design. Do not publish chat ids, tokens, arming schedules, or which camera covers which opening.
Credits
Inspired by the blueprint Door notify. This pack is an original, simpler per-room take: one editable Telegram message per opening, room climate, and an optional snapshot.