forked from openhab/openhab-addons
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Twitter] 3.0 Twitter Binding (openhab#10241)
* [twitter][WIP] Initial contribution using the 1.x binding as a template, I created a new Twitter Binding. Signed-off-by: Scott Hanson <[email protected]> (github: computergeek1507) Signed-off-by: Scott Hanson <[email protected]> * trying to fix twitter4j dependency stuff Signed-off-by: Scott Hanson <[email protected]> * add to bundle POM Signed-off-by: Scott Hanson <[email protected]> * trying to fix build Signed-off-by: Scott Hanson <[email protected]> * Fixed dependency issues, Got Actions working Signed-off-by: Scott Hanson <[email protected]> * updating readme Signed-off-by: Scott Hanson <[email protected]> * fix class name Signed-off-by: Scott Hanson <[email protected]> * Fixes based on review Signed-off-by: Scott Hanson <[email protected]> * Cleanup based on review and mvn checks Signed-off-by: Scott Hanson <[email protected]> * grammar fix Signed-off-by: Scott Hanson <[email protected]> * remove Apache dependencies Signed-off-by: Scott Hanson <[email protected]> * added Null Checks based on review Signed-off-by: Scott Hanson <[email protected]> * change null check around Signed-off-by: Scott Hanson <[email protected]>
- Loading branch information
1 parent
1c9836d
commit 3f0d5d4
Showing
14 changed files
with
769 additions
and
0 deletions.
There are no files selected for viewing
Validating CODEOWNERS rules …
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
This content is produced and maintained by the openHAB project. | ||
|
||
* Project home: https://www.openhab.org | ||
|
||
== Declared Project Licenses | ||
|
||
This program and the accompanying materials are made available under the terms | ||
of the Eclipse Public License 2.0 which is available at | ||
https://www.eclipse.org/legal/epl-2.0/. | ||
|
||
== Source Code | ||
|
||
https://github.com/openhab/openhab-addons | ||
|
||
== Third-party Content | ||
|
||
twitter4j | ||
* License: Apache License 2.0 | ||
* Project: https://twitter4j.org/ | ||
* Source: https://github.com/Twitter4J/Twitter4J | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
# Twitter Binding | ||
|
||
The Twitter binding allows your home to Tweet 280 characters at a time. It also supports direct messages and tweeting with media. | ||
|
||
## Supported Things | ||
|
||
``` | ||
account - Twitter Account. | ||
``` | ||
|
||
## Thing Configuration | ||
|
||
The Twitter Account Thing requires you to create a Twitter App in the Twitter Developer Page. | ||
|
||
| Property | Default | Required | Description | | ||
|-------------------|---------|:--------:|-----------------------------------| | ||
| consumerKey | | Yes | Consumer API Key | | ||
| consumerSecret | | Yes | Consumer API Secret | | ||
| accessToken | | Yes | Access Token | | ||
| accessTokenSecret | | Yes | Access Token Secret | | ||
| refresh | 30 | No | Tweet refresh interval in minutes | | ||
|
||
|
||
## Channels | ||
|
||
| channel | type | description | | ||
|------------|--------|------------------------------------------------| | ||
| lasttweet | String | This channel provides the Latest Tweet message | | ||
|
||
|
||
## Full Example | ||
|
||
twitter.things: | ||
|
||
``` | ||
Thing twitter:account:sampleaccount [ consumerKey="11111", consumerSecret="22222", accessToken="33333", accessTokenSecret="444444" ] | ||
``` | ||
|
||
twitter.items: | ||
|
||
``` | ||
String sample_tweet "Latest Tweet: [%s]" { channel="twitter:account:sampleaccount:lasttweet" } | ||
``` | ||
|
||
## Rule Action | ||
|
||
This binding includes rule actions for sending tweets and direct messages. | ||
|
||
* `boolean success = sendTweet(String text)` | ||
* `boolean success = sendTweetWithAttachment(String text, String URL)` | ||
* `boolean success = sendDirectMessage(String recipientID, String text)` | ||
|
||
Examples: | ||
|
||
``` | ||
val tweetActions = getActions("twitter","twitter:account:sampleaccount") | ||
val success = tweetActions.sendTweet("This is A Tweet") | ||
val success2 = tweetActions.sendTweetWithAttachment("This is A Tweet with a Pic", file:///tmp/201601011031.jpg) | ||
val success3 = tweetActions.sendTweetWithAttachment("Windows Picture", "D:\\Test.png" ) | ||
val success4 = tweetActions.sendTweetWithAttachment("HTTP Picture", "http://www.mywebsite.com/Test.png" ) | ||
val success5 = tweetActions.sendDirectMessage("1234567", "Wake Up" ) | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
|
||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<parent> | ||
<groupId>org.openhab.addons.bundles</groupId> | ||
<artifactId>org.openhab.addons.reactor.bundles</artifactId> | ||
<version>3.2.0-SNAPSHOT</version> | ||
</parent> | ||
|
||
<artifactId>org.openhab.binding.twitter</artifactId> | ||
|
||
<name>openHAB Add-ons :: Bundles :: Twitter Binding</name> | ||
|
||
<properties> | ||
<bnd.importpackage>!android.*,!com.android.org.*,!dalvik.*,!javax.annotation.meta.*,!org.apache.harmony.*,!org.conscrypt.*,!sun.*,!com.google.appengine.api.*</bnd.importpackage> | ||
</properties> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>org.twitter4j</groupId> | ||
<artifactId>twitter4j-core</artifactId> | ||
<version>4.0.7</version> | ||
<scope>compile</scope> | ||
</dependency> | ||
</dependencies> | ||
</project> |
9 changes: 9 additions & 0 deletions
9
bundles/org.openhab.binding.twitter/src/main/feature/feature.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<features name="org.openhab.binding.twitter-${project.version}" xmlns="http://karaf.apache.org/xmlns/features/v1.4.0"> | ||
<repository>mvn:org.openhab.core.features.karaf/org.openhab.core.features.karaf.openhab-core/${ohc.version}/xml/features</repository> | ||
|
||
<feature name="openhab-binding-twitter" description="Twitter Binding" version="${project.version}"> | ||
<feature>openhab-runtime-base</feature> | ||
<bundle start-level="80">mvn:org.openhab.addons.bundles/org.openhab.binding.twitter/${project.version}</bundle> | ||
</feature> | ||
</features> |
34 changes: 34 additions & 0 deletions
34
...g.twitter/src/main/java/org/openhab/binding/twitter/internal/TwitterBindingConstants.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
/** | ||
* Copyright (c) 2010-2021 Contributors to the openHAB project | ||
* | ||
* See the NOTICE file(s) distributed with this work for additional | ||
* information. | ||
* | ||
* This program and the accompanying materials are made available under the | ||
* terms of the Eclipse Public License 2.0 which is available at | ||
* http://www.eclipse.org/legal/epl-2.0 | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
*/ | ||
package org.openhab.binding.twitter.internal; | ||
|
||
import org.eclipse.jdt.annotation.NonNullByDefault; | ||
import org.openhab.core.thing.ThingTypeUID; | ||
|
||
/** | ||
* The {@link TwitterBindingConstants} class defines common constants, which are | ||
* used across the whole binding. | ||
* | ||
* @author Scott Hanson - Initial contribution | ||
*/ | ||
@NonNullByDefault | ||
public class TwitterBindingConstants { | ||
|
||
private static final String BINDING_ID = "twitter"; | ||
|
||
// List of all Thing Type UIDs | ||
public static final ThingTypeUID THING_TYPE_ACCOUNT = new ThingTypeUID(BINDING_ID, "account"); | ||
|
||
// List of all Channel ids | ||
public static final String CHANNEL_LASTTWEET = "lasttweet"; | ||
} |
Oops, something went wrong.