ImperiHome
So, some back story. I work 2 hours away (1 way), but I only have to go in the office every other week. On the days that I go, My wife likes to check my progress on my way back. PHLocation mixed with Backitude and Imperihome does this swimmingly. I started with a simple tile that showed her the minutes from home. This way she could plan dinner, or know how much longer till she is done dealing with the kids alone...LOL.
That worked great and she loved it, but I wanted to go a step further, so I started playing around with it. Instead of a single tile in Imperihome, I went to a whole page. PHLocation provides a map, so I decided to use this. Because I don't know how to access things from the /html folder from outside my house (I know I can do port forwarding, but I Don't want to expose that), I decided to upload them via FTP to my personal Server. I also upload a file which contains the "link" that PHLocations puts in the "Street Address" device. I use scripting on my server to generate a page where the image is a link and I call that from Imperihome.
In case anyone wants the script I'm using to do this, here it is:
Note that it accepts 2 parameters. The Device ID of the Root Device for the user and the Device ID for the Street Address Device. I do this because i upload 2 files, one for myself and one for my wife.
This script runs whenever the street address device changes.
I also include 4 other values on that page via an ImperiHome sensor combo widget: City, Speed, distance from home, time to home.
Alexa/Voice Status
In addition to this, I wanted a way for my wife to check my progress without having to pull out her phone. Enter Jon00's awesome Alexa Helper script (http://board.homeseer.com/showthread.php?t=184504). Now my wife can ask in a couple different ways where I am. I know, it sounds stalky, but most the time I am home, so I don't really care...LOL
In order to do this though, I needed something to tell me where I am in a nice text format. So I wrote another script that runs the same time that the FTP one above does. This script checks a couple of different values and "builds" a string and sets that as the devices string. This one is a bit more customized and not so easy for someone else to use, but here it is anyways:
Notice it takes 1 param, the person's name.
So, in my "virtual" devices I have set up 3 values:
0 is "not at any known locations"
1 is "At home"
2 is "At the office" (sara doesn't work right now so doesn't have an office).
I have their values set accordingly on the status graphics tab.
You'll also notice that for "0", I build a string and add it. Have a couple of different scenarios. I'll do mine since there are more:
1. Frank is Home - I just set the device value to 1
2. Frank is at work - I just set the device value to 2
3. Frank is at neither - This is where it gets fun!
3.a I am moving and I have been at work since I've been home. I must be driving home: "Frank is currently in [City] and is about [Time from home] Minutes from home."
3.b. I'm not home, but I'm moving: "Frank is driving [Course] down [Street] at [speed] miles per hour"
3.c Any other situation: "Frank is at [Address]"
My wife's are simpler, but follow some of the same rules. I may add in some other things like how long I've been at a place.
To do all this all my wife has to do is ask the Echo: "Alexa, ask The House where Frank is" (or My Husband, or Daddy, or Dad, or Bubba (what my kids call me) and Jon00s script just sends back the devices string for that virtual device.
This is the config for my jon00s helper for getting this information:
* note that the AlexaText values are odd. I used the logs to determine what her and I were saying. For some reason it doesn't like Frank (and will come back as Franke sometimes). Luckily the helper script lets you do logical ORs so if it misses one I can add it in there. It also seems to miss "where" a lot when asked "Alexa Ask the House where frank is". It will just return "frank is" about half the time. Very frustrating.
Possible feature requests:
I know, it's a lot. I'm just throwing stuff out there. It's completely possible to do all/most this via scripting (Which is awesome by itself!).
Future additions:
Things I want to do but can't yet (not the fault of this plugin!). Ok, mostly the fault of ImperiHome.
Images
here are some Images (I wanted to put them inline, but I really can't on this forum very well). My map is blurred because I don't want my location (Besides my city) out there
So, some back story. I work 2 hours away (1 way), but I only have to go in the office every other week. On the days that I go, My wife likes to check my progress on my way back. PHLocation mixed with Backitude and Imperihome does this swimmingly. I started with a simple tile that showed her the minutes from home. This way she could plan dinner, or know how much longer till she is done dealing with the kids alone...LOL.
That worked great and she loved it, but I wanted to go a step further, so I started playing around with it. Instead of a single tile in Imperihome, I went to a whole page. PHLocation provides a map, so I decided to use this. Because I don't know how to access things from the /html folder from outside my house (I know I can do port forwarding, but I Don't want to expose that), I decided to upload them via FTP to my personal Server. I also upload a file which contains the "link" that PHLocations puts in the "Street Address" device. I use scripting on my server to generate a page where the image is a link and I call that from Imperihome.
In case anyone wants the script I'm using to do this, here it is:
Code:
Imports System.Text.RegularExpressions Sub Main(ByVal Parms As String) Dim ParmArray() As String = Parms.tostring.split(",") Dim userDeviceID As Integer = CInt(ParmArray(0)) Dim addressDeviceID As Integer = CInt(ParmArray(1)) Dim localFileLocation As String = "C:\Program Files (x86)\HomeSeer HS3\html\PHLocation\Maps\" Dim remoteFileLocation As String = "ftp://[removed]/HA/PHLocation/Maps/" Dim AddressFile As String = localFileLocation & CStr(userDeviceID) & ".cfm" If System.IO.File.Exists( localFileLocation & CStr(userDeviceID) & ".cfm" ) = True Then Dim objWriter As New System.IO.StreamWriter( localFileLocation & CStr(userDeviceID) & ".cfm" , false) objWriter.WriteLine( hs.DeviceString( addressDeviceID ) ) objWriter.Close() End If ' upload location file Dim miRequest As Net.FtpWebRequest = Net.WebRequest.Create( remoteFileLocation & CStr(userDeviceID) & ".cfm" ) miRequest.Credentials = New Net.NetworkCredential("[removed]", "[removed]") miRequest.Method = Net.WebRequestMethods.Ftp.UploadFile Dim bFile() As Byte = System.IO.File.ReadAllBytes(localFileLocation & CStr(userDeviceID) & ".cfm") Dim miStream As System.IO.Stream = miRequest.GetRequestStream() miStream.Write(bFile, 0, bFile.Length) miStream.Close() miStream.Dispose() ' upload map image Dim miRequest2 As Net.FtpWebRequest = Net.WebRequest.Create( remoteFileLocation & CStr(userDeviceID) & ".png" ) miRequest2.Credentials = New Net.NetworkCredential("[removed]", "[removed]") miRequest2.Method = Net.WebRequestMethods.Ftp.UploadFile Dim bFile2() As Byte = System.IO.File.ReadAllBytes(localFileLocation & CStr(userDeviceID) & ".png") Dim miStream2 As System.IO.Stream = miRequest2.GetRequestStream() miStream2.Write(bFile2, 0, bFile2.Length) miStream2.Close() miStream2.Dispose() end sub
This script runs whenever the street address device changes.
I also include 4 other values on that page via an ImperiHome sensor combo widget: City, Speed, distance from home, time to home.
Alexa/Voice Status
In addition to this, I wanted a way for my wife to check my progress without having to pull out her phone. Enter Jon00's awesome Alexa Helper script (http://board.homeseer.com/showthread.php?t=184504). Now my wife can ask in a couple different ways where I am. I know, it sounds stalky, but most the time I am home, so I don't really care...LOL
In order to do this though, I needed something to tell me where I am in a nice text format. So I wrote another script that runs the same time that the FTP one above does. This script checks a couple of different values and "builds" a string and sets that as the devices string. This one is a bit more customized and not so easy for someone else to use, but here it is anyways:
Code:
Imports System.Text.RegularExpressions Sub Main(ByVal Parms As String) Dim ParmArray() As String = Parms.tostring.split(",") Dim LocationString As String = "" If ParmArray(0) = "Frank" Then If hs.DeviceValue(667) = 1 Then hs.SetDeviceString( 1982 , "" , false ) hs.SetDeviceValueByRef( 1982 , 1 , true ) ' LocationString = "Frank is at Home" ElseIf hs.DeviceValue( 1972 ) = 1 Then hs.SetDeviceString( 1982 , "" , false ) hs.SetDeviceValue( 1982 , 2 , true ) ' LocationString = "Frank is at the Office" Else ' Frank was at the office since being at home, he is currently moving faster than 5 mph, and he is approaching home If hs.DeviceLastChangeRef( 1972 ) > hs.DeviceLastChangeRef(667) And hs.DeviceValue( 658 ) > 5 And hs.DeviceValue(668 ) = 1 Then LocationString = "Frank is currently in " + hs.DeviceString( 651 ) + " and is about " + CStr( hs.DeviceValue( 672 )) + " Minutes from home." ' If moving ElseIf hs.DeviceValue( 658 ) > 5 Then Dim LocationNoHTML As String = Regex.Replace(hs.DeviceString(650), "<.*?>", "") Dim LocationArray() As String = LocationNoHTML.split( {","} , StringSplitOptions.RemoveEmptyEntries ) LocationString = "Frank is Driving " + hs.DeviceString(660) + "down " + Regex.Replace(LocationArray(0), "^[\d-]* ", "") + " at " + CStr( hs.DeviceValue( 658 ) ) + " miles per hour" Else Dim LocationNoHTML As String = Regex.Replace(hs.DeviceString(650), "<.*?>", "") Dim LocationArray() As String = LocationNoHTML.split( {","} , StringSplitOptions.RemoveEmptyEntries ) LocationString = "Frank is currently At " + LocationArray( 0 ) + " " + LocationArray( 1 ) + " " + LocationArray( 2 ) + ". " End If hs.SetDeviceString( 1982 , LocationString , false ) hs.SetDeviceValueByRef( 1982 , 0 , true ) End If Else If hs.DeviceValue(704) = 1 Then hs.SetDeviceString( 1983 , "" , false ) hs.SetDeviceValueByRef( 1983 , 1 , true ) LocationString = "Sara is at Home" Else ' If moving If hs.DeviceValue( 700 ) > 5 Then Dim LocationNoHTML As String = Regex.Replace(hs.DeviceString(692), "<.*?>", "") Dim LocationArray() As String = LocationNoHTML.split( {","} , StringSplitOptions.RemoveEmptyEntries ) LocationString = "Sara is Driving " + hs.DeviceString(702) + "down " + Regex.Replace(LocationArray(0), "^[\d-]* ", "") + " at " + CStr( hs.DeviceValue( 700 ) ) + " miles per hour" Else Dim LocationNoHTML As String = Regex.Replace(hs.DeviceString(692), "<.*?>", "") Dim LocationArray() As String = LocationNoHTML.split( {","} , StringSplitOptions.RemoveEmptyEntries ) LocationString = "Sara is currently At " + LocationArray( 0 ) + " " + LocationArray( 1 ) + " " + LocationArray( 2 ) + ". " End If hs.SetDeviceString( 1983 , LocationString , false ) hs.SetDeviceValueByRef( 1983 , 0 , true ) End If End If end sub
So, in my "virtual" devices I have set up 3 values:
0 is "not at any known locations"
1 is "At home"
2 is "At the office" (sara doesn't work right now so doesn't have an office).
I have their values set accordingly on the status graphics tab.
You'll also notice that for "0", I build a string and add it. Have a couple of different scenarios. I'll do mine since there are more:
1. Frank is Home - I just set the device value to 1
2. Frank is at work - I just set the device value to 2
3. Frank is at neither - This is where it gets fun!
3.a I am moving and I have been at work since I've been home. I must be driving home: "Frank is currently in [City] and is about [Time from home] Minutes from home."
3.b. I'm not home, but I'm moving: "Frank is driving [Course] down [Street] at [speed] miles per hour"
3.c Any other situation: "Frank is at [Address]"
My wife's are simpler, but follow some of the same rules. I may add in some other things like how long I've been at a place.
To do all this all my wife has to do is ask the Echo: "Alexa, ask The House where Frank is" (or My Husband, or Daddy, or Dad, or Bubba (what my kids call me) and Jon00s script just sends back the devices string for that virtual device.
This is the config for my jon00s helper for getting this information:
Code:
[Trigger1] AlexaText=frank he's||where frank||frank yes||where husband||where dad||husband is||dad is||where daddy||daddy is||where bubba||bubba is||franke's Mode=1 AlexaResponse=[devicetext 1982] RunEvent= Runscript= Speak= SPClient= SpeakDevice= CAPI= Json= DeviceValue= SetDeviceValue= SetCapiValue= Delay=
Possible feature requests:
- MY new virtual device is kinda of specialized, but would it be possible to have a device like this automatically created and populated with your known places? 0 could always be "at no known locations for this user" and there could be a scripting hook that when it's 0 (zero) you can run that script (to set the device string). The plugin could then add values for known places as you create them.
The plugin could even be smart and have some of the strings I have above automatically done like "So and So is drving down [street] and heading towards [known place]". - A way to grab all the known places and/or users/devices from scripting so I can just loop through them and check the values (would simply my script and make it easier to decide where they are as I add users)
I know, it's a lot. I'm just throwing stuff out there. It's completely possible to do all/most this via scripting (Which is awesome by itself!).
Future additions:
- I think I'm going to change my "webpage" that has the map to include my virtual device text as well. Imperihome doesn't do a good job at wrapping text.
- At some point I will be adding a status screen in the house (I keep dreaming for a reasonably priced, well sized e-ink display to be released). When I do, I will use some of the stuff here to populate that.
- When my kids get phones, I will be adding this stuff for them. It's not that I don't trust them, but it will be nice to know where they are. I have a feeling when I do that, I will be adding lots of known locations to account for friend's houses and stuff like that ("Where is Winnie?": "Winnie is a Babara's house").
Things I want to do but can't yet (not the fault of this plugin!). Ok, mostly the fault of ImperiHome.
- I wish Imerihome would not make me put that stupid generic sensor icon on the combo sensor widget
- I wish that Imperihome would allow me to open links in tiles outside that tile (so that when you click the map, it opens either google maps in a browser or the app)
- I wish that I could make sensors in Imperihome "clickable" to go to another page. This way I could make the icon on the main menu more meaning full, but still have a way to get "more information"
- I wish I could convince my wife to take her phone with her everytime she leaves the house (even if she leaves it in the car)..LOL
- I hope one day I can do all of the Alexa stuff on Google Home (which I haven't bought yet!)
Images
here are some Images (I wanted to put them inline, but I really can't on this forum very well). My map is blurred because I don't want my location (Besides my city) out there
Comment