Announcement

Collapse
No announcement yet.

Solar Position Script

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • langenet
    replied
    Thanks again Al. I have the living room and office south facing as well. I'm inspired to put this to use soon!

    How often is the event called?

    Leave a comment:


  • sparkman
    replied
    Originally posted by Richel View Post

    This works great! Thanks for posting it. Now, I have to figure out how to use it to close my motorized blinds. Elliott
    Glad that it's working for you. I just posted some examples on how I use it, along with the script in this post: https://forums.homeseer.com/forum/de...42#post1286742

    Leave a comment:


  • sparkman
    replied
    Originally posted by langenet View Post

    Al this is very interesting. So you call this via an event and pass in the three parameters? How often is this run? How is the multiplier parameter determined? Hit/miss.
    I will be purchasing some Bali blinds very soon so I'm keenly interested in implementing this.. Would you mind showing your event?

    As well, do you use Alexa and do you know if you can tell Alexa to open/close the blinds natively. I suppose using Jon's helper that's possible but wasn't sure if Alexa supports this.

    Thanks,

    Robert
    Hi Robert, yes, called from events with 3 parameters. See the example events for what triggers them. The multiplier can be a bit of trial and error, but the numbers I picked initially are pretty close. There's also a minimum change that's hard coded in the script (4%) so that the blinds don't adjust too often. I don't use Alexa but assume that it will work as the child devices look like switches and dimmers inside HS.

    This event deals with the morning and early afternoon sun in a south facing window. I'll modify it when it gets a bit warmer out to close as well if no one is home, whereas in the winter, I typically want it open to get more of the solar heat. I may just base it on forecasted high temps.

    Click image for larger version  Name:	Capture.PNG Views:	1 Size:	182.3 KB ID:	1287972

    This event deal with sun later in the afternoon for the same window. There's a TV in the corner of the room and this prevents the sun shining on it, so one of the conditions is that the TV is on (right now it's assumed that when the receiver is on the TV is on).

    Click image for larger version  Name:	Capture2.PNG Views:	1 Size:	136.7 KB ID:	1287973

    Leave a comment:


  • langenet
    replied
    Originally posted by sparkman View Post

    Light levels (ie. how bright it is outside) and in one room, whether the TV is on and whether the room is occupied. I also plan to factor outside temperature and potentially the forecast high termperature to see if shades on the south side of the house should be closed. In the winter, I want them open as much as possible to get the heat from the sun, unless the low sun shines on the tv or in people's eyes that are sitting in the room. I only have a few blinds automated at this point and it's unlikely I'll do more soon, so I don't plan to develop a general purpose script/web page/plugin for it. It's kind of trial and error to determine the azimuth range, elevation and brightness of the sun for which to lower the shades and by how much. Here's a script that I run for one room which uses a multiplier with the azimuth to determine the position (0 is fully closed for my blinds and 99 is fully open).

    Code:
    Sub Main(ByVal Parms as String)
    
    dim Debug as Boolean = False
    Dim logName As String = "Solar Shade" 'set log name for HS log
    
    Dim ParmArray() as String
    ParmArray = Parms.tostring.split(",")
    dim devSolarAltitude as Double = CDbl(ParmArray(0)) 'reference ID of the device to use for Solar Altitude
    dim devShadePosition as Double = CDbl(ParmArray(1)) 'reference ID of the shade/blind device
    dim Multiplier as Double = CDbl(ParmArray(2)) 'value for adjusting the altitude to determine the shade position
    
    Dim SolarAltitude As Double
    Dim CurrentShadePosition,NewShadePosition As Integer
    SolarAltitude = hs.DeviceValueEx(devSolarAltitude)
    CurrentShadePosition = hs.DeviceValue(devShadePosition)
    
    If Debug Then hs.writelog(logName,CStr(devSolarAltitude) & ":" & CStr(SolarAltitude))
    
    NewShadePosition = CInt(SolarAltitude * Multiplier)
    If Math.Abs(NewShadePosition - CurrentShadePosition) > 4 Then 'only adjust the shades if change is more than 4%
    Select Case NewShadePosition
    Case 1 to 98
    ' Device DIM, set its current dim level
    hs.CAPIControlHandler(hs.CAPIGetSingleControl(devShadePosition, false, CStr(NewShadePosition), false, true))
    If Debug Then hs.writelog(logName,CStr(devShadePosition) & ":" & CStr(NewShadePosition))
    Case > 98
    ' Device ON, set it to on
    hs.CAPIControlHandler(hs.CAPIGetSingleControl(devShadePosition, false, "On", false, false))
    If Debug Then hs.writelog(logName,CStr(devShadePosition) & " Set to On")
    Case < 1
    ' Device OFF, set it to off
    hs.CAPIControlHandler(hs.CAPIGetSingleControl(devShadePosition, false, "Off", false, true))
    If Debug Then hs.writelog(logName,CStr(devShadePosition) & " Set to Off")
    End Select
    Else
    If Debug Then hs.writelog(logName,"Blinds Not Adjusted as only different by " & Math.Abs(NewShadePosition - CurrentShadePosition) & "%")
    End If
    
    End Sub
    Al this is very interesting. So you call this via an event and pass in the three parameters? How often is this run? How is the multiplier parameter determined? Hit/miss.
    I will be purchasing some Bali blinds very soon so I'm keenly interested in implementing this.. Would you mind showing your event?

    As well, do you use Alexa and do you know if you can tell Alexa to open/close the blinds natively. I suppose using Jon's helper that's possible but wasn't sure if Alexa supports this.

    Thanks,

    Robert

    Leave a comment:


  • Richel
    replied
    Originally posted by sparkman View Post
    Below is a script that will calculate the solar azimuth and altitude (i.e. the position of the sun in the sky) and put the values in two virtual devices. ...
    This works great! Thanks for posting it. Now, I have to figure out how to use it to close my motorized blinds. Elliott

    Leave a comment:


  • sparkman
    replied
    Originally posted by Ltek View Post

    How are you doing it?
    Light levels (ie. how bright it is outside) and in one room, whether the TV is on and whether the room is occupied. I also plan to factor outside temperature and potentially the forecast high termperature to see if shades on the south side of the house should be closed. In the winter, I want them open as much as possible to get the heat from the sun, unless the low sun shines on the tv or in people's eyes that are sitting in the room. I only have a few blinds automated at this point and it's unlikely I'll do more soon, so I don't plan to develop a general purpose script/web page/plugin for it. It's kind of trial and error to determine the azimuth range, elevation and brightness of the sun for which to lower the shades and by how much. Here's a script that I run for one room which uses a multiplier with the azimuth to determine the position (0 is fully closed for my blinds and 99 is fully open).

    Code:
    Sub Main(ByVal Parms as String)
    
        dim Debug as Boolean = False
        Dim logName As String = "Solar Shade"                    'set log name for HS log
    
        Dim ParmArray() as String
        ParmArray = Parms.tostring.split(",")
        dim devSolarAltitude as Double = CDbl(ParmArray(0))        'reference ID of the device to use for Solar Altitude
        dim devShadePosition as Double = CDbl(ParmArray(1))        'reference ID of the shade/blind device
        dim Multiplier as Double = CDbl(ParmArray(2))            'value for adjusting the altitude to determine the shade position
    
        Dim SolarAltitude As Double
        Dim CurrentShadePosition,NewShadePosition As Integer
        SolarAltitude = hs.DeviceValueEx(devSolarAltitude)
        CurrentShadePosition = hs.DeviceValue(devShadePosition)
    
        If Debug Then hs.writelog(logName,CStr(devSolarAltitude) & ":" & CStr(SolarAltitude))
    
        NewShadePosition = CInt(SolarAltitude * Multiplier)
        If Math.Abs(NewShadePosition - CurrentShadePosition) > 4 Then 'only adjust the shades if change is more than 4%
            Select Case NewShadePosition
                Case 1 to 98
                    ' Device DIM, set its current dim level
                    hs.CAPIControlHandler(hs.CAPIGetSingleControl(devShadePosition, false, CStr(NewShadePosition), false, true))
                    If Debug Then hs.writelog(logName,CStr(devShadePosition) & ":" & CStr(NewShadePosition))
                Case > 98
                    ' Device ON, set it to on
                    hs.CAPIControlHandler(hs.CAPIGetSingleControl(devShadePosition, false, "On", false, false))
                    If Debug Then hs.writelog(logName,CStr(devShadePosition) & " Set to On")
                Case < 1
                    ' Device OFF, set it to off
                    hs.CAPIControlHandler(hs.CAPIGetSingleControl(devShadePosition, false, "Off", false, true))
                    If Debug Then hs.writelog(logName,CStr(devShadePosition) & " Set to Off")
            End Select
        Else
            If Debug Then hs.writelog(logName,"Blinds Not Adjusted as only different by " & Math.Abs(NewShadePosition - CurrentShadePosition) & "%")
        End If
    
    End Sub

    Leave a comment:


  • Ltek
    replied
    Originally posted by sparkman View Post

    Yes, these numbers by themselves are somewhat meaningless. I use these numbers along with other factors such as light levels to determine whether to open or close shades.
    How are you doing it?


    Might be interesting to have a comprehensive script (like the zwave lock script) with a single screen defining possible variables for each 'space'...
    in-room LUX
    window/door facing (compass direction)
    outside shading factor (trees, overhangs, etc)
    inside shading factor (type of window coverings)
    etc
    ... using those with the solar position to calculate when it is light or dark in each 'space'.

    or maybe I just use LUX.

    Leave a comment:


  • sparkman
    replied
    Originally posted by Ltek View Post
    This can be very handy (I used a plugin like this on Vera)... though I found more data is needed to make it accurate.
    Yes, these numbers by themselves are somewhat meaningless. I use these numbers along with other factors such as light levels to determine whether to open or close shades.

    Leave a comment:


  • Ltek
    replied
    This can be very handy (I used a plugin like this on Vera)... though I found more data is needed to make it accurate. Each side of the house, and in some cases each door/window/room will have a different directional facing, plants, overhangs, size of window, etc ... all this changes the light hitting windows/doors or entering a space.
    For instance: my front Door is set back with close walls and large overhang... very low ambient light door most of the day; but at times angle of the sun can be blinding

    ... all of this needs to be taken into account.

    Thinking Out loud...
    Most of my motion sensors have LUX readings, I've yet to that data
    -- maybe LUX + Sun Position would render the best results?
    -- maybe a profile for each space (room / area) which creates a vDevice to tell us what the light level in that space is. <

    Leave a comment:


  • sparkman
    replied
    Originally posted by langenet View Post
    That's embarrassing... Yes, I had to change the time zone to 5 .. So the numbers now line up and my virtual devices show 224.7 and 22.2. while the site shows 224.5 and 21.68. Close enough for the government!

    Great work. Thanks for all your help!

    Robert
    You're welcome and glad it's working for you!

    Cheers
    Al

    Leave a comment:


  • langenet
    replied
    That's embarrassing... Yes, I had to change the time zone to 5 .. So the numbers now line up and my virtual devices show 224.7 and 22.2. while the site shows 224.5 and 21.68. Close enough for the government!

    Great work. Thanks for all your help!

    Robert

    Leave a comment:


  • sparkman
    replied
    langenet What are you using as the Time Zone value on that web page and where do you think the sun is approx. in real life?

    Leave a comment:


  • langenet
    replied
    Right now the site shows 233.67 and altitude of 16.13. My virtual devices show 220 and 24.5. My Latitude is 45.42 an my long is 75.67.

    Leave a comment:


  • sparkman
    replied
    Originally posted by langenet View Post
    Can you share a link Al? I'm using https://planetcalc.com/4270/ but the numbers don't jive...
    This is one of the ones I tried: https://planetcalc.com/320/

    Right now, it shows Azimuth 173.27 and altitude 27.19. My virtual devices show 173.8 and 27.5, so close enough for my purposes. How far is yours off? Likely a timezone adjustment issue.

    Leave a comment:


  • langenet
    replied
    Can you share a link Al? I'm using https://planetcalc.com/4270/ but the numbers don't jive...

    Leave a comment:

Working...
X