I would create a warning code in markdown card

I would create a warning code that the carbon level has risen to more than 2000 parts per million. In this card, I did this code, but I did not know how to put it. If the rate is less than 2000, it is normal, and if it is greater than 2000, a note is written.

{% if is_state('sensor.blueair_my_room_co2', '1000') %}
 <ha-alert alert-type="success">
CO2 levels are normal.
</ha-alert>
{% else %} <ha-alert alert-type="error">
Warning: CO2 levels are high in my room!
</ha-alert> {% endif %}

Can I write this code like this:

{% if is_state('sensor.blueair_my_room_co2',  <  '1000') %}

Yes the markdown card accepts jinja templates. Though your template is incorrect. It should be:

{% if is_state('sensor.blueair_my_room_co2')|float(0)  <  1000 %}

tom_l
I appreciate the speed of your response, and I thank you for that, but the code that you corrected was incomplete state and I completed it

{% if is_state('sensor.blueair_my_room_co2', '  ' ) | float(0) > 1000 %}

and indicated the warning, but it does not change with the change of the sensor reading

Actually I forgot to edit one part of the template when copying yours. It should have been:

{% if states('sensor.blueair_my_room_co2') | float(0) > 1000 %}

Dear tom_l Thank you very much, for this interaction. It went so well

1 Like