baby_buddy_homeassistant icon indicating copy to clipboard operation
baby_buddy_homeassistant copied to clipboard

Feeds/Sleeps/TummyTime that start before midnight and end after midnight are not saved.

Open brylee123 opened this issue 6 months ago • 0 comments

service: babybuddy.add_feeding
data:
  method: Bottle
  type: Fortified breast milk
  amount: >-
    {{ (states.input_number.bottle_pre_feed.state | int) - (states.input_number.bottle_post_feed.state | int) }}
  notes: Auto-Log from Smart Scale.
  start: >-
    {{ as_timestamp(states.input_datetime.baby_feed_start.state) | timestamp_custom('%H:%M:%S') }}
  end: "{{ now().strftime('%H:%M:%S') }}"
target:
  entity_id: switch.baby_timer

If a feed starts and ends on the same day, this is not an issue. It will populate the correct times for both fields. I am assuming since this service call only takes a time format instead of datetime, it assumes the times are all on the same date, which causes these issues.

My proposed solution is to use a datetime object across all the service calls. Pumping, tummy time, sleep, and feedings.

Edit: I want to point out that I am not using the timer feature as I am storing start and end times automatically in a sensor/input_datetime object. I am unsure on how to use the timer feature (via home assistant service calls) when I would need multiple timers to be simultaneously running. (sleep, feedings, etc)

brylee123 avatar Jan 02 '24 14:01 brylee123