Constant selector

Has anyone been able to use or get working the Constant selector?

I haven’t used, but found this…

1 Like

Hi James, thanks for responding :+1:

I to have also seen this and have tried it but can’t seem to get it working. HA may not be very clear in this documentation as we have 2 different example, or it is just me not understanding it. I am sure it will work once we know the correct way to set this up. The closest I could get was to insert a default but there was no tick box.

Release notes code

    example:
      name: Constant selector example
      default: []
      selector:
        constant:
          label: Enabled
          value: true

The code that they (HA) have provided in selectors… I have had no luck.

boolean:
  value: true
  label: Enabled

Maybe someone will read this that do the documentation and fix it up for us or just let us know what I am doing wrong.

I’m not sure what to expect, but I pasted the sample code in and it didn’t error. Not sure what it is supposed to do, but it saves and was available as an input that didn’t do anything.
What are we expecting this to actually do? I mean the selector sets the only option, it really isn’t an !input at all, is it? Just add a variable that holds your ‘constant’.

There was an error in the VSCode yaml parser but that doesn’t always mean anything. There should be an issue added to Issues · keesschollaart81/vscode-home-assistant · GitHub so someone can fix that there.
Screenshot_20230526_203053

This change is only a month old or so and the VScode parser usually lags the HA implementation and these things pop up until they are fixed.

Yep, it has never work from day 1… or I couldn’t ever get it working. But it must work as it was a new feature right. Documentation is confusing and I could never get the tick box so it would do something.

I did post and issue to GitHub but got nothing.

Maybe someone will fix it or jump in and let us know what we are doing wrong.

Probably just be used in a condition. That is what I was thinking to use it for.

It doesn’t error. It seems to present a constant. It’s just conceived weirdly. IE there is no constant ‘entities’ that you can select, you generate the constant in the selector. You are able to turn it on and off outside of that, but off means blank, on means the constant word assigned. Plus the 'selector doesn’t appear to include the ability to turn it on or off. In no way is any of that a ‘selector’. I can do that all easily as a variable.
I agree I don’t understand it, but I don’t think it’s broken.

I would expect a constant be something set-up outside of the selector, like a constant helper, and the selector be the ability to pick one of the created constants. My thought is it’s missing that, but I really don’t know what the plan was here.

The thing we are missing is the tick option and I dont think there should have to be a default if you don’t need one. My understanding is, it only provides one value you set. So if someone tick the box then it can be “true” or any wording you put in the value. Then you can use that in a condition. I am not 100% sure on this as we can’t test it. My gut feeling is, they (HA) uploaded an old code file and haven’t realised it.

1 Like

@emontnemery and @piitaya

Could you please advise us on the above constant selector.

Thank you

Blacky :smiley:

1 Like

I figured out more about this ‘constant’ selector.
It works as advertised when used as a field in a script. That must of been the intended use. However it still appears broken when used in a BP…

In case anyone might come across this thread later—while I agree that the constant syntax covered in the official docs is pretty vague slash broken, I’ve had some success through using the constant syntax that’s covered in the release notes from when this feature was introduced:

example:
  name: Constant selector example
  selector:
    constant:
      label: Enabled
      value: true

What did you gain by using it? Can the BP user affect it in any way when creating a new BP?
I was able to get it to show up, but it was better replaced by a variable because the BP user could see it but not select anything. This is why the question if it’s a selector or not.

If there were perhaps a constant helper entity created, then use this selector to select one, that would work. This thing is a puzzle indeed.

@handcoding

Hi Ashley, I have tryed again today on HA 2023.6.2 and still not working here and I had to put in a default. Without the default the automation disappears from section.

    example:
      name: Constant selector example
      default: []
      selector:
        constant:
          label: Enabled
          value: true

And I get this

@Blacky @Sir_Goodenough I perhaps should have clarified this earlier, but it so happens that I’ve only messed about with the constant selector in scripts—when I’ve tried constant in a script, it appears to work as the release notes described when the feature was introduced.

My bad if I may have led you on a bit of a goose chase if it so happens that constant might be broken in blueprints—which sounds like it may be the case? Sorry about that.

1 Like

Not everyone agrees…

Also the release notes specifically state this was intended for blueprints, scripts are not mentioned. I agree it works slightly better in a Script selector, but even then a variable would be almost as useful.

@handcoding @Sir_Goodenough

Thanks Ashley :+1:

I agree James, I don’t know why you would release something that doesn’t work. I will tag the ones who created it again encase they are unaware it is broken or they need to fix up any documentation so we don’t waste time trying to get it working.

@emontnemery and @piitaya