Announcement

Collapse
No announcement yet.

TwittSeer: A Twitter plugin for HomeSeer

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    TwittSeer: A Twitter plugin for HomeSeer

    I figured I needed to learn how to create plugins. Scripting is great, but I'd like a little more control and support for DLLs and if I hadn't used 64 bit Win7 then debugging would also be easier.


    This plugin is based on TwitterVB and Ultrajones' VB.NET Template (I need to donate to him! ), and at the moment it doesn't cover all functions available in the API.

    This plugin lets you:
    • Tweet automatically using events.
    • Trigger events from new tweets.
    • Supports multiple accounts. NEW!
    • Browse timeline or direct messages (NEW!) using the plugin status devices (great for HStouch). The status device is updated when you like.
    • See all new tweets and direct messages since last update in a separate device. NEW!
    • Use special keywords to include DeviceString ( DS(code) ), DeviceStatus ( ST(code) ), DeviceValue (DV(code) ) or even an expression ( EXPR(1+2) ). NEW!
    • Post by "HomeSeer" (I thought that was a nice touch).
    • Scripting functions NEW!


    Check my Twitter account for a sample!
    Just remember, I do a lot of debugging at the time...


    The special keywords needs a device code, and are then replaced. For example: If device A1 is on, and this text in the Tweet-field (after Adding the Tweet Action in an event):
    Code:
    A1 status is ST(A1)
    .... will post this on Twitter:
    A1 status is ON
    Posted by Moskus on 28.02.20.10 18:20 using HomeSeer
    The new EXPR keyword let's you do a calculation on the fly before posting a tweet. This is ideal for example for temperatures which typically are stored as Integers instead of decimals. For example will this:
    Code:
    Temperature in the living room is EXPR(DV([2)/10) deg C
    .... will post this on Twitter:
    Temperature in the living room is 21,5 deg C
    Posted by Moskus on 07.03.10 19:40 using HomeSeer
    Events may be filtered on:
    1) Contents. Enter the words the tweet has to contain and seperate them by using space. Examle: If you enter "awesome TwittSeer", this tweet "TwittSeer is awesome" will be triggered. And the tweet "TwittSeer is fantastic" will not.

    2) The username. For example "moskus" will only trigger if any of the new tweet are made by the user with the screenname "moskus", using a pipe before the name means "not": "|moskus" will trigger dhe event if the tweets are not made by moskus. There can be only one username filter at the moment




    Click to enlarge



    Click to enlarge


    Scripting functions:
    Tweeting some text using account number one, the default account:
    hs.Plugin("TwittSeer").Tweet("This is the message")

    Tweeting some text using account number three:
    hs.Plugin("TwittSeer").Tweet("This is the message", 3)

    Tweeting some text using the account name
    hs.Plugin("TwittSeer").Tweet("This is the message", "moskus")


    Sending a direct message using account number one, the default account:
    hs.Plugin("TwittSeer").SendDM("This is the message", "to_user_screenname")

    Tweeting some text using account number three:
    hs.Plugin("TwittSeer").SendDM("This is the message", "to_user_screenname", 3)

    Tweeting some text using the account name
    hs.Plugin("TwittSeer").SendDM("This is the message", "to_user_screenname", "moskus")

    Functions available for EXPR():
    All operators, such as + - * / are available, % works too. For boolean algebra you can use "and" and "or"
    Other useful functions:


    MATH FUNCTIONS

    Function math_pi() As Double
    ============================
    Input:
    EXPR(math_pi)

    Output:
    3,14159265358979
    ============================


    Function sin(ByVal v As Double) As Double
    ============================
    Input:
    EXPR(sin(math_pi))

    Output:
    0
    ============================


    Function cos(ByVal v As Double) As Double
    ============================
    Input:
    EXPR(cos(math_pi))

    Output:
    -1
    ============================


    Function rnd() As Integer
    ============================
    Input:
    EXPR(rnd)

    Output:
    68
    ============================


    Function random() As Integer
    ============================
    Input:
    EXPR(random)

    Output:
    70
    ============================


    Function Int(ByVal value As Double) As Double
    ============================
    Input:
    EXPR(Int(3.65))

    Output:
    3
    ============================


    Function Round(ByVal value As Double) As Double
    ============================
    Input:
    EXPR(Round(3.65))

    Output:
    4
    ============================
    ============================
    Input:
    EXPR(Round(3.65, 1))

    Output:
    3,6
    ============================


    TIME FUNCTIONS

    Function now() As DateTime
    ============================
    Input:
    EXPR(now)

    Output:
    17.03.2010 09:44:50
    ============================


    Function today() As DateTime
    ============================
    Input:
    EXPR(today)

    Output:
    17.03.2010
    ============================


    Function [Date](ByVal year As Double, ByVal month As Double, ByVal day As Double) As DateTime
    ============================
    Input:
    EXPR(Date(2010, 3, 17))

    Output:
    17.03.2010
    ============================




    STRING FUNCTIONS

    Function len(ByVal str As String) As Double
    ============================
    Input:
    EXPR(len("Test string"))

    Output:
    11
    ============================


    Function trim(ByVal str As String) As String
    ============================
    Input:
    EXPR(trim(" Test string "))

    Output:
    Test string
    ============================


    Function Format(ByVal value As Object, ByVal style As String) As String
    ============================
    Input:
    EXPR(Format("Input variable here {0} in this string", "var"))

    Output:
    Input variable here var in this string
    ============================


    Function UCase(ByVal value As String) As String
    ============================
    Input:
    EXPR(UCase("lower"))

    Output:
    LOWER
    ============================


    Function LCase(ByVal value As String) As String
    ============================
    Input:
    EXPR(LCase("UPPER"))

    Output:
    upper
    ============================


    Function WCase(ByVal value As String) As String
    ============================
    Input:
    EXPR(WCase("UPPER"))

    Output:
    Upper
    ============================



    CONDITIONAL FUNCTIONS

    Function iifd(ByVal cond As Boolean, ByVal TrueValue As Double, ByVal FalseValue As Double) As Double
    ============================
    Input:
    EXPR(iifd(1=1,5,2))

    Output:
    5
    ============================
    ============================
    Input:
    EXPR(iifd(1>1,5,2))

    Output:
    2
    ============================


    Function iift(ByVal cond As Boolean, ByVal TrueValue As Date, ByVal FalseValue As Date) As Date
    ============================
    Input:
    EXPR(iift(1=1, now, today))

    Output:
    17.03.2010 10:01:41
    ============================
    ============================
    Input:
    EXPR(iift(1=2, now, today))

    Output:
    17.03.2010
    ============================


    Function iif(ByVal cond As Boolean, ByVal TrueValue As String, ByVal FalseValue As String) As String
    ============================
    Input:
    EXPR(iif(1=1, "This is true", "This is false"))

    Output:
    This is true
    ============================
    ============================
    Input:
    EXPR(iif(1=2, "This is true", "This is false"))

    Output:
    This is false
    ============================
    The plan is to:
    • Support image uploading. Great for doorbell rings.
    • Create a better view of all tweets.


    How to install:
    • Download the zip-file under
    • Shut down HomeSeer 2
    • Place the two files in your HomeSeer 2 directory
    • Start HomeSeer 2
    • Goto Setup -> Interfaces and enable TwittSeer, remember to click save
    • Click the new TwittSeer button on the second button row
    • Navigate to the "Settings" page
    • Click Request Pin link ("Click here") and follow the instructions. Don't worry, it's not dangerous, and I or Twitter can't access your login credentials. This is just another layer of security instead of passing and storing your username/password as readable text.
    • You'll receive a PIN. This needs to be entered (copy&paste) into the "Enter PIN" field
    • Click the "Verify User" button, and hopefully you'll get a message stating that the PIN has been verified.
    • You're done! Start tweeting!



    To remove, close HomeSeer, delete the two dll-files and you can remove the hspi_twittseer.ini file from the config directory too. After that you are free to delete the TwittSeer Timeline Device.


    All comments and ideas are welcome!
    Only keep in mind that this is my first plugin. Ever.


    Changelog:
    0.6.1
    Checking for DMs throw a 403 "Forbidden" message. I don't know how to fix it as it seems to occur random, so for now it is disabled. You can enable it yourself (at your own risk). I've contacted the authors of TwitterVB, we'll see what they say...
    Timer/loop can be manually reset.


    0.5.2
    Bug correction: Filters for event trigging weren't working properly. Now it should be fixed.
    Added option to disable logging for posting tweets.

    0.5.1
    Bug correction: Filters for event trigging weren't working properly.
    Bug correction: Account names are now not case sensivitve.
    Bug correction:The optional field for Event Action is now optional again...
    Scripting functions are now present

    0.5.0
    NB! Now requires .NET framework 3.5
    Support for multiple accounts
    A new device only for new tweets since last update
    A device for the Timeline for each account
    A device for the Direct Messages for each account
    Trigger events based on Direct Messages as well as Tweets
    Send Tweets and Direct Messages from the diffetent accounts associated with the plugin
    Also corrected a bug for DeviceValues, DV(code)

    See details on page 7


    0.3.2
    Event trigging has been rewritten
    Multiple replacement statements are now allowed

    0.2.6
    Added new version of TwitterVB
    Better error handling
    Better support for EXPR() functions

    0.2.3
    Found a little bug when trigging an event where a specified screen name is specified. Fixed.

    0.2.2
    Removed "TwittSeer is starting" tweet

    0.2.1
    Added option to trigger events
    Added support for expressions

    0.0.1
    Initial release



    Remember the .NET Framework version 3.5!
    Attached Files
    Last edited by Moskus; July 7, 2011, 01:52 PM.
    HSPro 3.0.0.458, Z-NET with Z-wave plugin 3.0.1.190, RFXCOM + 2x RFXtrx433E, HSTouch, Squeezebox plugin, iTach IP/WF2IR & GC-100-6 with UltraGCIR, BLDenon, NetcamStudio, Jon00s Webpage builder, Harmony Hub plugin, SCSIP (with FreePBX), Arduino plugin, IFTTT, Pushalot plugin, Device History plugin.
    Running on Windows 10 (64) virtualized
    on ESXi (Fujitsu Primergy TX150 S8).
    WinSeer (for Win10) - TextSeer - FitbitSeer - HSPI_MoskusSample

    Are you Norwegian (or Scandinavian) and getting started with HomeSeer? Read the "HomeSeer School"!

    #2
    Moskus, you work quickly.

    Comment


      #3
      Originally posted by heatvent View Post
      Moskus, you work quickly.
      It's easy to be fast when you're standing on the shoulders of giants...
      HSPro 3.0.0.458, Z-NET with Z-wave plugin 3.0.1.190, RFXCOM + 2x RFXtrx433E, HSTouch, Squeezebox plugin, iTach IP/WF2IR & GC-100-6 with UltraGCIR, BLDenon, NetcamStudio, Jon00s Webpage builder, Harmony Hub plugin, SCSIP (with FreePBX), Arduino plugin, IFTTT, Pushalot plugin, Device History plugin.
      Running on Windows 10 (64) virtualized
      on ESXi (Fujitsu Primergy TX150 S8).
      WinSeer (for Win10) - TextSeer - FitbitSeer - HSPI_MoskusSample

      Are you Norwegian (or Scandinavian) and getting started with HomeSeer? Read the "HomeSeer School"!

      Comment


        #4
        Neat idea.. not sure how many of my followers would be happy with all those tweets but Im going to give it a go, might even set up a new twitter account just for this.. nice 1

        TrOjAn

        Comment


          #5
          Please add "Twitter Monitoring" soon this would be fab!

          Comment


            #6
            Maybe I'm "old-fashioned" but...I don't understand the point of Tweeting...

            --Dan
            Tasker, to a person who does Homeautomation...is like walking up to a Crack Treatment facility with a truck full of 3lb bags of crack. Then for each person that walks in and out smack them in the face with an open bag.

            Comment


              #7
              that's two of us, I barely know what I'm doing let alone tell everyone else what I think I'm supposed to be doing.
              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


                #8
                Look here. I've been using twitter for months now and love it.

                http://board.homeseer.com/showthread.php?t=137585
                Regards, Bob

                Comment


                  #9
                  I have all my servers sending status which then gets displayed on mobiles, TV's and PC's without lifting a finger...even my XBox!

                  Comment


                    #10
                    Originally posted by darren-mc View Post
                    Please add "Twitter Monitoring" soon this would be fab!
                    I will.
                    But what exactly do you mean by "Twitter Monitoring"?
                    HSPro 3.0.0.458, Z-NET with Z-wave plugin 3.0.1.190, RFXCOM + 2x RFXtrx433E, HSTouch, Squeezebox plugin, iTach IP/WF2IR & GC-100-6 with UltraGCIR, BLDenon, NetcamStudio, Jon00s Webpage builder, Harmony Hub plugin, SCSIP (with FreePBX), Arduino plugin, IFTTT, Pushalot plugin, Device History plugin.
                    Running on Windows 10 (64) virtualized
                    on ESXi (Fujitsu Primergy TX150 S8).
                    WinSeer (for Win10) - TextSeer - FitbitSeer - HSPI_MoskusSample

                    Are you Norwegian (or Scandinavian) and getting started with HomeSeer? Read the "HomeSeer School"!

                    Comment


                      #11
                      I would love to be able to (holy grail)

                      To be able to:

                      • subscribe to a private feed
                      • Check for a phrase within the tweet and perform an action


                      "Home Phone Server: Critical alarm Resource: SIP server is not responding"

                      Is an example of a tweet which I use when something goes wrong..this gets tweeted by my monitoring system. I would love to be able to pick that out and power cycle the phone system for example.

                      Does that help?

                      Comment


                        #12
                        Originally posted by drozwood90 View Post
                        Maybe I'm "old-fashioned" but...I don't understand the point of Tweeting...

                        --Dan
                        Nor do I. We must be too old and have more to do than give everyone a minute by minute update of what we are doing.

                        In regards to this plugin, what is different from logging into HomeSeer and looking at your logs via UltrLog? If I have to open a url to my tweeter site I would open up a url to my log view.
                        -Rupp
                        sigpic

                        Comment


                          #13
                          I have a "nice" Windows Seven desktop gadget which displays the network status without logging on.

                          At work I have an XP desktop...so no gadget...but have a firefox add-on which does the same job....no logging on to the server.

                          I only forward import events else you get bombarded and switch off!

                          Comment


                            #14
                            Originally posted by Rupp View Post
                            Nor do I. We must be too old and have more to do than give everyone a minute by minute update of what we are doing.
                            I have to agree. I cannot see the point either but I'm an old f**t too
                            Jon

                            Comment


                              #15
                              i am NO WHERE near the age of any you old f*rts and still don't understand twitter or many of the other social networking sites for that matter.

                              But those that do "get it", sure get excited about it and I can see where this plug-in would be pretty slick.

                              Comment

                              Working...
                              X