this post was submitted on 13 Jan 2024
41 points (95.6% liked)

homeassistant

12131 readers
22 users here now

Home Assistant is open source home automation that puts local control and privacy first. Powered by a worldwide community of tinkerers and DIY enthusiasts. Perfect to run on a Raspberry Pi or a local server. Available for free at home-assistant.io

founded 2 years ago
MODERATORS
41
submitted 10 months ago* (last edited 10 months ago) by Streusel to c/homeassistant
 

Im trying to create an event log Card that will show important events during absence, like shown in the attached screenshot.

The decision, what is relevant and how its displayed, can be done by node red (i already started to create the flows)

Node Red puts the events in a .txt file. To show this Log on my Dashboard, i tried the following: A command sensor is putting the content of the .txt in a sensor.

command_line:
  - sensor:
      command: 'cat /share/test.txt'
      name: awaylog

The .txt file already includs the formating for the text to be shown as alert-types (colored row with related icon). The sensor is then used in a Markdown Card.

Problem is, the sensor only seems to be capable of storing 255 characters. This limit exeeds quickly. (one alert-type command is already >50 characters) . If it is exeeded the result is shown as "unknown" (screenshot at the top)

Is anybody aware of a solution to avoid this chracter limit. Any other ideas to achiev such an event log ?

#Edit/Solution: Thanks to @[email protected] I just put the log entries in the json_attributes of the sensor and used the actual sensor value (because only this is limited to 255 char.) to just count up the number of log entries. Also i skipped the step creating a command sensor in Home assistant config.yaml, instead i used the sensor node to change it directly with node red.

Node-red sensor node config:


state = msg.logcount
json_attributes = msg.payload (formated log entry list)

Markdown card


type: markdown
entity_id:
  - sensor.absencelog_2
content: |
  ##  Absence Events
   {{state_attr('sensor.absencelog_2', 'json_attributes')}}
   
  *This list will be deleted when Marge is home again*

ps. Marge got a new phonenumber :P

you are viewing a single comment's thread
view the rest of the comments
[โ€“] [email protected] 7 points 10 months ago (1 children)

Can you use json_attributes instead of the state for the value?

Give this a read for some ideas:

https://community.home-assistant.io/t/rest-sensor-state-max-length-is-255-characters/31807/20

[โ€“] Streusel 1 points 10 months ago

Thank you, thats it :)