Announcement

Collapse
No announcement yet.

Solar Position Script

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

  • #16
    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

    Comment


    • #17
      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
      HS3PRO 3.0.0.500 as a Fire Daemon service, Windows 2016 Server Std Intel Core i5 PC HTPC Slim SFF 4GB, 120GB SSD drive, WLG800, RFXCom, TI103,NetCam, UltraNetcam3, BLBackup, CurrentCost 3P Rain8Net, MCsSprinker, HSTouch, Ademco Security plugin/AD2USB, JowiHue, various Oregon Scientific temp/humidity sensors, Z-Net, Zsmoke, Aeron Labs micro switches, Amazon Echo Dots, WS+, WD+ ... on and on.

      Comment


      • #18
        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
        HS 3.0.0.548: 1976 Devices 1156 Events
        Z-Wave 3.0.1.262: 123 Nodes on one Z-Net

        Comment


        • #19
          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
          HS 3.0.0.548: 1976 Devices 1156 Events
          Z-Wave 3.0.1.262: 123 Nodes on one Z-Net

          Comment


          • #20
            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?
            HS3PRO 3.0.0.500 as a Fire Daemon service, Windows 2016 Server Std Intel Core i5 PC HTPC Slim SFF 4GB, 120GB SSD drive, WLG800, RFXCom, TI103,NetCam, UltraNetcam3, BLBackup, CurrentCost 3P Rain8Net, MCsSprinker, HSTouch, Ademco Security plugin/AD2USB, JowiHue, various Oregon Scientific temp/humidity sensors, Z-Net, Zsmoke, Aeron Labs micro switches, Amazon Echo Dots, WS+, WD+ ... on and on.

            Comment

            Working...
            X