Home Assistant beginners

alias: Hall @ night
description: Turn dimmed hall light on after dark when motion detected
trigger:
- type: motion
platform: device
device_id: 818546953f4583a966e13c6afdc86ff4
entity_id: binary_sensor.hall_sensor_occupancy
domain: binary_sensor
for:
hours: 0
minutes: 0
seconds: 0
condition:
- condition: sun
before: sunset
before_offset: "-00:30:00"
after: sunrise
enabled: false
action:
- service: light.turn_on
data:
brightness_pct: 17
target:
entity_id: light.hall
- delay:
hours: 0
minutes: 1
seconds: 0
milliseconds: 0
- service: light.turn_off
data: {}
target:
entity_id: light.hall
mode: single

when I look at it it looks like 30 mins before sunset till sunrise, totally lost, back to using HK automation for tonight, so easy lol
As Katie says, it’s far easier using the interface.

Try this:
Code:
condition: or
conditions:
  - condition: sun
    before: sunrise
  - condition: sun
    after: sunset
    after_offset: '-00:30:00'
 
Last edited:
when I look at it it looks like 30 mins before sunset till sunrise, totally lost, back to using HK automation for tonight, so easy lol

Think this is just basic program logic, ie:
condition: sun
before: sunset
So the time before the sun sets

before_offset: "-00:30:00"
after: sunrise
So the time after the sun rises

That's the day time by any logic is it not?
 
Sorry edited it as it was running whenever I passed, I now have this and it runs fine for 1 minute when tested.still runs when motion is detected with sun conditions disabled
alias: Hall @ night
description: Turn dimmed hall light on after dark when motion detected
trigger:
- type: motion
platform: device
device_id: 818546953f4583a966e13c6afdc86ff4
entity_id: binary_sensor.hall_sensor_occupancy
domain: binary_sensor
for:
hours: 0
minutes: 0
seconds: 0
condition:
- condition: sun
before: sunset
before_offset: "-00:30:00"
after: sunrise
action:
- service: light.turn_on
data:
brightness_pct: 17
target:
entity_id: light.hall
- delay:
hours: 0
minutes: 1
seconds: 0
milliseconds: 0
- service: light.turn_off
data: {}
target:
entity_id: light.hall
mode: single
This turns the lights on during the day by the look of it. Conditions should be After Sunset, Before Sunrise
 
thanks all so reversed my sun conditions just now and ran the automation, and it seemed to work okay, and no more automation running during the day when motion is detected, roll on tonight to confirm then around another dozen to duplicate and set up.
Thanks all for being patient with me

spoke to soon lights still running when motion detected

alias: Hall @ night
description: Turn dimmed hall light on after dark when motion detected
trigger:
- type: motion
platform: device
device_id: 818546953f4583a966e13c6afdc86ff4
entity_id: binary_sensor.hall_sensor_occupancy
domain: binary_sensor
for:
hours: 0
minutes: 0
seconds: 0
condition:
- condition: sun
before: sunrise
after: sunset
after_offset: "-30:00:00"
action:
- service: light.turn_on
data:
brightness_pct: 17
target:
entity_id: light.hall
- delay:
hours: 0
minutes: 1
seconds: 0
milliseconds: 0
- service: light.turn_off
data: {}
target:
entity_id: light.hall
mode: single
 
Last edited:
condition:
- condition: sun
before: sunrise
after: sunset
after_offset: "-30:00:00"
I think this still says it has to be both before sunrise and after sunset at the same time for the automation to run. This needs to apply to the single day so before sunrise today or after sunset today (rather than after sunset one day and before sunrise the next). See my example above.
 
I think this still says it has to be both before sunrise and after sunset at the same time for the automation to run. This needs to apply to the single day so before sunrise today or after sunset today (rather than after sunset one day and before sunrise the next). See my example above.
so as a newbie do i just copy what you have in place of lines 13-17 in my yaml ?

alias: Hall @ night
description: Turn dimmed hall light on after dark when motion detected
trigger:
- type: motion
platform: device
device_id: 818546953f4583a966e13c6afdc86ff4
entity_id: binary_sensor.hall_sensor_occupancy
domain: binary_sensor
for:
hours: 0
minutes: 0
seconds: 0
condition:
- condition: sun
before: sunrise
after: sunset
after_offset: "-00:30:00"

action:
- service: light.turn_on
data:
brightness_pct: 17
target:
entity_id: light.hall
- delay:
hours: 0
minutes: 1
seconds: 0
milliseconds: 0
- service: light.turn_off
data: {}
target:
entity_id: light.hall
mode: single
 
Has anyone worked out how to speed up the logbook so searching is actually usable?
Know this was an issue a couple of years ago, but think this was resolved?

ie:

Certainly it's lightning fast for me?
 
sorry i am trying, but getting an error after pasting

Message malformed: Expected a dictionary @ data['condition'][0]


alias: Hall @ night
description: Turn dimmed hall light on after dark when motion detected
trigger:
- type: motion
platform: device
device_id: 818546953f4583a966e13c6afdc86ff4
entity_id: binary_sensor.hall_sensor_occupancy
domain: binary_sensor
for:
hours: 0
minutes: 0
seconds: 0
condition: or
conditions:
- condition: sun
before: sunrise
- condition: sun
after: sunset
after_offset: '-00:30:00'

action:
- service: light.turn_on
data:
brightness_pct: 17
target:
entity_id: light.hall
- delay:
hours: 0
minutes: 1
seconds: 0
milliseconds: 0
- service: light.turn_off
data: {}
target:
entity_id: light.hall
mode: single
 
Last edited:
sorry i am trying, but getting an error after pasting

Message malformed: Expected a dictionary @ data['condition'][0]


alias: Hall @ night
description: Turn dimmed hall light on after dark when motion detected
trigger:
- type: motion
platform: device
device_id: 818546953f4583a966e13c6afdc86ff4
entity_id: binary_sensor.hall_sensor_occupancy
domain: binary_sensor
for:
hours: 0
minutes: 0
seconds: 0
condition: or
conditions:
- condition: sun
before: sunrise
- condition: sun
after: sunset
after_offset: '-00:30:00'

action:
- service: light.turn_on
data:
brightness_pct: 17
target:
entity_id: light.hall
- delay:
hours: 0
minutes: 1
seconds: 0
milliseconds: 0
- service: light.turn_off
data: {}
target:
entity_id: light.hall
mode: single

Just threw a quick one together, this works perfectly:

description: ""
mode: single
trigger:
- type: motion
platform: device
device_id: 53f2d8d935f449a983c771264ec18f15
entity_id: binary_sensor.driveway_sensor_motion
domain: binary_sensor
condition:
- condition: sun
before: sunset
after: sunrise
action:
- type: turn_on
device_id: 7d0132ebf385465cb34ef06f393341e2
entity_id: light.bedside_light_katie_side
domain: light

Try just inserting
condition:
- condition: sun
before: sunset
after: sunrise


As your red part and then test, then you can add the offset.

as I've said, highly recommend just doing in GUI though, just a few clicks and much easier
 
Know this was an issue a couple of years ago, but think this was resolved?

ie:

Certainly it's lightning fast for me?
It's very very very slow for me
 
Odd, might be something more local - you running on a Pi, Nas etc?

Might be worth digging into a bit to see if anything slowing down (or just post on HA discord/forum and get one of the gurus to give you some tips).

Certainly I've got a pretty complex system and runs very, very fast just on a RPi 4 8gb, so would be surprised if it's a HA thing...?
 
It is a Pi 3B+ 1GB to be fair, should think about moving to something more beefy
Ah right - I think both CPU and RAM would make a big difference, but particularly the 1GB feels very low and well below the usual 2GB min and 4GB recommended.

Think it'll work for the basics with that, but can totally see it being challenged on anything more!
 
Back
Top Bottom