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:
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):
.... will post this on Twitter:
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:
.... will post this on Twitter:
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:
Functions available for EXPR():
The plan is to:
How to install:
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!
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)
A1 status is ON
Posted by Moskus on 28.02.20.10 18:20 using HomeSeer
Posted by Moskus on 28.02.20.10 18:20 using HomeSeer
Code:
Temperature in the living room is EXPR(DV([2)/10) deg C
Temperature in the living room is 21,5 deg C
Posted by Moskus on 07.03.10 19:40 using HomeSeer
Posted by Moskus on 07.03.10 19:40 using HomeSeer
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")
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
============================
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
============================
- 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!
Comment