Question how to get a variable from configuration ( if possible)

Hi ,

Is there any way i can get access and use a varabele stored in the configuration.yaml

Demo config:

  • platform: manual_mqtt
    state_topic: home/alarm
    command_topic: home/alarm/set
    name: Home Alarm
    code: 1234
    pending_time: 30

What i want is the value of the pending time to use it in an automation. I tried to put the data in secrets.yaml but you can’t use !secret in a scripts.yaml. It will result in :
Invalid config for [script]: invalid template (TemplateSyntaxError: unexpected char ‘!’ at 21) for dictionary value @ data[‘script’][‘abort_pending_alarm’][‘sequence’][1][‘data_template’][‘message’]. Got ‘Alarm geannuleerd {{ !secret alarm_pending_sec }}’. (See /config/configuration.yaml, line 95).

Please help

Go to Developer Tools > States and look at the Attributes column for alarm_control_panel.home_alarm. If pending_time is shown there, you can use the state_attr function to get its value.

If it’s not shown, I don’t know of a way to get its value.

Unfortunately it’s not there, but thanks for trying helping me out.

Anyone other suggestions?

There are at least two custom_components (posted in this forum) designed to create and store variables. These variables are accessible to automations, scripts, etc. However, I suspect neither will be helpful because the pending_time option requires a value that is immediately available to the YAML interpreter on startup and can’t be based on a templated value.

I don’t think there’s a way of defining a value that is accessible to pending_time and automations, scripts, etc.