Select Selector SOLVED

I’m working on a Blueprint and can’t seem to find the proper way to handle something. Some of the options won’t make any sense and the user should not have to fill them out. Let’s say they are picking between a bicycle and a car. It makes no sense for me to present them with the option “Moon roof”. If I can’t hide the options that is fine but at the least I need a way to set a default option so the automation doesn’t fail. Some of the error messages aren’t that helpful to me as a newbie to blueprints. I don’t see a way to add a default in the documentation. I believe there might be a way to fix this in the variables section but not quite sure how to do that.

Thanks!

    vehicle:
      name: Vehicle
      selector:
        select:
          mode: dropdown 
          options:
            - label: "Car"
              value: "car"
            - label: "Bike"
              value: "bicycle"


    moon_roof:
      name: top
      selector:
        select:
          mode: dropdown 
          options:
            - label: "Yes"
              value: "Moon Roof"
            - label: "No"
              value: " "

Have you tried setting a default: indented to be inline with name and selector?

Alternatively, moon_roof looks like a good candidate for a boolean selector.

1 Like

That’s a good idea for some of my options but unfortunately others have multiple selections so binary is not possible.

That gives me
Failed to load blueprint: while parsing a block mapping

Thanks for the input! :rofl:

Based on your feedback I thought perhaps I could use a boolean with an if then statement in the variable section. I thought if I didn’t actually try to grab the variable that was left blank HA would not care it was blank. I tried variants of the following logic but unfortunately HA still complained when moon_roof was left empty.

moon_roof ="No" if boolean == false else moon_roof = !input moon_roof

Oh well… For the foreseeable future I will have to make sure the end user fills out every selector. My blueprint should be completely function. I’m currently letting it run to see how it handles real data. Then I’ll open it up for others to play with.

Thanks again for your feedback!

The best way that I have found to learn how to do something in HA coding is first, read the docs and find out what you can and cannot do. This is not always clear but gives you some guidance. After that I go into the forums here and search out where someone else does it. The blueprint exchange, I’m certain, has an example of someone else doing something similar. Here is a link to where I use that select selector with defaults to pick a weekday (or multiple). Leaving out the list of defaults will default it as empty.

Thanks! I did indeed read the documentation but Select Selector did not mention defaults. I then started looking at other peoples code but could not find what I needed. Finally I posted here. I don’t know what the heck I did wrong because I even put it at that same indentation level when @SgtBatten suggested it yesterday. Whatever I did wrong yesterday it now works today.

Thanks to both of you for your help!

2 Likes