jcgoette / baby_buddy_homeassistant

This custom integration provides sensors for Baby Buddy API endpoints.
MIT License
64 stars 30 forks source link

Activity data as time series #57

Closed danepowell closed 2 years ago

danepowell commented 2 years ago

This add-on is great for the use case of seeing the last time baby was fed, changed, etc. However, I'm having trouble using it to view historical data and trends because the sensors don't represent true time series.

For comparison, look at how most sensors are plotted in the history tab of HA: Screenshot 2022-03-08 155339

Imagine if one of those sensors was "sleeping", so you could see a state timeline of when your baby slept. That's what I want.

(Edited to make the desired output clearer and remove references to other programs)

jcgoette commented 2 years ago

Unfortunately, I don't know anything about InfluxDB or Grafana.

Would the proposed changes in https://github.com/jcgoette/baby_buddy_homeassistant/issues/45#issuecomment-965972097 help?

danepowell commented 2 years ago

I'm not sure I understand the intent of adding a new sensor, but it doesn't sound like a fix. Although #45 as a whole is another footgun that I've run across 😄

I'm still getting to know HA / InfluxDB / Grafana, but my understanding is that they all rely on time series data, which in the case of Baby Buddy would look something like:

Time Activity
14:05 Feeding
14:10 Feeding
14:15 Sleeping

This format is great because it can be easily translated into state timelines that look like this (this one is from the Huckleberry app, each color is a different activity): Screenshot 2022-03-08 154451

The sensor.baby_last_feeding format isn't a time series and is difficult or impossible to parse in the same way. It also leads to unexpected behavior, i.e. if you forgot to log a feed that took place before the latest feed and add it in Baby Buddy, it will never show up in HA.

Having said all that: I'm realizing that sending true time series data from Baby Buddy to HA may be impossible because HA doesn't let you backdate or retroactively import sensor data. Since Baby Buddy allows you to start a timer and only label it as an activity after the fact, it would be impossible to get that data into HA 😢 I hope someone can tell me I'm wrong.

danepowell commented 2 years ago

Also just to clarify, while InfluxDB and Grafana are my preferred visualization tools, you can put them aside for the purposes of this issue. This is a problem with Baby Buddy's sensors in HA itself. Basically, I'd like for the baby activity sensors to look and work like all of the other sensors in the "History" tab: Screenshot 2022-03-08 155339

jcgoette commented 2 years ago

Since Baby Buddy allows you to start a timer and only label it as an activity after the fact, it would be impossible to get that data into HA 😢 I hope someone can tell me I'm wrong.

I think I understand what you're asking now.

What you're asking for is a binary_sensor and I think you're correct that this isn't feasible since 1. BabyBuddy only labels the timer at the end instant and 2. I don't know of a way to update a previous entity value.

danepowell commented 2 years ago

Yep, I think you're right on both counts: that's what I want, and it's not possible 😄

I'm realizing that Home Assistant is really bad for consuming manually-produced data. Data produced by people needs to be mutable (either by design, as with BB timers, or by accident, when people make mistakes). HA is really hostile to this since sensor data is essentially immutable.

If I can come up with any other constructive solutions, I'll open a new issue 😄