Struggling with automation to turn lamp on with lux sensor level

@finity. Hmm - that’s food for thought. For these TP link plugs which are troublesome in HA, is there a way for the action to be something like “tell Google home to turn on xyz plug”, rather than directly trying to switch the plug in HA?

Not that I know of.

That’s why I mentioned that you could use both GH and HA for the automations that work best in those platforms.

Use GH for the TP-Link switch automations (if it can do that sort of thing?) and use HA for other stuff.

Sorry to jump on this old post, however it was exactly what I was looking for as I was trying to set the exact same thing up myself. Below is the code I’ve just tried and it works, I also have one for the weekends (different start times) and two for off. I added the 10 seconds to cut down on the number of log entries. Is there any way to reduce the log from filling up all day every day?

  alias: Weekday downstairs lights on by lux
  description: Auto lights on by lux level
  trigger:
  - platform: state
    entity_id:
    - sensor.lux_level
    for:
      hours: 0
      minutes: 0
      seconds: 10
  condition:
  - condition: time
    after: 06:00:00
    before: '23:30:00'
    weekday:
    - mon
    - tue
    - wed
    - thu
    - fri
    enabled: true
  - condition: template
    value_template: '{{ trigger.to_state.state | int <300 }}'
  action:
  - service: homeassistant.turn_on
    data: {}
    target:
      entity_id: group.lights
  mode: single

Not that I know of.

you might be able to exclude that automation from the logbook but I don’t think I would want to do that either.

I personally never look at the logbook so I don’t care how much something writes to it.

I look at the trace itself if there is an issue or the homeassistant.log file for more serious issues.

1 Like

This might suit your needs:

  alias: Weekday downstairs lights on by lux
  description: Auto lights on by lux level
  trigger:
  - platform: numeric_state
    entity_id: sensor.lux_level
    below: 300
    for:
      seconds: 10
  - platform: time
    at: '06:00:01'
  condition:
  - condition: time
    after: 06:00:00
    before: '23:30:00'
    weekday:
    - mon
    - tue
    - wed
    - thu
    - fri
    enabled: true
  - condition: template
    value_template: "{{ states('sensor.lux_level') | int(0) < 300 }}"
  action:
  - service: homeassistant.turn_on
    data: {}
    target:
      entity_id: group.lights
  mode: single
1 Like
trigger:
  - platform: numeric_state
    entity_id: sensor.lux_level
    below: 300
    for:
      seconds: 10

That was what I had originally, however, it doesn’t auto trigger (not for me anyway). Then I searched and found this thread.

What do you mean by “auto trigger”?

It’s a Numeric State Trigger so it will trigger at the moment when the light level decreases and crosses below the threshold of 300 (i.e. from above 300 to below 300).

Your version triggers every time the light level is less than 300 (that’s why there are so many entries in the Logbook).

1 Like

Yes, that is my problem, at 06:00 the light level will never drop below the threshold, it will always already be below.

That’s what I meant by auto start.

Or, what I could do then is create a weekdays turn the lights on at 06:00 and Weekends turn on at 08:00, then your adapted code would work as the lighting levels would then pass the thresholds. Thank you, that’s food for thought :slight_smile:

All working perfectly now, I’ve implemented your code amendments @123 and created the 6am and 8am lights on then tested the lighting levels and all working as I wanted and a tidier logbook.

Thank you for your patience and help, much appreciated.