Last active
June 20, 2024 20:37
-
-
Save AndySymons/105062c71de2badad995618fec0fe1ee to your computer and use it in GitHub Desktop.
Logfile Entry script
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
### ------------------------------------------------------------------------------------------------ | |
### | |
### Log File Entry script | |
### --------------------- | |
### | |
### Writes one line to a log file | |
### Provides songle control of the logging format | |
### | |
### RELEASE 1.0 | Andy Symons | 16-Mar-2024 | |
### | |
### Minor updates | |
### 16-Mar-2024: 1.0.0 New script.heating_xyz_logfile_entry | |
### 12-Jun-2024: 1.0.1 Generalised to any log file. Renamed 'logfile_entry' | |
### 20-Jun-2024: 1.0.2 Updated to use the new 'notify.send_message' service | |
### | |
### ------------------------------------------------------------------------------------------------ | |
script: | |
logfile_entry: | |
alias: Log File Entry | |
mode: parallel | |
icon: mdi:script | |
max: 100 | |
fields: | |
notification_service: | |
name: Notification Service | |
description: Name of the (alrady configured) notification service to be used | |
example: main_bedroom_heating_log | |
selector: | |
text: | |
required: true | |
logfile_title: | |
name: Logfile Title | |
description: Title for the logfile (appears in the header) | |
example: Heating X2 | |
selector: | |
text: | |
required: true | |
message_preamble: | |
name: Message Preamble | |
description: Text identifyng the source of the message | |
example: Main Bedroom Heating Control | |
selector: | |
text: | |
required: true | |
message_body: | |
name: Message Body | |
description: The substance of the message to be logged | |
example: This is a test message | |
selector: | |
text: | |
required: true | |
variables: | |
notification_service_trimmed: >- | |
{{ notification_service | string | trim }} | |
notification_service_entity: >- | |
{{ "notify." + notification_service_trimmed }} | |
sequence: | |
- if: | |
- condition: template | |
value_template: > | |
{{ notification_service_entity is defined }} | |
then: | |
- service: notify.send_message | |
data: | |
entity_id: > | |
{{ notification_service_entity }} | |
title: > | |
{{ logfile_title | string | trim }} | |
message: > | |
{{ as_timestamp(now()) | timestamp_custom('%d-%b-%Y %H:%M') + " [" + message_preamble | string | trim + "] " + message_body | string | trim }} | |
continue_on_error: true |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment