Announcement

Collapse
No announcement yet.

Photo Frame2 - WAF above 0 needed - can somebody help?

Collapse
This topic is closed.
X
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    #16
    I've progressed a "tiny" bit with scripting but I would have needed that 2 years ago.
    Marty
    ------
    XPpro SP3 /w HS Standard 2.5.0.80, HSTouch Server - 1.0.0.70, HSTouch Client 1.0.0.73 HSTouch Android - 1.0.0.2, HSTouch iPhone - 1.0.0.2
    Playing with HS3 a bit but it's just play at this point.

    Comment


      #17
      Originally posted by mterry63 View Post
      You could easily setup HSTouch to update a Homeseer device every time you open a screen, that way you would know which screen is active on a client.

      It's a workaround, but it should be easy to implement.
      Terry
      What do you thing would be the best way to do the above update. Also what about multiple clients? I can not see a good way to do either.

      Comment


        #18
        Originally posted by Gerard View Post
        Terry
        What do you thing would be the best way to do the above update. Also what about multiple clients? I can not see a good way to do either.
        Gerard,

        I'd imagine a virtual device per HSTouch client that holds a value per screen and according valuestrings to name the screen. On every button that changes a screen you'd have to set the right value under the actions. Am I right Terry?

        Wim
        -- Wim

        Plugins: JowiHue, RFXCOM, Sonos4, Jon00's Perfmon and Network monitor, EasyTrigger, Pushover 3P, rnbWeather, BLBackup, AK SmartDevice, Pushover, PHLocation, Zwave, GCalseer, SDJ-Health, Device History, BLGData

        1210 devices/features ---- 392 events ----- 40 scripts

        Comment


          #19
          Exactly what I would do. Create 1 device per client then after/before the "Open a screen" or "Close a screen" action add a second action to set the device string to the new screen. Generally these are tied to a button.

          The only place this might get tricky is if you use the timeout value to return to the main screen, in which case you'd have figure out what to do then, or if you change the screen from Homeseer, which should be easy to update the device value since you know you're changing the screen "remotely".

          Comment


            #20
            Originally posted by w.vuyk View Post
            Marty,

            You are right about that. And it might be a hard one for thos that don't like playing around inside a script. Maybe i should make that part easier by moving those hardcoded directories to the ini file, so one could decide inside the ini file instead of the script?
            If that is a wish I can work on that this weekend. it should not be hard to do.

            Wim
            I could not resist. I have changed the script and moved the hardcoded directorynames to tthe ini file. I have uploaded it in the original message.
            If needed the script will create the directory under the HS html directory itself.

            I also added a few error messages if the script discovers the sourcedirectory does not exist, or it cannot create the html subdirectory.

            Wim
            -- Wim

            Plugins: JowiHue, RFXCOM, Sonos4, Jon00's Perfmon and Network monitor, EasyTrigger, Pushover 3P, rnbWeather, BLBackup, AK SmartDevice, Pushover, PHLocation, Zwave, GCalseer, SDJ-Health, Device History, BLGData

            1210 devices/features ---- 392 events ----- 40 scripts

            Comment


              #21
              You're just like the rest of us geeks, you get a thought in you're head and you can't let it alone, you keep picking at it till it works or it beats you.

              I'll go play with it.
              Marty
              ------
              XPpro SP3 /w HS Standard 2.5.0.80, HSTouch Server - 1.0.0.70, HSTouch Client 1.0.0.73 HSTouch Android - 1.0.0.2, HSTouch iPhone - 1.0.0.2
              Playing with HS3 a bit but it's just play at this point.

              Comment


                #22
                Originally posted by nightwalker View Post
                You're just like the rest of us geeks, you get a thought in you're head and you can't let it alone, you keep picking at it till it works or it beats you.

                I'll go play with it.
                Guilty as charged!
                Just do not tell the wife....
                I guess in your case, you do not have to adjust your HS directory anymore?

                Wim
                -- Wim

                Plugins: JowiHue, RFXCOM, Sonos4, Jon00's Perfmon and Network monitor, EasyTrigger, Pushover 3P, rnbWeather, BLBackup, AK SmartDevice, Pushover, PHLocation, Zwave, GCalseer, SDJ-Health, Device History, BLGData

                1210 devices/features ---- 392 events ----- 40 scripts

                Comment


                  #23
                  no, but it'll be a small test until someone comes along and gives it the full blown test.
                  Marty
                  ------
                  XPpro SP3 /w HS Standard 2.5.0.80, HSTouch Server - 1.0.0.70, HSTouch Client 1.0.0.73 HSTouch Android - 1.0.0.2, HSTouch iPhone - 1.0.0.2
                  Playing with HS3 a bit but it's just play at this point.

                  Comment


                    #24
                    issues with script/feature

                    I am getting the following error when the script runs via the event... Any ideas? Also, Asssuming the ini should be in the config directory, not scripts? I have tried both but havent had any success either way. Also tried pointing to folder with about 30 jpgs on network, as well as creating c:\foto and placing images there. Any help is greatly appreciated. Thanks.

                    Code:
                    8/23/2009 9:08:40 PM   Info  Event Trigger "PictureShow" 
                    8/23/2009 9:08:40 PM   Info  Running script and waiting: JOWI_PictureRandom.vb("Main","") 
                    8/23/2009 9:08:40 PM   Error  Script compile error: Type 'Drawing.Bitmap' is not defined.on line 55 
                    8/23/2009 9:08:40 PM   SCR  Option Strict Offimports Schedulerimports SystemPublic Module scriptcode30#Region "Automatically generated code, do not modify"'Automatically generated code, do not modify'Event Sources Begin Public WithEvents hs As Scheduler.hsapplication Public WithEvents hsp As scheduler.hsp Public WithEvents hssystem As scheduler.phone0'Event Sources End'End of automatically generated code#End RegionDim PictureList As New System.Collections.Generic.SortedList(Of String, Date)Sub Main(ByVal parms As Object) Dim section As String = hs.GetINISection("Displays", "Jowi_PictureRandom.ini") Dim PictureDirectory As String = hs.GetINISetting("Settings", "PictureDirectory", "C:\Foto", "Jowi_PictureRandom.ini") Dim items() As String = section.Split(Chr(0)) If Not IO.Directory.Exists(PictureDirectory) Then hs.WriteLog("PictureRandom", "Error : Directory " & PictureDirectory & " does not exist, please correct in Jowi_PictureRandom.ini") Exit Sub End If Dim Picture As String = GetRandomInputFile(PictureDirectory) If Picture = "Exit" Then Exit Sub For Each item As String In items Dim Type As String = item.Split("=")(0) Dim Dimension() As String = item.Split("=")(1).Split(",") If Dimension.GetUpperBound(0) = 1 Then Resize(Dimension(1), Dimension(0), Type, Picture) Else hs.WriteLog("error", "Dimensionarray=" & Dimension.GetUpperBound(0)) End If NextEnd SubSub ResetList(ByVal parms As Object) PictureList = New System.Collections.Generic.SortedList(Of String, Date) hs.WriteLog("PictureRandom Info", "List has been reset")End SubPublic Sub Resize(ByVal MaxHeight As Integer, ByVal MaxWidth As Integer, ByVal Type As String, ByVal Picture As String) Dim HTMLDir As String = hs.GetAppPath & "\html\" & hs.GetINISetting("Settings", "WebDirectory", "JOWI_Picture_Random", "Jowi_PictureRandom.ini") Dim _pathOutputImage As String = HTMLDir & "\" & Type & ".jpg" Dim Height As Integer Dim width As Integer Dim bm_source As New Drawing.Bitmap(Picture) Dim CurrWidth As Integer = bm_source.Width Dim CurrHeight As Integer = bm_source.Height Dim relHeight As Double = CurrHeight / MaxHeight Dim relWidth As Double = CurrWidth / MaxWidth Dim relResize As Double Try If Not IO.Directory.Exists(HTMLDir) Then IO.Directory.CreateDirectory(HTMLDir) End If Catch ex As Exception hs.WriteLog("PictureRandom", "Error : Could not create directory") End Try If relHeight > relWidth Then relResize = relHeight Else relResize = relWidth End If Height = CurrHeight / relResize width = CurrWidth / relResize Dim bm_dest As New Drawing.Bitmap(width, Height) ' Make a bitmap for the result. Dim gr_dest As Drawing.Graphics = Drawing.Graphics.FromImage(bm_dest) ' Make a Graphics object for the result Bitmap. gr_dest.DrawImage(bm_source, 0, 0, bm_dest.Width + 1, bm_dest.Height + 1) ' Copy the source image into the destination bitmap. bm_dest.Save(_pathOutputImage) bm_dest.Dispose() bm_source.Dispose()End SubFunction GetRandomInputFile(ByVal Source As String) As String Dim Total As Integer = 0 Dim ChosenFile As String = ChooseFile(Source, Total) Dim MaxRetry As Integer = Total * 0.3 If PictureList.ContainsKey(ChosenFile) Then Dim Retries As Integer = 1 While PictureList.ContainsKey(ChosenFile) If CInt(Retries / 10) = Retries / 10 Then hs.WriteLog("PictureRandom Warning", "trying to get unused picture....(" & PictureList.Count & " pictures in list) Try nr. " & Retries) End If ChosenFile = ChooseFile(Source, Total) Retries += 1 If Retries > MaxRetry Then ResetList("") End If End While End If PictureList.Add(ChosenFile, Now) If ChosenFile = "" Or ChosenFile = "Exit" Then hs.WriteLog("PictureRandom", "Error : final file=EMPTY") End If Return ChosenFileEnd FunctionPublic Function ChooseFile(ByVal Source As String, ByRef Total As Integer) As String Dim Directory As New IO.DirectoryInfo(Source) Dim allFiles As IO.FileInfo() Dim ChosenFile As String = "" allFiles = Directory.GetFiles("*.jpg", 1) Total = allFiles.GetUpperBound(0) If allFiles.GetUpperBound(0) >= 0 Then ChosenFile = allFiles(RandomNumber(allFiles.GetUpperBound(0))).FullName ElseIf allFiles.GetUpperBound(0) = 0 Then ChosenFile = allFiles(0).FullName Else hs.WriteLog("PictureRandom", "Error : Directory " & Source & " contains no jpg files") Return "Exit" End If allFiles = Nothing Directory = Nothing Return ChosenFileEnd FunctionPublic Function RandomNumber(ByVal MaxNumber As Integer, _ Optional ByVal MinNumber As Integer = 0) As Integer Dim r As New Random() If MinNumber > MaxNumber Then Dim t As Integer = MinNumber MinNumber = MaxNumber MaxNumber = t End If Return r.Next(MinNumber, MaxNumber)End FunctionEnd Module
                    HS 3.0.0.199 Pro/Insteon 3.0.5.20/3 Venstar Insteon Therms / Insteon Thermostat 3.0.2.2 / DirecTV 3.0.0.14 / OpenSprinkler 2.0.5.21 / ITunes DAAP 3.0.0.23/ UltraM1G3 3.0.5437.37424/ UltraWeatherbug3 /HSTouch Svr 3.0.0.68/Zwave 3.0.1.25/Ultramon3/Global Cache 5.0.0.17/Various BLXXX Plugins.

                    Comment


                      #25
                      Looks like a library problem, Did you add the libraries to the settings.ini filein the config directory?

                      [Settings]
                      ScriptingReferences=MySql.Data.MySqlClient;D:\Program Files\MySQL\MySQL Connector Net 5.1.4\Binaries\.NET 2.0\MySql.Data.dll,System.Data;System.Data.dll,System.Drawin g;System.Drawing.dll,System.Drawing.Image;System.Drawing.dll ,System.Xml;System.Xml.dll
                      StartWithStartPage=False
                      IOCodesExclude=,


                      Originally posted by kuntakintay View Post
                      I am getting the following error when the script runs via the event... Any ideas? Also, Asssuming the ini should be in the config directory, not scripts? I have tried both but havent had any success either way. Also tried pointing to folder with about 30 jpgs on network, as well as creating c:\foto and placing images there. Any help is greatly appreciated. Thanks.

                      Code:
                      8/23/2009 9:08:40 PM   Info  Event Trigger "PictureShow" 
                      8/23/2009 9:08:40 PM   Info  Running script and waiting: JOWI_PictureRandom.vb("Main","") 
                      8/23/2009 9:08:40 PM   Error  Script compile error: Type 'Drawing.Bitmap' is not defined.on line 55 
                      8/23/2009 9:08:40 PM   SCR  Option Strict Offimports Schedulerimports SystemPublic Module scriptcode30#Region "Automatically generated code, do not modify"'Automatically generated code, do not modify'Event Sources Begin Public WithEvents hs As Scheduler.hsapplication Public WithEvents hsp As scheduler.hsp Public WithEvents hssystem As scheduler.phone0'Event Sources End'End of automatically generated code#End RegionDim PictureList As New System.Collections.Generic.SortedList(Of String, Date)Sub Main(ByVal parms As Object) Dim section As String = hs.GetINISection("Displays", "Jowi_PictureRandom.ini") Dim PictureDirectory As String = hs.GetINISetting("Settings", "PictureDirectory", "C:\Foto", "Jowi_PictureRandom.ini") Dim items() As String = section.Split(Chr(0)) If Not IO.Directory.Exists(PictureDirectory) Then hs.WriteLog("PictureRandom", "Error : Directory " & PictureDirectory & " does not exist, please correct in Jowi_PictureRandom.ini") Exit Sub End If Dim Picture As String = GetRandomInputFile(PictureDirectory) If Picture = "Exit" Then Exit Sub For Each item As String In items Dim Type As String = item.Split("=")(0) Dim Dimension() As String = item.Split("=")(1).Split(",") If Dimension.GetUpperBound(0) = 1 Then Resize(Dimension(1), Dimension(0), Type, Picture) Else hs.WriteLog("error", "Dimensionarray=" & Dimension.GetUpperBound(0)) End If NextEnd SubSub ResetList(ByVal parms As Object) PictureList = New System.Collections.Generic.SortedList(Of String, Date) hs.WriteLog("PictureRandom Info", "List has been reset")End SubPublic Sub Resize(ByVal MaxHeight As Integer, ByVal MaxWidth As Integer, ByVal Type As String, ByVal Picture As String) Dim HTMLDir As String = hs.GetAppPath & "\html\" & hs.GetINISetting("Settings", "WebDirectory", "JOWI_Picture_Random", "Jowi_PictureRandom.ini") Dim _pathOutputImage As String = HTMLDir & "\" & Type & ".jpg" Dim Height As Integer Dim width As Integer Dim bm_source As New Drawing.Bitmap(Picture) Dim CurrWidth As Integer = bm_source.Width Dim CurrHeight As Integer = bm_source.Height Dim relHeight As Double = CurrHeight / MaxHeight Dim relWidth As Double = CurrWidth / MaxWidth Dim relResize As Double Try If Not IO.Directory.Exists(HTMLDir) Then IO.Directory.CreateDirectory(HTMLDir) End If Catch ex As Exception hs.WriteLog("PictureRandom", "Error : Could not create directory") End Try If relHeight > relWidth Then relResize = relHeight Else relResize = relWidth End If Height = CurrHeight / relResize width = CurrWidth / relResize Dim bm_dest As New Drawing.Bitmap(width, Height) ' Make a bitmap for the result. Dim gr_dest As Drawing.Graphics = Drawing.Graphics.FromImage(bm_dest) ' Make a Graphics object for the result Bitmap. gr_dest.DrawImage(bm_source, 0, 0, bm_dest.Width + 1, bm_dest.Height + 1) ' Copy the source image into the destination bitmap. bm_dest.Save(_pathOutputImage) bm_dest.Dispose() bm_source.Dispose()End SubFunction GetRandomInputFile(ByVal Source As String) As String Dim Total As Integer = 0 Dim ChosenFile As String = ChooseFile(Source, Total) Dim MaxRetry As Integer = Total * 0.3 If PictureList.ContainsKey(ChosenFile) Then Dim Retries As Integer = 1 While PictureList.ContainsKey(ChosenFile) If CInt(Retries / 10) = Retries / 10 Then hs.WriteLog("PictureRandom Warning", "trying to get unused picture....(" & PictureList.Count & " pictures in list) Try nr. " & Retries) End If ChosenFile = ChooseFile(Source, Total) Retries += 1 If Retries > MaxRetry Then ResetList("") End If End While End If PictureList.Add(ChosenFile, Now) If ChosenFile = "" Or ChosenFile = "Exit" Then hs.WriteLog("PictureRandom", "Error : final file=EMPTY") End If Return ChosenFileEnd FunctionPublic Function ChooseFile(ByVal Source As String, ByRef Total As Integer) As String Dim Directory As New IO.DirectoryInfo(Source) Dim allFiles As IO.FileInfo() Dim ChosenFile As String = "" allFiles = Directory.GetFiles("*.jpg", 1) Total = allFiles.GetUpperBound(0) If allFiles.GetUpperBound(0) >= 0 Then ChosenFile = allFiles(RandomNumber(allFiles.GetUpperBound(0))).FullName ElseIf allFiles.GetUpperBound(0) = 0 Then ChosenFile = allFiles(0).FullName Else hs.WriteLog("PictureRandom", "Error : Directory " & Source & " contains no jpg files") Return "Exit" End If allFiles = Nothing Directory = Nothing Return ChosenFileEnd FunctionPublic Function RandomNumber(ByVal MaxNumber As Integer, _ Optional ByVal MinNumber As Integer = 0) As Integer Dim r As New Random() If MinNumber > MaxNumber Then Dim t As Integer = MinNumber MinNumber = MaxNumber MaxNumber = t End If Return r.Next(MinNumber, MaxNumber)End FunctionEnd Module
                      HS3 Pro Edition 3.0.0.435 (Windows 10 vmware)
                      BLOccupied:,UltraNetCam3:,weatherXML:,RFXCOM:,Current Cost 3P:,UltraGCIR3:
                      DMMQTT:,Kodi:,Z-Wave:,BLRadar:,EasyTrigger:,MySensors:,BLBackup:

                      Comment


                        #26
                        Dmurphy is right, this is a library problem:

                        To be able to run the script successfully you will have to adjust (or create) the line "ScriptingReferences" under [settings] in settings.ini.
                        Add "System.Drawing;System.Drawing.dll,System.Drawing.Image;Syst em.Drawing.dll" preceded by a comma to this line.

                        Restart HS after this change

                        Watch the funny space here, for some reason this board puts a space in the line, there should be no spaces in the scriptingreference

                        The ini file should be in the config directory indeed. In the ini file you can point to the folder holding your picture.

                        Hope this helps!

                        Wim
                        -- Wim

                        Plugins: JowiHue, RFXCOM, Sonos4, Jon00's Perfmon and Network monitor, EasyTrigger, Pushover 3P, rnbWeather, BLBackup, AK SmartDevice, Pushover, PHLocation, Zwave, GCalseer, SDJ-Health, Device History, BLGData

                        1210 devices/features ---- 392 events ----- 40 scripts

                        Comment


                          #27
                          Sorry to bump an old post but i can't get this to work.
                          This script is exactly what i'm looking for but sadly i keep getting errors.

                          What i've done.
                          1) Downloaded the script file and the ini file posted in post number2 of this thread (JOWI_PictureRandom.vb and Jowi_PictureRandom.ini)
                          2) Put both files in my HSPro directory under scripts
                          3) In the HSpro\Config\Settings.ini under the [Settings] section i added the following line;
                          Code:
                          ScriptingReferences=System.Drawing;System.Drawing.dll,System.Drawing.Image;System.Drawing.dll
                          4) Opened Jowi_PictureRandom.ini and it looks like this;
                          Code:
                          [Settings]
                          '
                          ' Set PictureDirectory to the root of the directory holding original pictures
                          '
                          PictureDirectory="C:\Foto"
                          '
                          ' WebDirectory should hold the name of the directory HSTouch will be accessing
                          ' to show the resized picture. 
                          ' The path to the HTML directory of HS is determined by the script itself.
                          ' If this directory does not exist, it will be created for you.
                          '
                          ' If you use an different webserver then HS, you will have to edit the script (set _pathOutputImage)
                          '
                          WebDirectory=JOWI_Picture_Random
                           
                          [Displays]
                          EETopMain=880,550
                          EETopExtra=200,170
                          HTCMain=150,140
                          5) Next i created the directoy HSPro\html\JOWI_Picture_Random
                          6) Created a directory c:\Foto and placed 5 foto's in it (as a test)
                          7) Created a test event; Run script: JOWI_PictureRandom.vb("Main","")

                          When executing the script i get the following error;
                          Code:
                          15-5-2012 14:02:19  - PictureRandom Info - List has been reset
                          15-5-2012 14:02:19  - Error - Scripting runtime error: System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.IndexOutOfRangeException: Index was outside the bounds of the array.   at scriptcode5.scriptcode5.Main(Object parms)   --- End of inner exception stack trace ---   at System.RuntimeMethodHandle._InvokeMethodFast(Object target, Object[] arguments, SignatureStruct& sig, MethodAttributes methodAttributes, RuntimeTypeHandle typeOwner)   at System.RuntimeMethodHandle.InvokeMethodFast(Object target, Object[] arguments, Signature sig, MethodAttributes methodAttributes, RuntimeTypeHandle typeOwner)   at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, Boolean skipVisibilityChecks)   at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)   at System.Reflection.MethodBase.Invoke(Object obj, Object[] parameters)   at Scheduler.VsaScriptHost.Invoke(String ModuleName, String MethodName, Object[] Arguments)
                          Anyone have an idea off what i'm doing wrong?
                          Thanks in advance

                          Kind regards,
                          Michiel

                          Comment


                            #28
                            I've been using this for awhile now, since it came out and it's worked very well. I can't help much but i do see a couple of differences between the info you posted and what i have.
                            1) my ini file has different displays than yours. I have
                            [Displays]
                            Standard=800,600
                            SmallScreen=633,475

                            2) I notice that your \html\JOWI_Picture_Random directory is different than what I have. I have \html\JOWI_PictureRandom

                            Neither of these may make a difference but it's worth checking anyway. Looking at the script I don't see anywhere where I made any changes in the main script itself.
                            Marty
                            ------
                            XPpro SP3 /w HS Standard 2.5.0.80, HSTouch Server - 1.0.0.70, HSTouch Client 1.0.0.73 HSTouch Android - 1.0.0.2, HSTouch iPhone - 1.0.0.2
                            Playing with HS3 a bit but it's just play at this point.

                            Comment


                              #29
                              Hi nightwalker,

                              Thanks for your reply.
                              1) The displays is what is says in the main ini file found in the second post. I just changed this to 2 different values.
                              2) Correct, i've changed this. Because the vb script is calling the JOWI_Picture_Random instead of JOWI_PictureRandom
                              Code:
                              Dim HTMLDir As String = hs.GetAppPath & "\html\" & hs.GetINISetting("Settings", "WebDirectory", "JOWI_Picture_Random", "Jowi_PictureRandom.ini")
                              Btw..in the ini file i changed c:\Foto to C:\Foto and now the error in HS changed. Every time i change something little. Even a c to C or f to F(oto) the error changes.

                              Would you mind posting your vb and ini file so i can try those?

                              Comment


                                #30
                                Originally posted by DrDoo View Post
                                Hi nightwalker,

                                Thanks for your reply.
                                1) The displays is what is says in the main ini file found in the second post. I just changed this to 2 different values.
                                2) Correct, i've changed this. Because the vb script is calling the JOWI_Picture_Random instead of JOWI_PictureRandom
                                Code:
                                Dim HTMLDir As String = hs.GetAppPath & "\html\" & hs.GetINISetting("Settings", "WebDirectory", "JOWI_Picture_Random", "Jowi_PictureRandom.ini")
                                Btw..in the ini file i changed c:\Foto to C:\Foto and now the error in HS changed. Every time i change something little. Even a c to C or f to F(oto) the error changes.

                                Would you mind posting your vb and ini file so i can try those?
                                What's the new error?
                                💁‍♂️ Support & Customer Service 🙋‍♂️ Sales Questions 🛒 Shop HomeSeer Products

                                Comment

                                Working...
                                X