Here’s some code that will allow you to Twitter your Indigo Insteon Traffic…. Â It will Tweet when a device is turned on or off…Just place it in the Attachments folder for Indigo. Â If you have any suggestions, improvements, or questions, just let me know.
If there is interest in it, I may continue to develop this… Â This was written from a request from SeaofClouds… See http://www.perceptiveautomation.com/phpBB2/viewtopic.php?t=2651&start=0&postdays=0&postorder=asc&highlight=&sid=e714b1b9f304a3ecaa17e1a8a3f7b93e
property TwitterID : “Twitter User Name”
property TwitterPassword : “Twitter Password”
Â
on _convertHexStrToInteger(hexStr)
set the hexList to “0123456789ABCDEF”
copy hexStr to {a1, a2, skip1, b1, b2, skip2, c1, c2}
set a1o to (offset of a1 in hexList) – 1
set a1o to (offset of a1 in hexList) – 1
set a2o to (offset of a2 in hexList) – 1
set b1o to (offset of b1 in hexList) – 1
set b2o to (offset of b2 in hexList) – 1
set c1o to (offset of c1 in hexList) – 1
set c2o to (offset of c2 in hexList) – 1
set val to 256 * 256 * (a1o * 16 + a2o)
set val to val + 256 * (b1o * 16 + b2o)
set val to val + c1o * 16 + c2o
return val
end _convertHexStrToInteger
Â
using terms from application “IndigoServer”
on log_tweet(log_text)
log log_text as string using type “Tweet”
end log_tweet
on receive insteon event of eventType for address addrString using broadcast group groupNum with increment deltaVal command value absVal
—log_tweet(“Received Insteon Event”)
if eventType is not instnTurnOn and eventType is not instnTurnOff and eventType is not instnFastOn and eventType is not instnFastOff then
log_tweet(“Is not Turn On / Turn Off”)
return — not a command type we are interested in
end if
set TwitterDeviceAddresses to {}
repeat with dev in devices
if type of dev is insteon then
—log_tweet(address of dev)
set addrVal to my _convertHexStrToInteger(address of dev)
if addrString as integer = addrVal as integer then
set Device_Name to name of dev as string
if eventType is instnTurnOn or eventType is instnFastOn then set action to “Turned On”
if eventType is instnTurnOff or eventType is instnFastOff then set action to “Turned Off”
set theMessage to “Indigo – “ & Device_Name & ” “ & action
log_tweet(theMessage)
end if
end if
end repeat
—set theMessage to “This is a test of Indigo Integration / Broadcast from Applescript”
set TwitterLogin to TwitterID & “:” & TwitterPassword
set TwitterStatus to quoted form of (“status=” & theMessage)
set results to do shell script “curl –user “ & TwitterLogin & ” –data-binary “ & TwitterStatus & ” http://twitter.com/statuses/update.json”
log_tweet(“Sent Tweet”)
end receive insteon event
end using terms from