Suncalc Rules Help

Hi All,

I have stumbled across @augoisms SunCalc driver, and I am trying to put it to good use with my blinds.

I've looked at the thread / post HERE , which has an example rule but I am struggling to work out where the private booleans fit in / how do I set them with the current rule machine 5.1.

In essence, what I am trying to do is write a rule that closes a blind once the sun gets round to the south, with an if on the forecast temp (using OWM). I think basically create the example rule, without elevation, but with the if qualifier. Is anyone able to point me in the right direction with booleans / the example?

Many Thanks.

I won’t be much help with the calculations of sun position combined with weather unfortunately, but having had to do some similar setups, I have tended instead to use an outside and/or inside illuminance sensor.

Then I have setup the rules (cold be shade, light, etc) based on the illuminance. Makes it much easier to do. I will typically only set the “correct” Illuminance value after a few trial runs - what is the value when I needed to close/open the blinds, etc.

1 Like

Hi @jason12
Here is what I do. My SunCalc driver is named TheSun and set to update every 5 minutes.
Then I have a rule that triggers at sunrise and runs my "suntracker" rule'. This "suntracker" rule sets my hub variables and repeats every 10 minutes. For example:
Repeat every 0:10:00 (stoppable)
Set Altitude to TheSun altitude
Set Lux to Backyard sensor illuminance
Set Azimuth to TheSun azimuth
END-REP
Then I have yet another rule that triggers when Azimuth > 180 (which is when the sun starts hitting my window) and adjusts the tilt on my blind depending on the sun's altitude and the lux level.
And finally I have another rule that runs at sunset and stops the "suntracker" rule.
Convoluted, but works for me.
Hope this helps.

2 Likes

Thanks Both.

Wounded, that sounds like exactly what I need. I think what I missed was running a separate rule to update some variables. That'll work, and perhaps give me more simplicity and also flexibility to limit the blinds rule to only when the forecast says it is going to be warm. Could be just the ticket.

Happy to hear anyone else's cool blinds / sun position rules if you stumble across this thread. I'm sure I'll get my original idea going, but you can never have too many ideas for automations :joy:

I do it conceptually the same as @Wounded. I have pasted the rule below—you’re welcome to steal anything that’s helpful and I’m happy to answer any questions.

My automation uses the following basic logic:

  • every time the sun’s azimuth or altitude change in the Suncalc driver, I update two hub variables respectively so I have a reference for the position of the Sun all the time
  • when the house stirs in the morning (defined in other automation), all blinds are opened
  • then every fifteen minutes throughout the day we adjust the blinds provided we’re home, not asleep, and it’s not dusk-or-darker (once it is dusk, another simple rule closes everything for the night)
  • assuming the above general prerequisites are met, then the logic checks to see if it’s bright outside (defined by an exterior lux sensor) and whether the sun’s altitude is in a Goldilocks range (not too high and not too low) to cause laser beams of unpleasant glare to enter the home. Given the particulars of our home, we’ve found this range to be roughly the horizon (zero degrees) to +62 degrees.
  • If the Sun’s altitude isn’t in this range or it’s not too bright, we raise the blinds.
  • If it is, however, we then look at the Sun’s azimuth relative to the angle of each window as a check to see if the window is situated unfavorably relative to the laserbeams, in which case the blind is closed; if not, it’s opened. [And, yes, to do all this the first time, we walked into each room with a compass app and, for each individual window, figured out the angle-range of the Sun that would deliver sun rays into the room.]
  • it’s perhaps overkill but we also have a hub variable that operates as a manual override for all the above if, for whatever reason, we don’t want any automation controlling the blinds so that we can set manually.

Probably sounds more complicated than it is, but it works great. I’ve thought about migrating the logic to Simple State Machine, but why mess with it, yknow?

Blinds Rule