Tonlof thanks for your help. I missed the fact that the website also showed a single day. Nice job. Simple and everything is working. Really appreciate your response I had spent several hours learning about regex over the past few days. Nice to have this part working.
Announcement
Collapse
No announcement yet.
[VB.NET] my.Alert
Collapse
X
-
tonlof-Several TV Channel program info.
My cable co. has this page-
http://mediacomtoday.com/tv/login.ph...1&submit=Enter
But you have to interact with it ie your zip code. Then the grid loads with this url- http://mediacomtoday.com/tv/listing_grid.php?page=grid
So I am not sure this will work, will it?
Thanks,
TimFB Page - https://www.facebook.com/pages/Capt-Tim/209398425902188
HSTouch Layouts - https://www.facebook.com/media/set/?...5902188&type=3
Comment
-
Hi Tim, the site I use is from local paytv operator and I don't think you can use it for your needs. Have you look at HSTV?
Originally posted by fungun View Posttonlof-
How and which site are you using for this? TVGuide?
My cable co. has this page-
http://mediacomtoday.com/tv/login.ph...1&submit=Enter
But you have to interact with it ie your zip code. Then the grid loads with this url- http://mediacomtoday.com/tv/listing_grid.php?page=grid
So I am not sure this will work, will it?
Thanks,
TimPlease excuse any spelling and grammatical errors I may make.
--
Tasker Plugin / Speech Droid
Tonlof | Sweden
Comment
-
Dan,
Script does look very powerful and useful. Need a bit of help. Keep getting this same error in the log file when looking up cnn breaking news. Please see attachment.
thanks
TomAttached FilesTom
baby steps...starting again with HS3
HS3Pro: Z-NET & 80 Z wave Devices,
HSTouch: 4 Joggler (Android Kitkat), 2 iPhone, 3 iPads
Whole House Audio: 5 SqueezePlay Jogglers w Bose Speakers
In The Works: 10 Cameras Geovision, new Adecmo/Envisalink Alarm, Arduinos
System: XP on Fanless Mini-ITX w/ SSD
Comment
-
I've re-installed the script file, .ini file( copied and pasted your example) and recreated the event. Seem to get the same log error(post #19). Can't seem to figure it out. Would appreciate any help you can provide. ThanksTom
baby steps...starting again with HS3
HS3Pro: Z-NET & 80 Z wave Devices,
HSTouch: 4 Joggler (Android Kitkat), 2 iPhone, 3 iPads
Whole House Audio: 5 SqueezePlay Jogglers w Bose Speakers
In The Works: 10 Cameras Geovision, new Adecmo/Envisalink Alarm, Arduinos
System: XP on Fanless Mini-ITX w/ SSD
Comment
-
MyAlert Error - Anyone know what Error Means
Do of the any other users here know what this error means. Thanks
7/14/2013 7:45:26 AM SCR Option Strict OffImports System.TextImports System.Text.RegularExpressionsPublic sSettingLogLevel As Integer = 0Public sConfigINIPath As String = "my.Alert.ini"Public sConfigProfile As StringPublic sConfigURL As StringPublic sConfigRegExSearch As StringPublic sConfigRegExReplace As StringPublic sConfigDeviceString As StringPublic sConfigDeviceOn As StringPublic sConfigDeviceOff As StringPublic sConfigDeviceToggle As StringPublic sConfigSpeak As StringPublic sConfigRun As StringPublic sConfigEvent As StringPublic sConfigMedia As StringPublic sConfigEmail As StringPublic bConfigHTML As Boolean' ------------------------------------------------------------Public Sub monitor(ByVal oParameters As Object) Dim sParameters() As String Dim sData As String Dim sURL As String Dim sRegExPattern As String Dim sRegExReplace As String Dim sLogLevel As String dlog("Executing my.Alert",2) sParameters = Split(oParameters.ToString,"@") If oParameters Is Nothing Then hs.WriteLog("my.Alert","Fatal Error") Return End If dlog(sParameters.GetUpperBound(0) + 1 & " parameter(s) specified: " & oParameters.ToString,3) Try dlog("Setting sSettingLogLevel to " & sParameters(0),3) sSettingLogLevel = sParameters(0) Select Case sSettingLogLevel Case 3 sLogLevel = "Debug" Case 2 sLogLevel = "Info" Case 1 sLogLevel = "Error" Case 0 sLogLevel ="None" End Select dlog("Setting logging level to " & sLogLevel,2) sConfigProfile = sParameters(1) dlog("Loading '" & sConfigProfile & "' profile (" & sConfigINIPath & ")",3) If hs.GetINISection(sConfigProfile, sConfigINIPath).Length 0 Then dlog("monitor(): New data detected",3) If sConfigDeviceString "0" Then dlog("monitor(): Updating device string for " & sConfigDeviceString & ": " & sData,3) hs.SetDeviceString(sConfigDeviceString, sData) End If If sConfigDeviceToggle "0" Then dlog("monitor(): Toggling device status for " & sConfigDeviceToggle,2) If hs.DeviceStatus(sConfigDeviceToggle) = 3 Then hs.SetDeviceStatus(sConfigDeviceOff,2) Else hs.SetDeviceStatus(sConfigDeviceOff,3) End If End If If sConfigDeviceOn "0" Then dlog("monitor(): Turning on " & sConfigDeviceOn,2) hs.SetDeviceStatus(sConfigDeviceOff,2) End If If sConfigDeviceOff "0" Then dlog("monitor(): Turning off " & sConfigDeviceOff,2) hs.SetDeviceStatus(sConfigDeviceOff,3) End If If sConfigRun "0" Then dlog("monitor(): Executing command " & sConfigRun,2) hs.Launch(sConfigRun) End If If sConfigSpeak "0" Then dlog("monitor(): Announcing " & sConfigSpeak,2) hs.Speak(sConfigSpeak) End If If sConfigMedia "0" Then dlog("monitor(): Playing " & sConfigMedia,2) hs.PlayWavFile(sConfigMedia) End If If sConfigEmail "0" Then dlog("monitor(): Sending e-mail to " & sConfigEmail,2) hs.SendEmail(sConfigEmail,sConfigEmail,sConfigProfile,sData) End If If sConfigEvent "0" Then dlog("monitor(): Executing event --- " & sConfigEvent,2) hs.TriggerEvent(sConfigEvent) End If Else dlog("monitor(): No change was detected",3) End If Catch Ex As Exception hs.WriteLog("my.Alert","Script Exception Error: " & Ex.Message) End TryEnd Sub' ------------------------------------------------------------Sub Main(ByVal sParams As String) dlog("Please read the instructions on how to configure my.Alert.",1)End Sub' ------------------------------------------------------------' ------------------------------------------------------------Sub dlog(ByVal sError As String, Optional ByVal iLevel As Integer = 3) Dim sLogLevel As String ' ' 0 = None ' 1 = Errors ' 2 = Info ' 3 = Verbose ' If sSettingLogLevel = iLevel And sSettingLogLevel 0 Then Select Case iLevel Case 3 sLogLevel = "Debug" Case 2 sLogLevel = "Info" Case 1 sLogLevel = "Error" End Select hs.WriteLog("my.Alert", sLogLevel & " --- " & sError) End If End Sub' ------------------------------------------------------------' ------------------------------------------------------------Function ProcessData(ByVal sURL As String, ByVal sRegExPattern As String,ByVal sRegExReplace As String) As String Dim sData As String Dim sResult As String Dim sSavedData As String dlog("ProcessData(" & sURL & "," & sRegExPattern & "," & sRegExReplace & ")",3) If sURL.Contains("{{") Then sURL = ParseVariables(sURL) sData = GetData(sURL) dlog("ProcessData(): size of received data is " & sData.Length,3) sData = PrepData(sData) 'dlog("ProcessData(): original data : " & sData,3) Try Dim RegEx = New RegEx(sRegExPattern) sResult = RegEx.Match(sData).Groups(sRegExReplace).Value Catch ex As ArgumentNullException dlog("ProcessData(): One of the parameters in the " & sConfigINIPath & " file has not been configured properly",1) Return "no data" Catch ex As ArgumentException dlog("ProcessData(): Invalid Regular Expression",1) Return "no data" Catch ex As Exception hs.WriteLog("my.Alert","ProcessData() Exception Error: " & Ex.Message) End Try dlog("ProcessData(): size of processed data is " & sResult.Length,3) dlog("ProcessData(): data : " & sResult,3) If bConfigHTML True Then sResult = CleanData(sResult) End If sResult = FormatData(sResult) dlog("ProcessData(): " & sResult,3) sSavedData = hs.GetINISetting(sConfigProfile, "Content", "0", sConfigINIPath) dlog("ProcessData(): Saved data is " & sSavedData.Length & " long, new data is " & sResult.Length & " long",3) If sSavedData sResult dlog("ProcessData(): Change detected, saving data to " & sConfigINIPath,2) hs.SaveINISetting(sConfigProfile, "Content", sResult, sConfigINIPath) Return sResult Else dlog("ProcessData(): No change detected",2) Return "" End IfEnd Function' ------------------------------------------------------------Function GetData(ByVal sURL As String) As String Dim sData As String Dim hRequest As System.Net.HttpWebRequest Dim hResult As System.Net.HttpWebResponse Dim iStatusCode As Integer Dim sStatusDescription As String dlog("GetData(" & sURL & ")",3) Try hRequest = CType(System.Net.WebRequest.Create(sURL), System.Net.HttpWebRequest) hRequest.ContentType = "text/html" hRequest.UserAgent = "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_2) AppleWebKit/537.17 (KHTML, like Gecko) Chrome/24.0.1309.0 Safari/537.17" hRequest.Method = "GET" hRequest.AllowAutoRedirect = True hRequest.TimeOut = 10000 hResult = CType(hRequest.GetResponse(), System.Net.HttpWebResponse) iStatusCode = hResult.StatusCode sStatusDescription = hResult.StatusDescription dlog("GetData() HTTP response: " & iStatusCode & " : " & sStatusDescription,2) If iStatusCode = System.Net.HttpStatusCode.OK Then sData = New System.IO.StreamReader(hResult.GetResponseStream()).ReadToEn d() Else dlog("GetData(): An error has occurred while downloading data.",1) Return "ERROR" End If hResult.Close() Catch ex As Exception dlog("An error has occurred while downloading data from " & sURL & " : " & ex.ToString(),1) End Try dlog("GetData(): " & sData) Return sDataEnd Function' ------------------------------------------------------------Function PrepData(ByVal sData As String) 'dlog("PrepData(): Prepping HTML data") 'sData = Regex.Replace(sData, "]*[\s\S]*?", string.Empty) 'dlog("PrepData(): " & sData,3) Return sDataEnd Function' ------------------------------------------------------------Function CleanData(ByVal sData As String) dlog("CleanData(): Scrubbing HTML data") sData = Regex.Replace(sData, "", string.Empty) dlog("CleanData(): " & sData,3) Return sDataEnd Function' ------------------------------------------------------------Function FormatData(ByVal sData As String) Dim cTrimChar() As Char = { "*"c, " "c, "'"c, " "c} dlog("FormatData(): Before: " & sData,3) sData = sData.Replace(ControlChars.Tab,"") sData = sData.Replace(ControlChars.CrLf,"") sData = sData.Replace(ControlChars.Lf,"") sData = sData.Replace(ControlChars.Cr,"") Do While sData.IndexOf(" ") -1 sData = sData.Replace(" ", " ") Loop sData = sData.Trim(cTrimChar) dlog("FormatData(): After: " & sData,3) return sDataEnd Function' ------------------------------------------------------------' ------------------------------------------------------------' ------------------------------------------------------------' ------------------------------------------------------------Function ParseVariables(ByVal sInput As String) As String ' ' Examples: {{String:Y12}} {{Value:Y11}} ' Dim sOutput As String Dim sPattern As String = "(?\{\{(?String|Value)?\S\d{1,2})\}\})" sOutput = sInput dlog("ParseVariables(" & sOutput & ")",3) Dim r As New Regex(sPattern) Dim m As Match = r.Match(sInput) While m.Success 'dlog("ParseVariables(): " & m.Groups("cmd").Value & " parameter for " & m.Groups("device").Value,3) Select Case m.Groups("cmd").Value Case "String" dlog("ParseVariables(): replacing " & m.Groups("var").Value & " with " & hs.DeviceString(m.Groups("device").Value),3) sOutput = sOutput.Replace(m.Groups("var").Value, hs.DeviceString(m.Groups("device").Value)) Case "Value" dlog("ParseVariables(): replacing " & m.Groups("var").Value & " with " & hs.DeviceValue(m.Groups("device").Value),3) sOutput = sOutput.Replace(m.Groups("var").Value, hs.DeviceValue(m.Groups("device").Value)) End Select m = m.NextMatch() End While dlog("ParseVariables():" & sOutput,3) Return sOutputEnd Functionimports 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 RegionEnd Module
7/14/2013 7:45:26 AM Error Script compile error: Statement is not valid in a namespace.on line 0
7/14/2013 7:45:26 AM Event Running script in background: myAlert.vb("monitor","3@cnnbreakingnews")
7/14/2013 7:45:26 AM Event Event Trigger "my.Alert CNN Breaking News"Tom
baby steps...starting again with HS3
HS3Pro: Z-NET & 80 Z wave Devices,
HSTouch: 4 Joggler (Android Kitkat), 2 iPhone, 3 iPads
Whole House Audio: 5 SqueezePlay Jogglers w Bose Speakers
In The Works: 10 Cameras Geovision, new Adecmo/Envisalink Alarm, Arduinos
System: XP on Fanless Mini-ITX w/ SSD
Comment
-
I apologize for not responding, I never got any alerts for new messages in this thread.
Let me take a closer look at this, and will post a response soon (don't see anything obvious). In the meantime, can you share what version of Homeseer you are running?HSPRO 2.4 (ESXi 4.1) | my.Alert NEW | my.Trigger | HSTouch | ACRF2 | UltraM1G | BLWeather | BLLan | Rover
(aka xplosiv)
Do You Cocoon? Home Automation News, Tutorials, Reviews, Forums & Chat
Comment
-
Thank you for your reply. Sorry I should have included this info earlier. Using HS PRO 2.5.0.52. Thank you again for your help.Tom
baby steps...starting again with HS3
HS3Pro: Z-NET & 80 Z wave Devices,
HSTouch: 4 Joggler (Android Kitkat), 2 iPhone, 3 iPads
Whole House Audio: 5 SqueezePlay Jogglers w Bose Speakers
In The Works: 10 Cameras Geovision, new Adecmo/Envisalink Alarm, Arduinos
System: XP on Fanless Mini-ITX w/ SSD
Comment
-
Sorry to bother again, but I just can't get my head around this regex stuff.
Here are the 2 items I am missing for my weather pages.
Thank you,
Tim
Link -Code:http://www.wunderground.com/cgi-bin/findweather/getForecast?query=51334&sp=KIASPIRI1
ps - I only really need the numbers ie, 10 and 4
pps - I had to attach the page sources, sorryAttached FilesFB Page - https://www.facebook.com/pages/Capt-Tim/209398425902188
HSTouch Layouts - https://www.facebook.com/media/set/?...5902188&type=3
Comment
-
Ok, forget that last post, I found another way.
I do have a question about the lake temp you worked out for me.
I went to the site - http://waterdata.usgs.gov/ia/nwis/uv?06604200. then opened up the ini file to look at what you did.
Then I looked at the page source for the website, found where you got the temp value, but this -Code:RegExSearch=instantaneous value:\s(?<temp>[0-9]{1,3}\.[0-9])\s RegExReplace=temp
Now the reason for all this. I now want to do the Gage Feet reading for the lake. So I thought i could figure it out from the Lake Temp entry, but I can't see how you got all those numbers and letters.
See below -
PHP Code:URL=http://waterdata.usgs.gov/ia/nwis/uv?06604200
RegExSearch=instantaneous value:\s(?<temp>[0-9]{1,3}\.[0-9])\s
RegExReplace=temp
<tr>
<td width="35"></td>
<td>
<table id="table_06604200_15_00010" border="0">
<tr>
<td nowrap="nowrap">Most recent instantaneous value: 24.4 08-25-2013 09:45 CDT </td>
<td align="right"> </td>
</tr>
<tr>
<td width="35"></td>
<td>
<table id="table_06604200_12_00065" border="0">
<tr>
<td nowrap="nowrap">Most recent instantaneous value: 3.90 08-25-2013 09:45 CDT </td>
<td align="right"> </td>
</tr>
TimFB Page - https://www.facebook.com/pages/Capt-Tim/209398425902188
HSTouch Layouts - https://www.facebook.com/media/set/?...5902188&type=3
Comment
-
If you aren't familiar with regular expressions, then my example is going to look like an Alien language for sure. Check out this website for examples/tutorials.
That said, let me explain the example quickly:
RegExSearch=instantaneous value:\s(?[0-9]{1,3}\.[0-9])\s
[0-9] means a number falling in the specified range
{1,3} means the previous component has to be repeated at least once, up to 3 times)
\. means literally a dot
So in this case, we are looking for a number with up to 3 digits, and 1 decimal point.
I'm on my phone right now, but if you still can't figure it out, post another message in this thread, and I'll create the regex once I get home.HSPRO 2.4 (ESXi 4.1) | my.Alert NEW | my.Trigger | HSTouch | ACRF2 | UltraM1G | BLWeather | BLLan | Rover
(aka xplosiv)
Do You Cocoon? Home Automation News, Tutorials, Reviews, Forums & Chat
Comment
-
[VB.NET] my.Alert
Hi Electron,
If you have time, could you also look at post #21 and see what the cause of these errors might be. I've re installed everything about four times and still no luck.
Tom
Sent from my iPhoneTom
baby steps...starting again with HS3
HS3Pro: Z-NET & 80 Z wave Devices,
HSTouch: 4 Joggler (Android Kitkat), 2 iPhone, 3 iPads
Whole House Audio: 5 SqueezePlay Jogglers w Bose Speakers
In The Works: 10 Cameras Geovision, new Adecmo/Envisalink Alarm, Arduinos
System: XP on Fanless Mini-ITX w/ SSD
Comment
-
Thank you very much.
Your explanation was perfect. I was able to get it on the first try.
PHP Code:RegExSearch=instantaneous value:\s(?<stage>[0-9]{1,3}\.[0-9][0-9])\s
RegExReplace=stage
DeviceString=I28
Content=3.89
TimFB Page - https://www.facebook.com/pages/Capt-Tim/209398425902188
HSTouch Layouts - https://www.facebook.com/media/set/?...5902188&type=3
Comment
-
What happens when you load the JavaScript file directly? In theory, you can monitor any file, but that's assuming there isn't some other weird stuff going on.HSPRO 2.4 (ESXi 4.1) | my.Alert NEW | my.Trigger | HSTouch | ACRF2 | UltraM1G | BLWeather | BLLan | Rover
(aka xplosiv)
Do You Cocoon? Home Automation News, Tutorials, Reviews, Forums & Chat
Comment
Comment