Announcement

Collapse
No announcement yet.

EZsnsRF (dakota motion sensor) external script

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

  • Oman
    replied
    That's beyond the scope of external device support, but I do have a system for Insteon specific message triggers.

    Jon
    Originally posted by JeffryD View Post
    Jon,

    A received-raw Insteon data callback would be very helpful. Not just for externally-registered devices, but for devices the plug-in handles itself. The callback should be ByRef instead of ByVal, so we can change what the plug-in sees. Something like:

    Code:
    Function RawInsteonNotification(ByRef InsteonData as Data) as Boolean
        ' process data, make changes, return True or False
        RawInsteonNotification = True
    End Function
    If the callback returns FALSE, the plug-in ignores the packet. If it returns TRUE, the plug-in does whatever it normally does (but the callback may have changed the packet's data).

    HomeSeer's design of only providing notifications on changes is quite limiting for detecting things like double-clicks or triple-clicks. A raw Insteon callback would also let us distinguish FAST OFF from OFF. FAST ON/OFFs get consumed by the plug-in right now, and by the time a notification gets to HomeSeer and thence to an external script, it's reduced to ON/OFF (and only if it's a change).

    I have a little program running in the background now that just samples the stream off the PLC every couple of seconds, looking for FAST OFFs. This is horribly inefficient, and relies on the PLC's buffering between calls, so it's also unreliable.

    Leave a comment:


  • JeffryD
    Guest replied
    Jon,

    A received-raw Insteon data callback would be very helpful. Not just for externally-registered devices, but for devices the plug-in handles itself. The callback should be ByRef instead of ByVal, so we can change what the plug-in sees. Something like:

    Code:
    Function RawInsteonNotification(ByRef InsteonData as Data) as Boolean
        ' process data, make changes, return True or False
        RawInsteonNotification = True
    End Function
    If the callback returns FALSE, the plug-in ignores the packet. If it returns TRUE, the plug-in does whatever it normally does (but the callback may have changed the packet's data).

    HomeSeer's design of only providing notifications on changes is quite limiting for detecting things like double-clicks or triple-clicks. A raw Insteon callback would also let us distinguish FAST OFF from OFF. FAST ON/OFFs get consumed by the plug-in right now, and by the time a notification gets to HomeSeer and thence to an external script, it's reduced to ON/OFF (and only if it's a change).

    I have a little program running in the background now that just samples the stream off the PLC every couple of seconds, looking for FAST OFFs. This is horribly inefficient, and relies on the PLC's buffering between calls, so it's also unreliable.

    Leave a comment:


  • Oman
    replied
    That's it. Register a device, send it some data, get data from it.

    Jon


    Originally posted by baudi View Post
    Jon,

    Is there any documentation of the Insteon plug-in's exposed methods and callbacks, or is what we see in the script the only ones that exist?

    David

    Leave a comment:


  • baudi
    replied
    Jon,

    Is there any documentation of the Insteon plug-in's exposed methods and callbacks, or is what we see in the script the only ones that exist?

    David

    Leave a comment:


  • Oman
    replied
    This is exactly what I was hoping for when I put in the external device support. Since SmartHome didn't actually make any sort of generic device support part of their spec it was virtually impossible to support these devices internally without continuously re-writing the plug-in.

    I'm glad to see that it is getting used. I would have preferred to be able to have some sort of generic device support in the plug-in itself for users but that sort of magic just wasn't possible without SmartHome defining something up front.

    The external device support is very low-level at the moment (as you well know) but it does allow you to cooperate with the built-in device support so that things work properly together. The one thing I was think about was adding a call to allow the script to register a link on a compliant remote device (one that supports standard link databases). This would be somewhat difficult since the plug-in would have to download the existing database each time it needed to be updated, but it could be done.

    If there are additional suggestions for additional calls or needed functions from the plug-in itself just let me know and I'll see what I can do.


    Jon




    Originally posted by baudi View Post
    Gotcha. I'll put the callback function back in.

    Thanks.

    David

    Leave a comment:


  • baudi
    replied
    Gotcha. I'll put the callback function back in.

    Thanks.

    David

    Leave a comment:


  • JeffryD
    Guest replied
    Interesting! Thanks for sharing. Your approach is similar to mine, although I ended up not using the classes and collections for the sake of clarity while playing with the code.

    StatusChangeCB is useful for the EZIO units so that when on/off is set within HomeSeer (either by clicking something on the Status page, or from within an event or script), we can operate the relays:

    This isn't strictly necessary, as one can write a relay-operate subroutine and call it directly.

    Code:
    Public Sub EZIOOperateRelay(parms as object)
       Dim iDevice as Integer
    
       Try
          If g_bEZIO_Enabled Then
             iDevice = parms
             If iDevice >= 1 AND iDevice <= 2 Then
                hs.plugin("Insteon").ExtDev_TransmitToExternalDevice(g_szEZIO_DevName,&H7,&H45,iDevice - 1)
             Else
                hs.WriteLog(g_szScriptname,"EZIOOperateRelay: Was expecting 1 or 2 as parameter")
             End If
          End If
    
       Catch ex As Exception
          hs.WriteLog(g_szScriptName,"Error in EZIOOperateRelay: " & ex.ToString)
       End Try
      
    End Sub
    My own callback for the EZIO2x4 does nothing more than call this subroutine. I'm using the two output relays to control the garage doors, so I added buttons called "Operate" on the HomeSeer Status page, and set the relays to shut off automatically after two seconds. This yields the same function as pressing the regular garage door momentary contacts, but I can do it from within HS.

    Leave a comment:


  • bobwondernut
    replied
    good man, sir.

    Leave a comment:


  • baudi
    replied
    Genaralized version of ExtDevSupport

    Tom and Jonathan,

    I've taken the liberty of generalizing the ExtDevSupport script to make it easier to handle new device types. I've tested the revised version with EZSnsRf, EZX10RF, and RemoteLinc. I don't have the EZIO or EZRain, but it should work OK with those devices, too.

    There were some parts of the code that didn't seem to me to be necessary, so I've commented them out. Please let me know if that was a mistake.

    By the way, it turns out not to be necessary to link the EZ devices with another Insteon device to make them visible to HomeSeer. All that's needed is to link the Dakota or X10 devices as broadcast devices. To do that, press and hold the link button on the EZ device for 4 seconds. Then make the RF device fire, then wait for the RF device to time out so that it will fire again, then fire it again. That will make the EZ LED stop blinking. Then press and hold the EZ LED for 4 seconds.

    This technique causes the EZ device to generate a broadcast instead of a group message when the RF device fires. The new version of the script handles those broadcast messages correctly. I think.

    David
    Attached Files

    Leave a comment:


  • bobwondernut
    replied
    Script update

    All:

    Here's a significantly improved version of the script. I've got this confirmed to work at home now with the following equipment:


    I've posted this one as a zip, so just unzip and copy the single script file into your Homeseer 2 Scripts directory.

    Install instructions are almost the same: follow the EZsnsRF manual's instructions to pair the sensors (one at a time) against your PLM/PLC. Then, edit the script in Notepad and give it the Insteon address of your EZsnsRF, make sure EnableEZSnsRF is set to True, and (optionally) set EZsnsRFNumSensorsToWatch to the number of Dakota Alert sensors/devices/channels you intend to monitor. Shut down and restart homeseer and you should see the devices appear in the status screen starting at E40 (unless you've changed the starting code in the script). Each device corresponds to the sensors bound to the ezsnsrf (in the order you bound them.)

    I also cleaned up a couple of lines of code for the other EZ devices simplehomenet makes. I don't have those devices so I can't test if they work now, but there was little chance of them working before.

    Range here is great -- I've got the outdoor sensors at least 300 feet away from the EZsnsRF! It's also very reliable!
    Attached Files

    Leave a comment:


  • jono
    replied
    That did it! Thanks very much for the help. This looks like it will be really cool.
    Jono

    Leave a comment:


  • bobwondernut
    replied
    Hey Jono:

    It occurs to me that your file might have been saved as Insteon_ExtDevSupport.vb.txt if you used notepad. Windows by default hides extensions for known file types (as it assumes people to be dumb), and would display the file in explorer as Insteon_ExtDevSupport.vb. To check, open the scripts folder in explorer, and go to the tools menu -> folder options. Set your options per the attached image to see full filenames and all files in that folder. Click OK and hopefully that's the issue.
    Attached Files

    Leave a comment:


  • bobwondernut
    replied
    Hey Jono:

    That's homeseer's internal scripting initialization messages and not the insteon plugin's. I have debugging enabled on the insteon config page, and when I start up HS2 with the script placed at c:\program files\homeseer 2\scripts\Insteon_ExtDevSupport.vb I see the following lines. Note that the insteon plug-in doesn't instantiate the script until after all start-up is complete.

    Code:
    6/24/2007 8:49:13 AM ~!~Startup~!~Starting scheduler
    6/24/2007 8:49:13 AM ~!~Startup~!~Start up complete.
    6/24/2007 8:49:13 AM ~!~Insteon~!~Requesting external device support registration...
    6/24/2007 8:49:25 AM ~!~Insteon~!~External device name EZSnsRF1 (Address:08.9E.01) has registered with callback to Insteon_ExtDevSupport.vb using method EZSnsRFRcv as external device #1
    6/24/2007 8:49:25 AM ~!~Insteon~!~Calling DM.AddRecord for 08.9E.01 1 True
    6/24/2007 8:49:25 AM ~!~Insteon~!~Registration complete.
    If you don't see these messages, then the plug-in isn't finding your script at the right location, or it can't read from the file.

    You should see your EZsnsRF's ID instead of 08.9E.01, provided that you've changed the ID in the .vb. The line to modify is:

    Code:
    Const EZSnsRFAddress As String = "08.9E.01"         ' The Insteon address of the EZSnsRF controller
    You also want to make sure this line is set to True:

    Code:
    Const EnableEZSnsRF As Boolean = True
    Hope that helps,
    -t

    Leave a comment:


  • jono
    replied
    this is very helpful, but unfortunately still not working for me. Could it be how the file is saved? I am using the correct file name and it is saved as a text file using ANSI encoding.


    My log says
    6/24/2007 1:48:22 AM - Startup - Scripting is OK
    6/24/2007 1:48:22 AM - Info - Finished initializing scripting

    but I don't see the new entries you mention
    thanks again for your guidance
    Jono

    Leave a comment:


  • bobwondernut
    replied
    Hey Jono:

    It has to be in the scripts directory, and explicitly named Insteon_ExtDevSupport.vb. The Insteon_ExtDevSupport_Source.vb is the example code that they ship with the plug-in, but it isn't enabled by default and has to be renamed in order to load.

    Make sure you changed the ID in the script to match the hex id of the rf module -- this is a must in order for it to work.

    When it's working, you'll see a message on the main Insteon Configuration web page directly above the "Save changes" button that says:

    Externally registered device: EZSnsRF1 (Insteon Address xx.xx.xx) registered through Insteon_ExtDevSupport.vb method EZSnsRFRcv

    where xx.xx.xx will be the ID of your ezsnsrf module. if you don't see this message, then the script isn't installed correctly or you haven't set the right address for the rf module in the script. You won't see E40-E47 until you've set up the script per the instructions above.

    don't forget to restart homeseer in between script changes.

    Leave a comment:

Working...
X