Im using custom logbook entries to display a logbook card on a dashboard.
Im doing this through the use of an automation to log the custom entry into a template sensor which is then displayed on the dashboard in a logbook card.
Everything is working great BUT, Id really like to truncate the entry to just what is in the Automation.
The Automation:
alias: testing logbook formatting
trigger:
- platform: state
entity_id: switch1.test
to: "on"
id: switch1_test_on
action:
- choose:
- conditions:
- condition: trigger
id: switch1_test_on
sequence:
- service: logbook.log
data:
name: Switch1
message: " was turned on from the front right hand panel"
entity_id: sensor.switch1_logbook
The sensor template:
sensors:
switch1_logbook:
value_template: ''
The card:
cards:
- type: logbook
entities:
- sensor.switch1_logbook
What gets displayed in the card is:
Switch1 was turned on from the front right hand panel triggered by automation testing logbook formatting triggered by state of switch1.test
What I’d really like is to truncate all the un-needed info to the right of the message so it looks like this:
Switch1 was turned on from the front right hand panel
Any ideas as to how to achieve this?
Perhaps a jinja template that truncates everything to the right of triggered by
???
I Ive done a bit of research and .split
may be a way of achieving this but my understanding of the logbook card doesnt quite work.
Ive taken a look in the states history and logbook of sensor.switch1_logbook and it is blank (obviously because of the template). It would appear that in the automation, the - service: logbook.log
doesnt log anything to entity_id: sensor.switch1_logbook
However the automation data (name: message:) DOES show up in a logbook card.
Any help in how to achieve this would be appreciated.