jcgoette / baby_buddy_homeassistant

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

Selector Template Documentation Example #72

Closed ahgray closed 2 years ago

ahgray commented 2 years ago

I'm sure this is probably just my ignorance but, I have a template that doesn't seem to work when I call baby buddy services even though it appears to return the right value in developer tools. Could you tell me what I'm doing wrong, it would also be nice to see some documentation regarding using the select options like this. I've got other things like adding sleep using the time working well.

"{{states('select.baby_buddy_diaper_color')}}"

Returns Brown etc as per the selected value. However in this card setup with buttons it returns the following error.

Failed to call service babybuddy/add_diaper_change. value must be one of ['Black', 'Brown', 'Green', 'Yellow'] for dictionary value @ data['color']

Card Code

 cards:
      - show_name: true
        show_icon: true
        type: button
        tap_action:
          action: call-service
          service: babybuddy.add_diaper_change
          data:
            color: '{{states(''select.baby_buddy_diaper_color'')}}'
            type: '{{states(''select.baby_buddy_diaper_type'')}}'
          target:
            entity_id: sensor.baby_callan_gray
        entity: ''
        name: 'Change Diaper '
        icon: mdi:emoticon-poop
      - show_name: true
        show_icon: true
jcgoette commented 2 years ago

Please properly format your YAML.

ahgray commented 2 years ago

Think i figgured out how to format it, does it look ok now?

Please properly format your YAML.

jcgoette commented 2 years ago

This is an older post, but probably still accurate.

ahgray commented 2 years ago

This is an older post, but probably still accurate.

This seems to resolve the issue. For anyone else or if you want to add to documentation/examples this is working.

Lovelace Buttons

 cards:
      - show_name: true
        show_icon: true
        type: button
        hold_action:
          action: call-service
          service: script.add_diaper_change_from_select_options
        entity: sensor.baby1_last_change
        name: Change Diaper
        icon: mdi:emoticon-poop
      - show_name: true
        show_icon: true
        type: button
        hold_action:
          action: call-service
          service: script.add_feeding_based_off_selected_options
        entity: sensor.baby1_last_feeding
        name: Add Feeding
        icon: mdi:baby-bottle-outline
      - show_name: true
        show_icon: true
        type: button
        hold_action:
          action: call-service
          service: babybuddy.add_sleep
          data:
            timer: true
            end: '00:00:00'
          target:
            entity_id: switch.baby1_timer
        entity: sensor.baby1_last_sleep
        name: Add Sleep
        icon: mdi:cradle-outline

Feeding Script

service: babybuddy.add_feeding
data:
  type: '{{states(''select.baby_buddy_feeding_type'')}}'
  method: '{{states(''select.baby_buddy_feeding_method'')}}'
  timer: true
target:
  entity_id: switch.baby1_timer