-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlogfile_entry,yaml
85 lines (78 loc) · 2.67 KB
/
logfile_entry,yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
### ------------------------------------------------------------------------------------------------
###
### 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
### 06-Jul-2024: 1.0.3 Added seconds to the timestamp
### 23-Sep-2024: 1.0.4 Corrected notification service to not be required
###
### ------------------------------------------------------------------------------------------------
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: false
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_entity: >-
{% if notification_service | string | trim | length == 0 %}
{{ "" }}
{% else %}
{{ "notify." + notification_service | string | trim }}
{% endif %}
sequence:
- if:
- condition: template
value_template: >
{{ notification_service_entity != "" }}
- 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:%S') + " [" + message_preamble | string | trim + "] " + message_body | string | trim }}
continue_on_error: true