Buttons + custom log entries?

I’m trying to work out a way to create a log that is added to via buttons.

i.e. when button 1 is pressed, lovelace card has entry added “date and time Button 1 pressed”

I’m looking for something similar. I think we need to made a Sensor that holds the time but I’m not sure how to do it. Something like this:

sensor:
       - platform: time_date
         display_options:
         - 'time'

So i did solve this eventually although it might be a bit of a novice method. I’ll note down my method and post for you

So:

Shopping List integration (main integrations, not HACS) needs to be installed, along with the custom button HACS addon and the browser mod addon.

This is my button for adding the new entry to my list, which is does by triggering an automation. (i’ve got a new born baby whose feeds and poos i’m tracking hence the names haha). Even writing this out i realised i was over cooking the process so have simplified and put the newer method.

type: custom:button-card
tap_action:
  action: call-service
  service: automation.trigger
  service_data:
    entity_id: automation.poop_logging_toggle

I’ve also got a text helper called input_text.poops

This is the automation the button triggers:

alias: Poop Logging Toggle
description: ''
trigger: []
condition: []
action:
  - service: input_text.set_value
    data:
      value: '{{ now().strftime("%d/%m/%Y: %H:%M") }}: Poop'
    target:
      entity_id: input_text.poops_add
  - service: shopping_list.add_item
    data:
      name: '{{ states.input_text.poops_add.state }}'
  - service: browser_mod.lovelace_reload
    data: {}
mode: single

Essentially pressing the button, triggers the automation. The automation:
Adds a value to the text helper consisting of the date and time and “poop”
Adds the value now stored in the text helper to my shopping list using the add_item service
Reloads the lovelace view using the browser mod so that the added item shows up immediately without needing to manually refresh.

I’ve got buttons, automations and helpers for each item i want to track. So any of the 4 buttons add the same formatted note but with “Poop” “Wee” “Feed” and so on

Having posted that, i’ve dimplified it even more. You can skip having the text helper and just directly add the required info to the shopping list by using the “value” as “name” i.e.

alias: Poop Logging Toggle
description: ''
trigger: []
condition: []
action:
  - service: shopping_list.add_item
    data:
      name: '{{ now().strftime("%d/%m/%Y: %H:%M") }}: Poop'
  - service: browser_mod.lovelace_reload
    data: {}
mode: single

Nice, I will give this a try at some point. I think I’m using it for something very similar :stuck_out_tongue:

Hopefully it helps! Haha, it’s one of those “there’s already an app for that but I want to make something” situations

Any reason you can’t just use the built-in logbook?

  1. Make input buttons called “Log poop”, “Log wee” and “Log feed”
  2. Put them on your dashboard
  3. Next to the buttons drop a logbook card like this:
- type: logbook
  entities:
    - input_button.log_feed
    - input_button.log_poop
    - input_button.log_wee
  hours_to_show: 168 # Or whatever you want
  1. Click buttons to log events, see the log in the card.
1 Like

For me that’s exactly what I want. Just a sensor that stores the datetime when the button was pressed. Then I should be able to go back in the log book and see the times it was set to.

I don’t think a sensor is needed tbh. The state of a button is the last time it was pressed and logbook will have an entry showing each time it is pressed. So I think all you need is an input button, nothing else. There’s no action to configure, just press it when you want to record something happened and view the history of the button itself.

EDIT: Just to clarify, I’m talking about an input_button entity. I’m not talking about a button card, those are two different things.

haha! Yes a reason: stupidity :D. That would have been much simpler, although i’m always happy to have had a reason to play around with other bits. Cheers, i’m gunna try the logbook out now