Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to specify start & end time for pumping #122

Open
seanhagen opened this issue Aug 4, 2023 · 3 comments
Open

Unable to specify start & end time for pumping #122

seanhagen opened this issue Aug 4, 2023 · 3 comments
Labels
enhancement New feature or request

Comments

@seanhagen
Copy link

I'm trying to add a button that will add a pumping entry with a specific start and end time, but that doesn't seem to be possible currently.

When I add the button via the Lovelace UI, this is the YAML that gets created:

show_name: true
show_icon: true
type: button
tap_action:
  action: call-service
  service: babybuddy.add_pumping
  target:
    entity_id: sensor.baby_name
  data:
    amount: 33
    time: '22:33:00'
entity: sensor.baby_name
name: Add Pumping

I've tried using a template, and just entering in specific values -- nothing seems to work for setting the start time.

I looked at the OpenAPI schema ( which I found by going to /api/schema on my Baby Buddy instance ) and the arguments for adding a pumping don't specify time as a field:

    Pumping:
      type: object
      properties:
        id:
          type: integer
          readOnly: true
        child:
          type: integer
        amount:
          type: number
        start:
          type: string
          format: date-time
        end:
          type: string
          format: date-time
        duration:
          type: string
          readOnly: true
          nullable: true
        notes:
          type: string
          nullable: true
        tags:
          type: array
          items:
            type: string
      required:
      - child
      - amount

It looks like the API supports setting a start and end time as of version 2.0.0, same as for feedings -- but the code is only sending a time field.

I've tried to update the code so that it has a start and end like async_add_feeding and created a PR: #121 -- I'm not a Python dev though, I'm a Go dev; so I probably missed something 😅

@jcgoette jcgoette added the enhancement New feature or request label Aug 5, 2023
@Ksp3cialK
Copy link

I have tried playing with adding this myself and had no luck, the wife has been asking for this feature!

@brylee123
Copy link

This one issue was throwing me off. I was setting a time via the service call but it was not actually setting in baby buddy. I would like to bump this for a fix too

@20BBrown14
Copy link

I was running into this issue as well and was causing my wife frustration. I ended up using a rest_command within HA to replace the broken add_pumping service from this integration.
If you add this to your configuration.yaml for Home Assistant you can call the service as below

rest_command:
  add_pumping:
    url: [[your instance]]/api/pumping/ # be sure to set this to the address of your baby buddy instance
    method: POST
    headers:
      authorization: !secret baby_buddy_token # but auth token is stored in `secrets.yaml` in the format of `Token abc123`
      accept: "application/json, text/html"
    content_type:  'application/json'
    verify_ssl: false # This was false for me since I don't use ssl
    payload: '{"amount": "{{ amount }}", "notes": "{{ notes }}", "child": "{{ child }}", "start": "{{ start }}", "end": "{{ end }}"}'

Then in my automation I have

service: rest_command.add_pumping
data:
  start: >-
    {{(states('input_datetime.pumping_start_time') |
    as_datetime).strftime('%Y-%m-%dT%H:%M:%S')}}
  end: >-
    {{(states('input_datetime.pumping_start_time') |
    as_datetime).strftime('%Y-%m-%dT%H:%M:%S')}}
  amount: "{{states('input_number.pumping_amount')}}"
  notes: "{{states('input_text.pumping_notes') or ''}}"
  child: 1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

5 participants