- move joanna_send_telegram into config/script - deduplicate Shutdown Helper light automation - remove the duplicate Color Tornado action - update package docs for the shared Telegram helperpull/1708/head
parent
e13e591823
commit
0ee97c923d
@ -0,0 +1,27 @@
|
||||
######################################################################
|
||||
# @CCOSTAN - Follow Me on X
|
||||
# For more info visit https://www.vcloudinfo.com/click-here
|
||||
# Original Repo : https://github.com/CCOSTAN/Home-AssistantConfig
|
||||
# -------------------------------------------------------------------
|
||||
# Kitchen Helper Light - Turn off helper after the main light stays off
|
||||
# Powers down `light.k4` after 20 minutes only when `light.k1` remains off.
|
||||
# -------------------------------------------------------------------
|
||||
######################################################################
|
||||
|
||||
- alias: Shutdown Helper light
|
||||
id: 124f95f6-78ca-4c22-9348-1f3a1da2d803
|
||||
|
||||
trigger:
|
||||
- platform: state
|
||||
entity_id: light.k4
|
||||
to: 'on'
|
||||
for: '00:20:00'
|
||||
|
||||
condition:
|
||||
condition: state
|
||||
entity_id: light.k1
|
||||
state: 'off'
|
||||
|
||||
action:
|
||||
- service: light.turn_off
|
||||
entity_id: light.k4
|
||||
@ -1,23 +0,0 @@
|
||||
###################################
|
||||
## ZWave Section -
|
||||
## Home Assistant runs on my [Raspberry Pi 3](https://amzn.to/2e3DOBY) with [Aeon Labs Z Wave Stick (GEN 5)](https://amzn.to/2eAiAP0).
|
||||
###################################
|
||||
|
||||
##############################################################
|
||||
- alias: Shutdown Helper light
|
||||
id: e3f4beff-4fa8-42e3-be5a-32b45106ac8a
|
||||
|
||||
trigger:
|
||||
- platform: state
|
||||
entity_id: light.k4
|
||||
to: 'on'
|
||||
for: '00:20:00'
|
||||
|
||||
condition:
|
||||
condition: state
|
||||
entity_id: light.k1
|
||||
state: 'off'
|
||||
|
||||
action:
|
||||
- service: light.turn_off
|
||||
entity_id: light.k4
|
||||
@ -0,0 +1,92 @@
|
||||
######################################################################
|
||||
# @CCOSTAN - Follow Me on X
|
||||
# For more info visit https://www.vcloudinfo.com/click-here
|
||||
# Original Repo : https://github.com/CCOSTAN/Home-AssistantConfig
|
||||
# -------------------------------------------------------------------
|
||||
# Joanna Send Telegram - Shared Telegram delivery helper
|
||||
# Chunks long messages, sends Telegram replies, and falls back to plain text when needed.
|
||||
# -------------------------------------------------------------------
|
||||
# Notes: Shared helper moved out of packages so cross-file callers resolve from config/script.
|
||||
# Notes: Keep Joanna/BearClaw decision logic in docker_17/codex_appliance; this script only delivers messages.
|
||||
######################################################################
|
||||
|
||||
joanna_send_telegram:
|
||||
alias: Joanna Send Telegram
|
||||
description: Sends resilient Telegram messages with chunking and plain-text fallback.
|
||||
mode: queued
|
||||
fields:
|
||||
message:
|
||||
description: Message body to send.
|
||||
example: Joanna is online.
|
||||
parse_mode:
|
||||
description: Telegram parse mode (`plain_text` or `html`).
|
||||
example: html
|
||||
disable_web_page_preview:
|
||||
description: Whether Telegram should suppress web page previews.
|
||||
example: true
|
||||
sequence:
|
||||
- variables:
|
||||
chunk_size: 3400
|
||||
requested_parse_mode: >-
|
||||
{% set raw = parse_mode | default('plain_text', true) | string | lower | trim %}
|
||||
{% if raw in ['html', 'plain_text'] %}
|
||||
{{ raw }}
|
||||
{% else %}
|
||||
plain_text
|
||||
{% endif %}
|
||||
preview_disabled: "{{ disable_web_page_preview | default(true, true) }}"
|
||||
normalized_message: >-
|
||||
{% set raw = message | default('', true) | string %}
|
||||
{{ raw | replace('\r\n', '\n') | replace('\r', '\n') | trim }}
|
||||
safe_message: >-
|
||||
{% if normalized_message | length > 0 %}
|
||||
{{ normalized_message }}
|
||||
{% else %}
|
||||
Joanna: (empty message)
|
||||
{% endif %}
|
||||
total_chunks: >-
|
||||
{% set size = chunk_size | int(3400) %}
|
||||
{% set length = safe_message | length %}
|
||||
{{ ((length + size - 1) // size) if length > 0 else 1 }}
|
||||
- repeat:
|
||||
count: "{{ total_chunks | int(1) }}"
|
||||
sequence:
|
||||
- variables:
|
||||
start: "{{ ((repeat.index | int(1)) - 1) * (chunk_size | int(3400)) }}"
|
||||
stop: "{{ start + (chunk_size | int(3400)) }}"
|
||||
chunk_body: "{{ safe_message[start:stop] }}"
|
||||
chunk_message: >-
|
||||
{% if (total_chunks | int(1)) > 1 %}
|
||||
[{{ repeat.index }}/{{ total_chunks }}]
|
||||
{{ chunk_body }}
|
||||
{% else %}
|
||||
{{ chunk_body }}
|
||||
{% endif %}
|
||||
fallback_message: >-
|
||||
{{ chunk_message
|
||||
| regex_replace(find='[\x00-\x08\x0B\x0C\x0E-\x1F]', replace=' ')
|
||||
| trim }}
|
||||
telegram_send_response: null
|
||||
- service: telegram_bot.send_message
|
||||
continue_on_error: true
|
||||
data:
|
||||
chat_id: !secret telegram_allowed_chat_id_carlo
|
||||
message: "{{ chunk_message }}"
|
||||
parse_mode: "{{ requested_parse_mode }}"
|
||||
disable_web_page_preview: "{{ preview_disabled }}"
|
||||
response_variable: telegram_send_response
|
||||
- choose:
|
||||
- conditions:
|
||||
- condition: template
|
||||
value_template: >-
|
||||
{{ telegram_send_response is none
|
||||
or telegram_send_response.chats is not defined
|
||||
or (telegram_send_response.chats | count) == 0 }}
|
||||
sequence:
|
||||
- service: telegram_bot.send_message
|
||||
continue_on_error: true
|
||||
data:
|
||||
chat_id: !secret telegram_allowed_chat_id_carlo
|
||||
message: "{{ fallback_message if fallback_message | length > 0 else 'Joanna: message delivery fallback (content omitted)' }}"
|
||||
parse_mode: plain_text
|
||||
disable_web_page_preview: "{{ preview_disabled }}"
|
||||
Loading…
Reference in new issue