Hi
Is there a way to pass info in the secret.yaml into the code used for a template sensor?
This doesn’t work, but is an example of what I’m trying to do: {% if is_state('binary_sensor.myphone_wifi_state','on') and is_state('sensor.myphone_wifi_connection',"!secret ATrustedWifiSSID") %}
I’m not aware of any option like that. Maybe somebody else has knowledge of one.
In any case, maybe a useful workaround is to create an input_boolean and set/clear that one using an automation that triggers on the sensor.myphone_wifi_connection state. I think you can use a secret inside automation variables which you can then use in the action to compare with the current state to set the input_boolean.
Something like this (didn’t test the automation):
trigger:
- platform: state
entity_id: "sensor.myphone_wifi_connection"
to: null # = any state
variables:
secret: !secret "ATrustedWifiSSID"
actions:
- service: "{{ 'input_boolean.turn_' + ('on' if is_state('sensor.myphone_wifi_connection', secret) else 'off') }}"
entity_id: input_boolean.myphone_wifi_state
The !secret gainloss (used as value_template: !secret gainloss in an external template) showed value if input_boolean.hide = on and showed “X” if it = off.
This works good until core update (2023.5.1 from 2022.12.9).
I do not find specific “breaking changes”… How to fix this, keeping the template in secrets.yaml?
I try with modern template but in secrets.yaml does not work (the entity is not created).
Tks
EDIT: I solved. if the unit_of_measurement: of sensor is i.e. “€” it does not validate the string "x"