Sensor gives unknown

Hello,

i am struggling my way into HA.
Got a lot of things done, with help of some of you, but now I am stuck.

I do have some sensors defines in configuration.yaml with the same problem. As example:

  - resource: http://10.0.0.3:8998/api/tags/process.json?presstrend
    scan_interval: 600
    sensor:
      - name: weer_buiten_trend_luchtdruk
        value_template: >-
            {{ value_json.presstrend }}

That gives - at the moment - a state of “Rising slowly”

But when I do:

{{ is_state('sensor.weer_buiten_trend_luchtdruk' , 'Rising slowly') }}

The answer is ‘false’

And when I do:

{% set state = states('sensor.sensor.weer_buiten_trend_luchtdruk') %}
{{ state }}          

The value of ‘state’ = unknown.

When I use the sensor in a template, you can see the state when entering the name. That has: ‘Rising slowly’
So the text is somewhere in the sensor, but cannot be used.

What do I do wrong?

First one: maybe it has a space at the end? Try this to see if there’s a space hiding there:

{{ "x"~states("sensor.weer_buiten_trend_luchtdruk")~"x" }}

Second: you have an extra sensor. in your template.

You’ve got an extra sensor. in there.

tried spaces: no result, still ‘unknown’

Double sensor is stupid from me, but it did not help.

getting rid of the second ‘sensor’ gives same result.

I also tried:

{{ is_state('sensor.weer_buiten_trend_luchtdruk' , '"Rising slowly"') }}

No result.

Still ‘unknown’.

That was false last time.

Please post the results from my template in post #2:

{{ "x"~states("sensor.weer_buiten_trend_luchtdruk")~"x" }}

See screenshot. Still ‘unknown’.

OK: and what about the States screen filtered for luchtdruk — like I’ve done here for octo:

Then the history graph for the sensor? Anything in the logs?

Go to Developer Tools > States, find sensor.weer_buiten_trend_luchtdruk and see what is reported for its state value.

If its state value is shown as unknown then that’s its actual value, not ‘Rising slowly’ as claimed by the popup message.


BTW, all of the tests you have already performed appear to confirm that the sensor’s state value is unknown so the UI’s popup is mistaken.


EDIT

Ninja’d by Troon

1 Like

States page:

History screen:

What’s the sensor’s value in the empty areas?

Data come from cumulus MX, what I started up today. Shut down, startup some times for testing purpose.
Shutdown = no data

A more complete screenshot:

Btw: restarted HA several times: also no difference.

Would it be fair to say that the empty slots in the history chart represent when the sensor’s value was unknown.

Currently, the sensor’s value in the history chart is Rising slowly and that’s the same value displayed in Developer Tools > States. However you’re saying the following template, when tested in the Template Editor, reports unknown instead of Rising slowly?

{{ states.sensor.weer_buiten_trend_luchtdruk.state }}

Paste copy gives as result:

get rid of last ‘state’ at the end:

Exactly: that what I don’t understand…

Sorry, have to leave now, to morrow I’ll be back…