#Dashboard for manually inputting data and displaying datapoints in a graph

1 messages · Page 1 of 1 (latest)

dense crown
#

Hi,

So I'm getting into creating dashboards for the first time, and I'm having quite a bit of trouble.

What I want:
I want to track the weight of my pet and as it grows up to ensure it's staying healthy. I do this by weighing it a couple of times a week. I want to input this data somewhere and then I get a datapoint which can be plotted on a graph. and then I can view history of the weight progression and the data should persist forever. This would be a very simply task for a spreadsheet, but I was thinking that surely I can put this into a home assistant dashboard where it would be convenient to access right next to all other pet related things I will have on this dashboard.

However, it turns out setting this up with home assistant has been extremely difficult for me.
After many painful hours of cooking something up with chatgpt and finding up all sorts of annoying shortcomings, I finally got something that is somewhat ok, but far from pretty.

The attached image is what I got done so far. Getting this done was after many pain points:

  • number input cant be used because it just seemingly has to open some dialog for data input and clicking up/down arrows on the data input just spams loads of datapoint even though I'm just trying to input one value
  • had to go with a text helper for entry, hidden number helper for actually storing the data, save script that sets the text input's value to the number input. and then history graph for visualizing the number input

Now this was kind of ok I thought (though very far away from how clean of a result a spreadsheet could produce, wife approval factor might not be good here), but then I learned that my data wont be stored forever. trying to learn about how to make the data be stored has been a pain again. honestly I just want to be able to store all datapoints and see a historical graph of all the datapoints.

any tips on how I should approach this dashboard would be greatly appreciated, thanks.

dense crown
#

ok, it seems I can integrate google sheets to home assistant. honestly I think this is probably the way to (assuming someone doesnt give me some nice tip for a HA native way of doing this). but this would reqire the ability for for the HA dashboard to cleanly display the graph google sheets would generate. I wonder if that's possible

magic acorn
#

Yeah this isn't easy to do, but it is possible. Google sheets can't natively be charted in HA.

Data is stored forever in long term statistics if it is stored in a sensor entity with a state_class: measurement.

The way I do this is to have a script with an input field of weight, and that script fires a custom event when run.
Then you have a triggered template sensor that picks up the value from the event when the event is detected.

That template sensor will record the weight forever.

#

Script looks like this:

alias: Weight Report
sequence:
  - event: custom_weigh_in
    event_data:
      weight: "{{ weight }}"
fields:
  weight:
    selector:
      number:
        unit_of_measurement: lbs
        min: 1
        max: 300
        mode: box
        step: 0.1
    name: Weight
    description: Current weight in lbs
    required: true
#

And the template sensor:

- trigger:
    - trigger: event
      event_type: custom_weigh_in
  sensor:
    - name: Weight
      unique_id: custom_weight
      state_class: measurement
      device_class: weight
      unit_of_measurement: lb
      state: >
        {{ trigger.event.data.weight | float(-1)}}
      attributes:
        record_date: "{{ now() }}"
dense crown
magic acorn
#

Just with a statistics graph card.

#

I only update data every couple months so it's pretty flat, but you can do it more often if you want.

dense crown
# magic acorn Just with a statistics graph card.

initially I had some sensor & statistics graph setup and I was diappointed that I only got the statistics graph to some some aggregate values, and if I added a new datapoint it took quite some time for the graph to even update to show this. was I maybe just doing something wrong? I just added it via the UI wizard, didnt look into its yaml config.

magic acorn
#

Statistics is generally aggregated hourly. That shouldn't be a problem for a sensor you only update couple times a week?

dense crown
# magic acorn Statistics is generally aggregated hourly. That shouldn't be a problem for a sen...

well I guess not strictly speaking a problem, but honestly quite annoying and not the best UX when you cant see that the data entry went through.
also I was kinda thinking that stats graph was the wrong tool for the job since it could only show mean, min, max etc. I just want to see datapoints and a line plotted through them. but if history graph cant be used here, I guess there isnt a component for this. unless maybe something over on hacs. (I'm open to using hacs if needed, I have it installed and have used it before)

magic acorn
#

If you want to show long term history, then statistics graph is the right tool.
I wouldn't worry about min/mean/max, for infrequently updated data they will all be the same. You can just plot the mean.

#

If you need instant feedback you can add a tile card with the current value.

dense crown
#

yeah ok. well I will see about this. thanks for your input.

maybe will also look into the google sheets integration.
when you said "Google sheets can't natively be charted in HA", what did you exactly mean by that?

when I was exploring the google sheets option, chatgpt said I could do this:

type: iframe
url: https://docs.google.com/spreadsheets/d/e/…your_chart_embed_url…/pubchart?oid=123456&format=interactive
aspect_ratio: 75%

didnt try it, but I would believe this is possible, since I see that you can indeed embed iframes. not sure how pretty it would look though and how interactable it actually is

magic acorn
#

you can try

#

it will look pretty kludgey

#

You can also use something like ApexCharts to draw custom charts, but that's not native HA.