Automations trigger light sensor

Hi

A simple question for some of you. But I can’t find the answer.

I have a light sensor when the sensor has a value between 0-450, a switch is on otherwise it is off. I have some conditions in time let’s say 0700 – 0900 and 1800-2200. If I manual turn the switch off, it should automatic turn on again.
(I tried with trigger and a numeric value. And conditions in time. But it allays work one day, the second day nothing happens. )
If the light sensor has a value 0, and turn the switch on at time 1800. Later I turn it off manual. The next day the sensor has not changed still 0, it will not turn on the switch at 0700
Do any one has a solution on this?

BR
Conney

Show us your code, formatted properly with the </> button.

If you are triggering on light level changing it will only trigger if the light level changes, at 0 it will not change. Therefore no trigger.

You need to trigger on the switch turning off and then check light level with a condition.

Trigger with time, then another trigger with the switch and condition with light level.

But as suggested show us your code.

HI again

I have tried with a script and it works.

alias: test ljus
sequence:
  - if:
      - condition: and
        conditions:
          - condition: device
            type: is_off
            device_id: fc1fb909e69445504d04fd2d086b99b6
            entity_id: light.kok_tak
            domain: light
          - condition: numeric_state
            entity_id: sensor.sensor_1_ljus
            above: -1
            below: 500
          - condition: time
            after: "07:00:00"
            before: "20:00:00"
            weekday:
              - mon
              - tue
              - thu
              - wed
              - fri
              - sat
              - sun
    then:
      - type: turn_on
        device_id: fc1fb909e69445504d04fd2d086b99b6
        entity_id: light.kok_tak
        domain: light
        brightness_pct: 1
    else:
      - delay:
          hours: 0
          minutes: 0
          seconds: 20
          milliseconds: 0
  - service: script.turn_on
    data: {}
    target:
      entity_id: script.test_ljus
mode: restart

Hi again.

I haven’t used this yet, but is there any other way to make this?
I must make an automation to start the script when I restart Home Assistant.

But my question I, is there any other way to check the value and turn on a lamp, instead of automations that is when a value reaches a specific number?

BR
Conney