I have a sensor with states “Running, Stopping, Stopped/Ready” etc.
I can’t figure out how to get the state “Stopped/Ready” to be evaluated as true for a condition?
I have a sensor with states “Running, Stopping, Stopped/Ready” etc.
I can’t figure out how to get the state “Stopped/Ready” to be evaluated as true for a condition?
Can you post an example of what you’re trying?
What was unclear?
condition: state
entity_id: sensor.xxx
state: Stopped/Ready
Use quote marks
Try
condition: state
entity_id: sensor.xxx
state: "Stopped/Ready"
Everything was unclear–it was not possible to figure out what you’re doing wrong without the code. In principle, a / should be no different than a regular old letter, but context is everything.
condition: state
entity_id: sensor.afterburner_heater_state
state: "Stopped/Ready"
That does not help. Still not evaluated as true.
When your sensor is in that state, go to Developer Tools → Template and type in
{{ states('sensor.afterburner_heater_state') }}
What does it return?
It returns the state: Stopped/Ready
Unclear, then, what the problem might be.
Exactly. Let’s wait till someone with knowledge chimes in.
Does the template
{{ is_state('sensor.afterburner_heater_state', 'Stopped/Ready') }}
resolve True, when the sensor is in that state?
No. I get False
I have had a couple of cases where double quotes didn’t work but singles did.
try
state: 'Stopped/Ready'
edit: Just saw Didgeridrew beat me to it.
Could the state have a whitespace on either end of it?
What if we strip it…that should handle any hidden characters or whitespaces…
{{ states('sensor.afterburner_heater_state').strip() == 'Stopped/Ready' }}
I can’t find any whitespaces or hidden characters.
But
{{ states('sensor.afterburner_heater_state').strip() == 'Stopped/Ready' }}
Returns True
That’s a strange one… what integration is the sensor from?
Sure is strange. It comes in via Mqtt. No integration, just autodiscovery populating sensors and control. I’ve gone through the logs now looking at the payloads. Only received is the same as I see elsewhere. No obvious strange characters or whitespaces. Would be fun finding the fault of course, but for now lets evaluate the template instead in the condition. I’ll do a test run, seeing if other state values on those sensors give same problematic returns. Thanks for your help
I can’t find any whitespaces or hidden characters.
Where did you look? If you’re looking at the output of template editor it will be stripped.
Setting state with space:
{{ states('sensor.carbon_dioxide') }}
-{{ states('sensor.carbon_dioxide') }}-
Yes there’s whitespace. Use the template variant.