Generic log/history

Hi,
I’m quite new in the “Home Assistant”-world. I was a long time iobroker user, then switched to openHAB and now I’m trying to find out how to get best out of HA.

One thing I haven’t found so far is how to implement some sort of generic log.
For example I would like to have a phone call history (last five missed calls) or the last x times someone hit the doorbell or the last x times the garden door was opened, …

In openHAB I had several string ‘item’ s for this use cases. I just wrote my message into this item and set the persistence to ‘on change’ (so only true changes are recorded). Then I was able to present this messages via InfluxDB->Grafana as table in my UI.
Is there a generic solution for this use case in HA or is using InfluxDB+Grafana the best solution in HA too?

You could use the file notifier:

Sounds interesting, but the documentation says ‘Only the last line of the file is used’. Is it possible to select more than one line from the text file using the file sensor?

Take a look at the history statistics sensor

But according to the documentation the history statistics sensor would only give me the count of missed calls in a given period of time and not something i can visualize as a table?

What I’m trying to do is to show a table or list in the UI like this as example:

26.07.2019 05:30 call from 012345
26.07.2019 06:56 call from 1234567
26.07.2019 06:56 call from 6234567
26.07.2019 06:56 call from 7234567
26.07.2019 06:56 call from 8234567

…and similar tables/list for other events.

I just thought it might take a little script from the shell and then when the sensor triggers get the “tail” of the text, which is passed to another file.
Is it awkward?

Use the file notification service to write lines to the file. Don’t use the file sensor to to feed grafana. I know pretty much nothing about grafana but could it not read the file directly?

If I have to use Grafana to display the table, then I’ll use InfluxDB as data source and target.
This will be the same way as I did it in openHAB.
Well…at least if an ‘input_text’ is accepted as entity in the InfluxDB config in HA.

Maybe it’s interesting for others too…

I realized my logbooks by defining “input_text” values:

input_text:
  log_telefon:
    name: Anrufe  
  log_general:
    name: Allgemein

In the “action” part of a “Automation” I insert:

  action:
    - service: input_text.set_value
      data_template:
        entity_id: input_text.log_general
        value: "{{'Haustür wurde geöffnet.'}}"

In the influxDB part of configuration.yaml:

influxdb:
  username: !secret influxdb_user
  password: !secret influxdb_password
  host: !secret myhost
  max_retries: 3  
  include:
    entities:
      #Logbücher
      - input_text.log_general
      - input_text.log_telefon

That’s the “Home Assistant” part…

In Grafana I format the values as table and present the dashboard in an iFrame in Home Assistant.

This is far from perfect, but at least I have my logbook. :smiley: