Conditional Card hide on state_not nil

I just want hide the card if the senor have no value.
I the condition set card I see “State (actual: ‘’)
I try state_not: ‘’ / nil / null / none / “’’” / '”"’ / ‘’’’’’
if the value is not empty, it return Warning weather alert like ‘Severe Thunderstorm Watch’
Thanks!

type: conditional
conditions:
  - entity: sensor.warnings
    state_not: ''
card:
  type: entity
  entity: sensor.warnings

Try:

state_not: None

No quotes.

I try none / None / ‘none’ to :frowning:

post a screenshot of the sensor in the states page showing the sensor state and attributes when the “senor have no value”.

It’s in french, but the code is the same

lovelace-prog

1 Like

None of those are the developer tools / states page.

There it is

try a space between the quotation marks

like:

state_not: " "

I just tried it on an empty sensor I have and it works for me like that.

I try the space ’ ’ and that did’nt work.
I try another idea, i create two new sensors, one to fill empty sensor and wnother one to be sure it work.
Good news, that patch the empty space! But, i don’t understant why, I can’t fill the sensor when it’s not empty. Look the “Fill Empty Warning” it’s supose to give “Heat Warning Value” and i just have “Value”

  - platform: template
    sensors:
      fill_empty_statements:
        friendly_name: 'Fill Empty Statement'
        value_template: >-
          {% set statement2 = states.sensor.statements.state %}
          {%- if statement2 == '' -%} none
          {%- else -%} 
            {{ statement2 }} Value
          {%- endif -%}

  - platform: template
    sensors:
      fill_empty_warning:
        friendly_name: 'Fill Empty Warning'
        value_template: >-
          {% set warning2 = states.sensor.warning.state %}
          {%- if warning2 == '' -%} none
          {%- else -%} 
            {{ warning2 }} Value
          {%- endif -%}

anyone has the proper solution to match the null/empty string for weathers tatements of sensor.statements in conditional card?

maybe

state_not: unavailable

or

state_not: null

or

 state_not: ''

?

Did you ever get this figured out? I assume you are using the Environment Canada Integration. Me too and I’d love to see how you set up the alerts/warnings/statements/etc. Thanks!

If someone still looking for a solution of this, this worked out for me (HA v.2023.3.3):

type: conditional
conditions:
  - entity: sensor.my_entity_status
    state_not: unavailable
card:
  <..>