Sensor.daylight in automations

I want to trigger to switch on lights when when sensor value daylight goes from true to  false.
But it's not working. what am i missing?
Some details:
Virrual sensor comes with installation of ConBee II.

alias: voorkamer
"description: ''
  - platform: state
    entity_id: sensor.daylight
    attribute: daylight
    from: 'true'
    to: 'false'
condition: []
  - type: turn_on
    device_id: 2538dddee83e38f1a9d4c4fb30851cab
    entity_id: switch.shelly1_e09806a9da55
    domain: switch
mode: restart


Try removing the quotes around true/false.

1 Like

Hi, @PeterSch - Welcome to the community! I’m not familiar with this particular sensor. Did removing the quotes as @Burningstone suggested work? If that’s not it, then take a look at the sensor contents within the developer/states panel and let us know what’s in there. All the attributes will be listed on the right side of the table. I’m looking for the actual names of the attributes and some of the values. If they are really booleans, then @Burningstone’s suggestion is spot-on and is the solution.

For future efforts, HA distinguishes between a boolean and a string that, on the surface, may look the same. For example,

true is NOT the same as 'true'
 ^                        ^
This is                 This is a
boolean                   string

These are not the same. The easiest way I’ve found to figure it out is using the developer/states page to see what’s really inside the sensor.

But I’m pretty sure @Burningstone nailed it.

1 Like


Thanks for the responses.
I have tried this, but no affect.
It looks like the value of attribute sensor.daylight cannot be used for state change?


  - platform: template
    value_template: '{{ state_attr("sensor.daylight", "daylight") == false }}'
1 Like

Let us know if this works - this is an odd one. If it does, then that suggests the attribute never goes from true to false. It may go from something else to false (??), but the value_template should trigger in either case.

I should have asked this in the first place - are there any relevant errors or warnings in the log?

One other thought - with @cloak’s suggestion, you can test it out in the developer/template panel. Just copy the information within the braces (including the braces but not the single quotes) to the template test section and see what it provides. You can interrogate other attributes in this way, too.

1 Like

Hello, this worked!.

1 Like