Home Assistant beginners

Associate
OP
Joined
20 Jul 2007
Posts
2,105
Location
A sunnier or damper area than Ron-ski....
hi looking for some help with lighting automations, coming from HK and i moved everything to HA, set up a zigbee network and the only thing i am stuck at is sunset/sunrise dimmable lighting with motion sensors, as a work around i am using timed rather than sun, but would like to have it on at sunset and off at sunrise ?
Yep, two ways - one is using the motion sensor itself (ie mine have lux sensors, so you can detect the light level and trigger using that), the other is using your location settings in home assistant to trigger it, ie something like this:


But basically you want to:

a) create automation
B) set the trigger to your motion sensors
C) set a condition that light level is more than X (or between sunset and sunrise)

And away you go!
 
Associate
OP
Joined
20 Jul 2007
Posts
2,105
Location
A sunnier or damper area than Ron-ski....
alias: Motion @ night
description: Turn dimmed hall lights on when motion detected @ night
trigger:
- type: motion
platform: device
device_id: 818546953f4583a966e13c6afdc86ff4
entity_id: binary_sensor.hall_sensor_occupancy
domain: binary_sensor
condition:
- condition: sun
after: sunset
after_offset: "-30:00"
action:
- service: light.turn_on
data:
transition: 12
brightness_pct: 11
target:
entity_id: light.hall
mode: single

this is as close as I can get

Sorry, not sure I'm following - just use the gui to select condition > sun > then set after sunset and before sunrise?

This means that your automation will only trigger between these conditions (ie at night)
 
Last edited:
Associate
OP
Joined
20 Jul 2007
Posts
2,105
Location
A sunnier or damper area than Ron-ski....
sorry dont know what one you want
https://imgur.com/a/ifvRkBs
Thanks, that's helpful - first question, can you try taking out the sunset condition and confirm the lights work without it?

Quite often it's the motion sensors with various different entity_ids that cause the problem (ie picking the right state monitor)

Also a quick check is to click the three buttons to the right of the condition at the right time (eg this evening) and click 'test' - it should tell you if the condition was passed or failed (sometimes it's just people testing at the wrong point or offsets being misunderstood)
 
Last edited:
Associate
OP
Joined
20 Jul 2007
Posts
2,105
Location
A sunnier or damper area than Ron-ski....
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
Stupid question, is it not the opposite you want?

ie Would this not trigger after sunrise and before sunset (ie during the day).

For night time triggering, would you not want it after sunset and before sunrise (ie the night time)
 
Last edited:
Associate
OP
Joined
20 Jul 2007
Posts
2,105
Location
A sunnier or damper area than Ron-ski....
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?
 
Associate
OP
Joined
20 Jul 2007
Posts
2,105
Location
A sunnier or damper area than Ron-ski....
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?
 
Associate
OP
Joined
20 Jul 2007
Posts
2,105
Location
A sunnier or damper area than Ron-ski....
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
 
Associate
OP
Joined
20 Jul 2007
Posts
2,105
Location
A sunnier or damper area than Ron-ski....
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...?
 
Associate
OP
Joined
20 Jul 2007
Posts
2,105
Location
A sunnier or damper area than Ron-ski....
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!
 
Associate
OP
Joined
20 Jul 2007
Posts
2,105
Location
A sunnier or damper area than Ron-ski....
I run a Dell Optiplex 5050, upgraded to an i5 7500. It runs ESXi with 3 virtual machines, OPNsense, Home Assistant and Pihole. Even with the original dual core G4400 it was never under any stress from HA, just a little underpowered for high speed internet over vpn.

But it’s a great little machine and idles at around 15w.
That's very cool actually - 15w idle is very neat!
 
Associate
OP
Joined
20 Jul 2007
Posts
2,105
Location
A sunnier or damper area than Ron-ski....
Got a couple of hours to upgrade my home assistant wall panel today.... :D

Hacked a Fire 10 HD out of its brains to make it a normal tablet, then designed and 3d printed a magnetic cover.
Bit of plastering and it's working nippy quick!
JC90Gbg.jpg


More photos here if interested (need to find a better place than imgur to upload, it's getting harder and harder to just post images!!)
 

Attachments

  • 4BuStlb.jpg
    4BuStlb.jpg
    195 KB · Views: 21
  • 4BuStlb.jpg
    4BuStlb.jpg
    195 KB · Views: 22
Last edited:
Associate
OP
Joined
20 Jul 2007
Posts
2,105
Location
A sunnier or damper area than Ron-ski....
Nice work Katie :)

Not sure if it interests you, but you can rip the battery out of them and wire 5v up to the battery circuit board and run them without the battery to save on any potential issues :) I've done it with two now, a HD10 and a HD8. I figured I'd rather not have the worry of the inevitable battery swelling. And one less fire risk attached to the wall is always a bonus :D
Great idea Andy! Just as well I've got a magnetic cover!! I might add that to the list!
 
Associate
OP
Joined
20 Jul 2007
Posts
2,105
Location
A sunnier or damper area than Ron-ski....
how can you add yaml code if you dont have supervisor in HA.... i have a sensor that needs to be reconfigured from power to energy, but i need to add the yaml code for it to work

Looks like i need a newer version of HA.....aaahhhhhhhhh its a headache lol
But just wait until you get it working, you'll be able to achieve unlimited levels of madness.....


Do post if you have any questions! We're here to help (well except @dLockers he's here to take you down, but he told me not to say that.... )
 
Back
Top Bottom