-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Feature: Cisco Spark action *new* (#5090) #5092
Conversation
* Supports messages to room and person * Optional default room config * Basic input validation Signed-off-by: Tom Deckers <tom@ducbase.com> Closes openhab#5090
1f508cc to
8b932dd
Compare
9037568
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In addition to the inline comments, please also create a wiki page for the new action and link it into the Actions wiki page.
|
|
||
| ### Configure openhab | ||
|
|
||
| Configure openhab with the access token by adding the following to the file `services/ciscospark.cfg`: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
openHAB in text for human use should always be presented as in line 4, as "openHAB".
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I also believe this configuration instruction is incorrect for OH1. The text should not reference specific files.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@9037568 : The README.md is not concerned with OH1 runtime users, and should reference the .cfg file used in openHAB 2. If there is an expectation that this action will be used by OH1 runtime users (and why not), the body of README.md can be copied to a wiki page and adjustments can be made for OH1 users. Or, OH1 runtime users can just figure it out.
| bin.includes = META-INF/,\ | ||
| .,\ | ||
| OSGI-INF/,\ | ||
| lib/ciscospark-client-1.0-SNAPSHOT.jar,\ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What licence is used for this?
MIT, yes? I don't think that's a problem. Perhaps @watou can confirm?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
MIT license is OK. It's good practice to add an about.html file explaining use of third-party content (like this), but much of this repo didn't.
|
|
||
| // Validate message | ||
| if (msgTxt == null || "".equals(msgTxt)) { | ||
| logger.error("Message can't be empty"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be a WARN or lower. (see the guidelines)
Please review other logging messages and update them accordingly.
| CiscoSpark.spark = createSpark(); | ||
| logger.debug("Retrieving user..."); | ||
| Person person = CiscoSpark.spark.people().path("/me").get(); | ||
| logger.info("Cisco Spark logged in as " + person.getDisplayName()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should use parameterized logging instead of string concatenation.
| public void updated(Dictionary<String, ?> config) throws ConfigurationException { | ||
| if (config != null) { | ||
|
|
||
| String accessTokenString = (String) config.get("accessToken"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For compatibility with OH2, should use Objects.toString instead. eg.
... = Objects.toString(config.get("accessToken"), null);
| */ | ||
| public class CiscoSpark { | ||
|
|
||
| private static final Logger logger = LoggerFactory.getLogger(CiscoSpark.class); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Logger should not be static.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@9037568 Loggers in nearly all other OH1 add-ons are static, so I think it's OK for this to be as well. If it ever comes time to run through this repo and change all loggers to non-static, it's the difference between changing 1,000 and 1,001 cases. Code in openhab2-addons, by contrast, started out using non-static loggers so it's required in that repo.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Left this one static for now. Couldn't easily change the action methods to non-static. I used the Twitter action as example and didn't find an example with non-static action methods.
| @@ -0,0 +1,129 @@ | |||
| /** | |||
| * Copyright (c) 2010-2016 by the respective copyright holders. | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
2017
| */ | ||
| public class CiscoSparkActionService implements ActionService, ManagedService { | ||
|
|
||
| private static final Logger logger = LoggerFactory.getLogger(CiscoSparkActionService.class); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Logger should not be static.
| @@ -0,0 +1,55 @@ | |||
| /** | |||
| * Copyright (c) 2010-2016 by the respective copyright holders. | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
2017
| */ | ||
| public final class CiscoSparkActivator implements BundleActivator { | ||
|
|
||
| private static Logger logger = LoggerFactory.getLogger(CiscoSparkActivator.class); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Logger should not be static.
|
Updated PR... I'll add the wiki page shortly. |
| <nature>org.eclipse.jdt.core.javanature</nature> | ||
| <nature>org.eclipse.pde.PluginNature</nature> | ||
| </natures> | ||
| </projectDescription> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove maven2Builder and maven2Nature.
e5c382d to
0e4de24
Compare
| http://www.eclipse.org/legal/epl-v10.html | ||
| --> | ||
| <scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0" activate="activate" configuration-policy="require" deactivate="deactivate" immediate="true" name="org.openhab.action.ciscospark.action"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I do not know if specifying configuration-policy without also specifying configuration-pid works. I think (but am not sure) that the absence of configuration-pid causes it to default to the value of the name attribute, which in this case is incorrect. configuration-pid should be the same as the value of the service-pid property. Together, configuration-policy="require" and configuration-pid="org.openhab.ciscospark" should mean that the component is only activated if there is a configuration under the persistence ID org.openhab.ciscospark.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure what this means... Admittedly, I'm no osgi/karaf expert. I've been digging into the docs here, but am not seeing any reference to an actual configuration.pid property. The text mentions the configuration pid, but appears to refer to service.pid as the actual property.
I'm testing this by manually adding this plugin to the addon directory and the plugin does get loaded and is functional.
If there are changes needed, can give me few pointers/examples of how to proceed? Thanks for the feedback so far!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was referring to a file like this one, but since your testing shows that the service.pid property is working with the "require" configuration policy, then I would say that no change is needed.
|
|
||
| if (isBlank(accessToken)) { | ||
| throw new ConfigurationException("ciscospark", | ||
| "The parameters 'accessToken' is missing! Please refer to your config file."); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
parameter
| @@ -1,5 +1,4 @@ | |||
| source.. = src/main/java/,\ | |||
| src/main/resources/ | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
src/main/resources isn't empty, so this entry should be restored
0e4de24 to
ca8b832
Compare
|
Wiki page created: https://github.com/openhab/openhab1-addons/wiki/Cisco-Spark-Action |
ca8b832 to
59b15d2
Compare
|
|
||
| ## Introduction | ||
|
|
||
| [Cisco Spark](https://www.ciscospark.com) is a simple and secure way for collaborating with individuals and groups across the cloud. This Action plugin allows you to send messages to _rooms_ and individuals when certain events take place in openHAB. Messages in the Cisco Spark plugin support Markdown text. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please remove lines 3-7 inclusive. This file is processed to appear on docs.openhab.org so a particular set of conventions are expected.
| * This class registers an OSGi service for the Cisco Spark action. | ||
| * | ||
| * @author Tom Deckers | ||
| * @since 1.9.0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
1.10.0
| * Extension of the default OSGi bundle activator | ||
| * | ||
| * @author Tom Deckers | ||
| * @since 1.9.0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
1.10.0
| * sending Messages via Cisco Spark. | ||
| * | ||
| * @author Tom Deckers | ||
| * @since 1.9.0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
1.10.0
|
Change occurrences
Since it's a working add-on at this point and soon to be in a nightly build, I think it's OK to add the action to the proper place in the sidebar and linked properly in the Actions wiki page. For all OH2 users, however, the wiki should not matter for add-ons. |
* Changed to non-static logger where possible, error -> warn * Changed year * Added about and detail license for dependency * Remove maven nature from project
59b15d2 to
3fc0ece
Compare
|
I've made all updates as requested. I only backtracked on the settings for: With the current version of the code in this PR the plugin loads properly. |
|
LGTM |
Adding new action for Cisco Spark.
Signed-off-by: Tom Deckers tom@ducbase.com
Closes #5090