How to use sensors/entities within actions?

Hi there,

What I would like to do is create a conditional card (that only shows on the dashboard in certain conditions). That works. But what I want it to contain is a warning tekst and also using the content of a specific sensor. In this case I want to display a warning when visibility is below 500m.

For instance:

Warning Visibility belof 500m. Current visibility 450m

Where "450m* should be the actual visibility derived from sensor.knmi_zicht

What I have so fare is:

I’ve created a helper “Mist” of the type input.text

I’ve created an automation with the follwing code:

alias: Mist onder 500m
description: Test of de mist onder 500m zicht is en toont een waarschuwing via Helper Mist
triggers:
  - trigger: numeric_state
    entity_id:
      - sensor.knmi_zicht
    below: 500
conditions: []
actions:
  - action: input_text.set_value
    metadata: {}
    data:
      value: "*WARNING*: Visibility below 500m"
    target:
      entity_id: input_text.mist
mode: single

This works and it shows the text behind ‘value’ in the card.
Now I would like to add the current visibility (eg. the content of sensor.knmi_zicht) to the text so that it reads

WARNING: Visibility below 500m. Current visibility xxxm

Where xxx obviously is the content of the sensor.knmi_zicht

I’ve been searching for this but haven’t found a solution. Sorry for those that feel this is a noob question…correct…I am :slight_smile:

Ow and perhaps, if you can. Please tell me how to format text within standard cards so that I can make WARNING bold or even a different font type. Thanks

You can use Templating to get the value of your sensor into the text:

alias: Mist onder 500m
description: Test of de mist onder 500m zicht is en toont een waarschuwing via Helper Mist
triggers:
  - trigger: numeric_state
    entity_id:
      - sensor.knmi_zicht
    below: 500
conditions: []
actions:
  - action: input_text.set_value
    metadata: {}
    data:
      value: "*WARNING*: Visibility below 500m. Current visibility is {{ states('sensor.knmi_zicht') }}m"
    target:
      entity_id: input_text.mist
mode: single

I’m not sure what I did wrong but I couldn’t get this to work, but this does. Thank you!!

Do you know if there is a way to format the text too? I really want the message to pop out if there is low visibility.