Quantcast
Channel: Configuration - Home Assistant Community
Viewing all articles
Browse latest Browse all 107861

How can I set the option of a select entity using voice assistant sentence triggers in an automation?

$
0
0

I hope I am posting this in the correct place.
I have setup a baby buddy integration with my home assistant and have made a nice usable dashboard. Problem is when you are changing diapers or feeding you need a third hand to use the dashboard so voice assistant seems ideal for this scenario. Long story short I’ve created two automations so far that trigger with sentences and they seem to work.
My problem is that I feel there should be a better way to do it so before I spend more time adding more of these automations I thought maybe someone here has a better idea. The issue Im running into is how to “convert” a sentence variable to an option of a select entity. Part of my config is as follows and if I manage to sort that issue I should be able to combine all the permutations to a single automation per script.

- id: baby_voice_add_formula_feeding
  alias: (Baby) Voice Add Formula Feeding
  triggers:
    - trigger: conversation
      command:
        - "[Add ]feeding {number}[ml]"
        - "[Add ]feeding {number}[ml] formula"
        - "[Add ]formula {number}[ml]"
  conditions: []
  actions:
    - action: input_number.set_value
      data:
        value: "{{ trigger.slots.number }}"
        entity_id: input_number.feeding_amount
    - action: select.select_option
      target:
        entity_id: select.baby_buddy_feeding_method
      data:
        option: "Bottle"
    - action: select.select_option
      target:
        entity_id: select.baby_buddy_feeding_type
      data:
        option: "Formula"
    - action: script.turn_on
      target:
        entity_id: script.add_feeding
    - set_conversation_response: >
        I set the feeding amount to {{states('input_number.feeding_amount')}}, 
        feeding method to {{states('select.baby_buddy_feeding_method')}}, 
        feeding type to {{states('select.baby_buddy_feeding_type')}}
        And I added the feeding
  mode: single

- id: baby_voice_add_breast_milk_feeding
  alias: (Baby) Voice Add Breast Milk Feeding
  triggers:
    - trigger: conversation
      command:
        - "[Add ]breast [milk ]{number}[ml]"
        - "[Add ]breast [milk] [feeding ] {number}[ml] [with] [bottle]"
        - "[Add ]feeding {number}[ml] [with ]breast [milk]"
        - "[Add ]{number}[ml] breast [milk ][feeding]"
  conditions: []
  actions:
    - action: input_number.set_value
      data:
        value: "{{ trigger.slots.number }}"
        entity_id: input_number.feeding_amount
    - action: select.select_option
      target:
        entity_id: select.baby_buddy_feeding_method
      data:
        option: "Bottle"
    - action: select.select_option
      target:
        entity_id: select.baby_buddy_feeding_type
      data:
        option: "Breast milk"
    - action: script.turn_on
      target:
        entity_id: script.add_feeding
    - set_conversation_response: >
        I set the feeding amount to {{states('input_number.feeding_amount')}}, 
        feeding method to {{states('select.baby_buddy_feeding_method')}}, 
        feeding type to {{states('select.baby_buddy_feeding_type')}}
        And I added the feeding
  mode: single

As you can see each select has 3-4 options so as a fast workaround I thought not to define the ones I don’t need and create a separate automation based n the ones I do use.
But then for diaper change there are 4 colours that would be nice to be able to record. Although arguably if you see some of the colours you’ll be running to the doctor rather than worry about keeping records.
Any advice would be helpful. Thanks

2 posts - 2 participants

Read full topic


Viewing all articles
Browse latest Browse all 107861


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>