Packages in secrets

I am using packages in secrets for a code which I am using a lot, like this:

glob_package__slider_percent:
  min: 1
  max: 100
  step: 1
  mode: slider
  unit_of_measurement: '%'

Usage:

input_number:
  filter_dust_level_critical: !secret glob_package__slider_percent

Or this example for Lovelace:

glob_package__lovelace_sort_options_name:
  method: name
  reverse: false
  ignore_case: true
  attribute: null
  first: 0
  count: 1000
  numeric: false

This package is used inside auto-entities cards.

Surely these are not secrets - and these packages will be not available for people if I decide to publish my setup on GitHub. But I needed a possibility to have globally available data like units, persons’ names, IPs etc - and decided to keep this info in secrets. Then added some common packages too.

The 1st example works fine - but what I would like to add more options inside the input_number entity?

This is what is not permitted:

input_number:
  filter_dust_level_critical:
    <<: !secret glob_package__slider_percent
    icon: mdi:car

or this:

input_number:
  filter_dust_level_critical:
    !secret glob_package__slider_percent
    icon: mdi:car

The question - is it possible to use “secret packages” along with other options?

Any thoughts?

It is partly possible for helpers to merge secrets with other dict.
Assume there is a secret:

test__glob_package__input_number_level:
  min: 0
  max: 100
  mode: slider

which is a part of input_number.

I cannot create these helpers:

input_number:
  number_1:
    !secret test__glob_package__input_number_level
    icon: mdi:car
  number_2:
    !secret test__glob_package__input_number_level
    icon: mdi:account

But I may use a trick described here:

input_number:
  number_1: !secret test__glob_package__input_number_level
  number_2: !secret test__glob_package__input_number_level
input_number:
  number_1:
    icon: mdi:car
  number_2:
    icon: mdi:account

These 2 parts are merged:

For sensors & other places - seems merging “secret + dict” not possible.

Nice work! :+1:

But why are you using it this way, I mean, what advantage do you get with the outsourcing into secrets.yaml? :slight_smile:

Hmmm, may be because I do not want to repeat same code in many places in different files?
(alternatively you may use “include”, same story)

Interesting, I wouldn’t have thought of that way! :slight_smile: Thanks! :smiley: