Originally posted by Rupp
View Post
Announcement
Collapse
No announcement yet.
How to determine if tomorrow is not a school day?
Collapse
X
-
Originally posted by langenet View PostInteresting... I never looked into this and now have found a great use of it.
However, when I tried this, aside from the fact that it worked, it seems that HS complains.
Dec-17 10:45:15 AM Error Getting POP message header, count: 1982 Index: 1234 :The enveloped-data message does not contain the specified recipient.
Dec-17 10:45:15 AM Error Getting POP message header, count: 1982 Index: 384 :The enveloped-data message does not contain the specified recipient.
Dec-17 10:45:15 AM email Initializing email, found 1982 messages
Dec-17 10:45:15 AM email Start checking server for email using POP
Dec-17 10:45:15 AM Startup Initializing email, will check server for new email
Dec-17 10:42:38 AM TTS Speak ():This is a test
Dec-17 10:42:38 AM Event Event Trigger "Calenadar Email Recieve test"
Dec-17 10:42:38 AM Error Getting POP message header, count: 1982 Index: 1234 :The enveloped-data message does not contain the specified recipient.
Dec-17 10:42:38 AM Error Getting POP message header, count: 1982 Index: 384 :The enveloped-data message does not contain the specified recipient.
Is this a bug? What is the default behavior of POP - leave email on server?
I run my own e-mail server which supports calendaring on the same system along side HS3. When the calendar event comes up, the system will send a reminder message. I see that HS logs in without issue... Just the error throws me off.
Have I missed something?
Robert
I can send a calendar message to it and despite checking each minute, it is processed cleanly. Can anyone else confirm this? I could create a rule such that if I get the reminder e-mail, I could forward it to the other account, but this gets a bit messy which in my opinion shouldn't be required.
RobertHS3PRO 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
-
Originally posted by jon00 View PostI'm more comfortable with scripts so this is how I would do it:
Copy the script below and save it in the scripts directory (something like SchoolTomorrow.vb)
Create a virtual device and note its reference number
Change the 1234 in the script to the actual reference number of your device you have just created.
Create a text file called NoSchoolTomorrowDates.txt and save it to your Homeseer Data directory.
In the text file, list the dates where there is no school tomorrow when this falls outside the normal Sunday to Thursday days.
Example:
12/24/2017
12/25/2017
(Make sure there are no spaces in the list including the top).
Run the script at 5:00pm each day from an event and the virtual device will have a value of 1 if there is a school day tomorrow and 0 if not.
Code:Imports System.IO Sub Main(ByVal Parm As Object) Try Dim Path As String = "" Dim FileReader As StreamReader Dim Data As String = "" Dim DayOfWeek As Integer Dim SchoolDayTomorrow As Boolean = True Dim DVRef As Integer = 1234 Path = hs.GetAppPath & "\data\NoSchoolTomorrowDates.txt" FileReader = New StreamReader(Path) DayOfWeek = DateTime.Now.DayOfWeek Select Case DayOfWeek Case 1 To 5 'Sunday To Thursday SchoolDayTomorrow = True Case 6 To 7 ' Friday & Saturday SchoolDayTomorrow = False End Select Do While FileReader.Peek >= 0 Data = FileReader.ReadLine() If Data <> "" Then If DateTime.Now.ToString.Contains(Data) Then SchoolDayTomorrow = False Exit Do End If End If Loop FileReader.Close() If hs.DeviceExistsRef(DvRef) Then If SchoolDayTomorrow Then hs.SetDeviceValueByRef(DvRef, 1, True) hs.SetDeviceString(DVref, "School Tomorrow", True) Else hs.SetDeviceValueByRef(DvRef, 0, True) hs.SetDeviceString(DVref, "No School Tomorrow", True) End If End If Catch Ex As Exception hs.WriteLog("Error", "Error in SchoolTomorrow.vb: " & Ex.ToString) End Try End Sub
Thanks for this script!
I have been trying to get it to work, with a little success.
I created a new device called "School Night (True/false)" Ref ID# 337
I created a text file with no spaces(the rest of this school year), and added tomorrows date as a test. 12/18/2017 is Monday, normally there is school, but I added it to the top of the list, to test if the script would see it.
****************************************
12/18/2017
12/25/2017
12/26/2017
12/27/2017
12/28/2017
12/29/2017
1/1/2018
1/2/2018
1/3/2018
1/4/2018
1/5/2018
1/15/2018
2/15/2018
2/16/2018
2/19/2018
3/26/2018
3/27/2018
3/28/2018
3/29/2018
3/30/2018
4/2/2018
5/25/2018
5/28/2018
5/29/2018
5/30/2018
5/31/2018
**********************************************
I copied the script, pasted it into NotePad++, changed "1234" to "337" and saved it as SchoolTomorrow.vb
Created a manual test event, to run the script.
If I manually turn off my virtual device #337, and manually run the script, the device will turn on. Works every time.
However, regardless if (12/18/2017) is in the date text file, Running the script will always turn the device on, and never turn the device back off.
Did I do something wrong?
Not sure on the virtual device, as it defaults to 100 is on, 0 is off.
Comment
-
You have to put the day before the text file i.e. if tomorrow is not a school day, the date entered would be today 12/17/2017.
The script can be modified to use the actual day if you want.
Change the line:
If DateTime.Now.ToString.Contains(Data) Then
To
If DateTime.Now.AddDays(1).ToString.Contains(Data) Then
Comment
-
Originally posted by Rupp View PostYou could do it the old fashion way and trust them until they break the trust and they will. Then when the trust is broken take away the privilege for, oh say, a month and I'll bet they'd maintain the trust when they get their phones and wifi back. My 27 year old daughter told me a few weeks ago that one of the best things we ever did for her was take her phone, tv, and door (yep bed room door) away for a month when she was 17.
This whole project started as a way to have homeseer automatically dock a few hours of internet/TV whenever he fails to get up on time, fails to get to school on time, etc. I also want homeseer to calculate his allowance, and dock it for any day he skips school, etc.
It sucks it has come to this, but he knows his mom and I can't keep track of everything, and watch him like a hawk. It is pretty easy to trick/fool parents who are playing the "trust" game.
However, homeseer has nothing better to do then to watch his bedroom lights, bathroom lights, house doors open/close when he leaves for school, and can react to his laziness as an impartial judge. My house is smarter than he is, and I am trying to prove a point. He will not be able to trick homeseer, and homeseer will not feel sorry for him and give him a break, either!
BUT, in order to get all this to work, hinges on the basics. I need homeseer to be able to accurately decide if it is a school day or school night. Once that code works, the rest of it will be easy.
Comment
-
Originally posted by jon00 View PostYou have to put the day before the text file i.e. if tomorrow is not a school day, the date entered would be today 12/17/2017.
The script can be modified to use the actual day if you want.
Change the line:
If DateTime.Now.ToString.Contains(Data) Then
To
If DateTime.Now.AddDays(1).ToString.Contains(Data) Then
Hi Jon00,
Yes, I need the text file with the dates to be the actual days off. It is much easier to create this list of actual days off with the school calendar.
When tomorrow is a holiday,
I need the script to be able to look at this list of dates TODAY, and set the virtual device to "School Night(true/false)" to false or 0.
It's hard to explain in writing, but I need homeseer to look into the future (1)one day, decide if tomorrow will be a holiday or not, and then set my virtual device today, so homeseer can use it today.
Will the code change you mentioned above, do this?
Comment
-
Your Brilliant!
I added the code change you mentioned, and it now Works perfect!
Now to do some more testing!!
Hopefully last question.
Will the script be able to function correctly if months are split?
For example: across the last day of the month/year, and the first day of the next month/year?
Lets say 5/1/2017 is a special date listed in the text file.
Will it be able to subtract (1)day and arrive at 4/30/2017 correctly?
Comment
-
Originally posted by langenet View PostSo I think there's a limitation to the number of e-mails that the account has in order to have this work without error. My account I defined above is actually an Imap account and with 1982 messages it appears that HS3 has issue digesting the return list or something. When I tested with another account which only had one message in it, it works fine.
I can send a calendar message to it and despite checking each minute, it is processed cleanly. Can anyone else confirm this? I could create a rule such that if I get the reminder e-mail, I could forward it to the other account, but this gets a bit messy which in my opinion shouldn't be required.
Robert
HS only looked at the 251 emails, but it is does appear to be looking for new emails; which is what I want it to do on HS start up.
Code:[email]->Start checking server for email using POP [email]->Initializing email, found 251 messages
Code:The enveloped-data message does not contain the specified recipient.
Len
HomeSeer Version: HS3 Pro Edition 3.0.0.435
Linux version: Linux homeseer Ubuntu 16.04 x86_64
Number of Devices: 633
Number of Events: 773
Enabled Plug-Ins
2.0.54.0: BLBackup
2.0.40.0: BLLAN
3.0.0.48: EasyTrigger
30.0.0.36: RFXCOM
3.0.6.2: SDJ-Health
3.0.0.87: weatherXML
3.0.1.190: Z-Wave
Comment
Comment