From 6576c696156bf7070e55bd71cff1718c05af7e7b Mon Sep 17 00:00:00 2001 From: RSStephens Date: Thu, 24 Sep 2015 08:31:20 -0400 Subject: [PATCH 1/2] New DSC Alarm Action Binding Incorporating DSC Alarm action into openhab. DSC Alarm Action updates. Create README.md File Fix README.md Another README.md Fix Still Another README.md Fix README.md Spelling Correction Final fixes for Actions Implimentation Minor Typo Errors Fixed PR Review Fixes Fixes made to pull request after review. --- .../org.openhab.action.dscalarm/.classpath | 8 ++ .../org.openhab.action.dscalarm/.project | 33 +++++++ .../.settings/org.eclipse.jdt.core.prefs | 85 +++++++++++++++++ .../META-INF/MANIFEST.MF | 26 ++++++ .../OSGI-INF/action.xml | 24 +++++ .../org.openhab.action.dscalarm/README.md | 87 ++++++++++++++++++ .../build.properties | 6 ++ .../org.openhab.action.dscalarm/pom.xml | 35 +++++++ .../dscalarm/internal/DSCAlarmAction.java | 76 +++++++++++++++ .../internal/DSCAlarmActionService.java | 92 +++++++++++++++++++ .../dscalarm/internal/DSCAlarmActivator.java | 53 +++++++++++ .../src/main/resources/readme.txt | 1 + bundles/action/pom.xml | 1 + .../META-INF/MANIFEST.MF | 8 +- .../OSGI-INF/activebinding.xml | 1 + .../dscalarm/DSCAlarmActionProvider.java | 14 +++ .../internal/DSCAlarmActiveBinding.java | 47 +++++++++- .../dscalarm/internal/protocol/APICode.java | 2 +- distribution/pom.xml | 6 ++ .../org.openhab.designer.feature/feature.xml | 7 ++ 20 files changed, 605 insertions(+), 7 deletions(-) create mode 100644 bundles/action/org.openhab.action.dscalarm/.classpath create mode 100644 bundles/action/org.openhab.action.dscalarm/.project create mode 100644 bundles/action/org.openhab.action.dscalarm/.settings/org.eclipse.jdt.core.prefs create mode 100644 bundles/action/org.openhab.action.dscalarm/META-INF/MANIFEST.MF create mode 100644 bundles/action/org.openhab.action.dscalarm/OSGI-INF/action.xml create mode 100644 bundles/action/org.openhab.action.dscalarm/README.md create mode 100644 bundles/action/org.openhab.action.dscalarm/build.properties create mode 100644 bundles/action/org.openhab.action.dscalarm/pom.xml create mode 100644 bundles/action/org.openhab.action.dscalarm/src/main/java/org/openhab/action/dscalarm/internal/DSCAlarmAction.java create mode 100644 bundles/action/org.openhab.action.dscalarm/src/main/java/org/openhab/action/dscalarm/internal/DSCAlarmActionService.java create mode 100644 bundles/action/org.openhab.action.dscalarm/src/main/java/org/openhab/action/dscalarm/internal/DSCAlarmActivator.java create mode 100644 bundles/action/org.openhab.action.dscalarm/src/main/resources/readme.txt create mode 100644 bundles/binding/org.openhab.binding.dscalarm/src/main/java/org/openhab/binding/dscalarm/DSCAlarmActionProvider.java diff --git a/bundles/action/org.openhab.action.dscalarm/.classpath b/bundles/action/org.openhab.action.dscalarm/.classpath new file mode 100644 index 00000000000..1fc171b1aa8 --- /dev/null +++ b/bundles/action/org.openhab.action.dscalarm/.classpath @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/bundles/action/org.openhab.action.dscalarm/.project b/bundles/action/org.openhab.action.dscalarm/.project new file mode 100644 index 00000000000..822ea5302a6 --- /dev/null +++ b/bundles/action/org.openhab.action.dscalarm/.project @@ -0,0 +1,33 @@ + + + org.openhab.action.dscalarm + This is the ${binding-name} binding of the open Home Automation Bus (openHAB) + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.pde.ManifestBuilder + + + + + org.eclipse.pde.SchemaBuilder + + + + + org.eclipse.pde.ds.core.builder + + + + + + org.eclipse.jdt.core.javanature + org.eclipse.pde.PluginNature + + diff --git a/bundles/action/org.openhab.action.dscalarm/.settings/org.eclipse.jdt.core.prefs b/bundles/action/org.openhab.action.dscalarm/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 00000000000..d7d0f21d58b --- /dev/null +++ b/bundles/action/org.openhab.action.dscalarm/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,85 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.annotation.missingNonNullByDefaultAnnotation=ignore +org.eclipse.jdt.core.compiler.annotation.nonnull=org.eclipse.jdt.annotation.NonNull +org.eclipse.jdt.core.compiler.annotation.nonnullbydefault=org.eclipse.jdt.annotation.NonNullByDefault +org.eclipse.jdt.core.compiler.annotation.nullable=org.eclipse.jdt.annotation.Nullable +org.eclipse.jdt.core.compiler.annotation.nullanalysis=disabled +org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=warning +org.eclipse.jdt.core.compiler.problem.autoboxing=ignore +org.eclipse.jdt.core.compiler.problem.comparingIdentical=warning +org.eclipse.jdt.core.compiler.problem.deadCode=warning +org.eclipse.jdt.core.compiler.problem.deprecation=warning +org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode=disabled +org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod=disabled +org.eclipse.jdt.core.compiler.problem.discouragedReference=ignore +org.eclipse.jdt.core.compiler.problem.emptyStatement=ignore +org.eclipse.jdt.core.compiler.problem.explicitlyClosedAutoCloseable=ignore +org.eclipse.jdt.core.compiler.problem.fallthroughCase=ignore +org.eclipse.jdt.core.compiler.problem.fatalOptionalError=disabled +org.eclipse.jdt.core.compiler.problem.fieldHiding=ignore +org.eclipse.jdt.core.compiler.problem.finalParameterBound=warning +org.eclipse.jdt.core.compiler.problem.finallyBlockNotCompletingNormally=warning +org.eclipse.jdt.core.compiler.problem.forbiddenReference=ignore +org.eclipse.jdt.core.compiler.problem.hiddenCatchBlock=warning +org.eclipse.jdt.core.compiler.problem.includeNullInfoFromAsserts=disabled +org.eclipse.jdt.core.compiler.problem.incompatibleNonInheritedInterfaceMethod=warning +org.eclipse.jdt.core.compiler.problem.incompleteEnumSwitch=warning +org.eclipse.jdt.core.compiler.problem.indirectStaticAccess=ignore +org.eclipse.jdt.core.compiler.problem.localVariableHiding=ignore +org.eclipse.jdt.core.compiler.problem.methodWithConstructorName=warning +org.eclipse.jdt.core.compiler.problem.missingDefaultCase=ignore +org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=ignore +org.eclipse.jdt.core.compiler.problem.missingEnumCaseDespiteDefault=disabled +org.eclipse.jdt.core.compiler.problem.missingHashCodeMethod=ignore +org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotation=ignore +org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotationForInterfaceMethodImplementation=enabled +org.eclipse.jdt.core.compiler.problem.missingSerialVersion=warning +org.eclipse.jdt.core.compiler.problem.missingSynchronizedOnInheritedMethod=ignore +org.eclipse.jdt.core.compiler.problem.noEffectAssignment=warning +org.eclipse.jdt.core.compiler.problem.noImplicitStringConversion=warning +org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral=ignore +org.eclipse.jdt.core.compiler.problem.nullAnnotationInferenceConflict=error +org.eclipse.jdt.core.compiler.problem.nullReference=warning +org.eclipse.jdt.core.compiler.problem.nullSpecViolation=error +org.eclipse.jdt.core.compiler.problem.nullUncheckedConversion=warning +org.eclipse.jdt.core.compiler.problem.overridingPackageDefaultMethod=warning +org.eclipse.jdt.core.compiler.problem.parameterAssignment=ignore +org.eclipse.jdt.core.compiler.problem.possibleAccidentalBooleanAssignment=ignore +org.eclipse.jdt.core.compiler.problem.potentialNullReference=ignore +org.eclipse.jdt.core.compiler.problem.potentiallyUnclosedCloseable=ignore +org.eclipse.jdt.core.compiler.problem.rawTypeReference=warning +org.eclipse.jdt.core.compiler.problem.redundantNullAnnotation=warning +org.eclipse.jdt.core.compiler.problem.redundantNullCheck=ignore +org.eclipse.jdt.core.compiler.problem.redundantSpecificationOfTypeArguments=ignore +org.eclipse.jdt.core.compiler.problem.redundantSuperinterface=ignore +org.eclipse.jdt.core.compiler.problem.reportMethodCanBePotentiallyStatic=ignore +org.eclipse.jdt.core.compiler.problem.reportMethodCanBeStatic=ignore +org.eclipse.jdt.core.compiler.problem.specialParameterHidingField=disabled +org.eclipse.jdt.core.compiler.problem.staticAccessReceiver=warning +org.eclipse.jdt.core.compiler.problem.suppressOptionalErrors=disabled +org.eclipse.jdt.core.compiler.problem.suppressWarnings=enabled +org.eclipse.jdt.core.compiler.problem.syntheticAccessEmulation=ignore +org.eclipse.jdt.core.compiler.problem.typeParameterHiding=warning +org.eclipse.jdt.core.compiler.problem.unavoidableGenericTypeProblems=enabled +org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=warning +org.eclipse.jdt.core.compiler.problem.unclosedCloseable=warning +org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=ignore +org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=warning +org.eclipse.jdt.core.compiler.problem.unnecessaryElse=ignore +org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=ignore +org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore +org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=ignore +org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionExemptExceptionAndThrowable=enabled +org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionIncludeDocCommentReference=enabled +org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionWhenOverriding=disabled +org.eclipse.jdt.core.compiler.problem.unusedImport=warning +org.eclipse.jdt.core.compiler.problem.unusedLabel=warning +org.eclipse.jdt.core.compiler.problem.unusedLocal=warning +org.eclipse.jdt.core.compiler.problem.unusedObjectAllocation=ignore +org.eclipse.jdt.core.compiler.problem.unusedParameter=ignore +org.eclipse.jdt.core.compiler.problem.unusedParameterIncludeDocCommentReference=enabled +org.eclipse.jdt.core.compiler.problem.unusedParameterWhenImplementingAbstract=disabled +org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disabled +org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning +org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning +org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning diff --git a/bundles/action/org.openhab.action.dscalarm/META-INF/MANIFEST.MF b/bundles/action/org.openhab.action.dscalarm/META-INF/MANIFEST.MF new file mode 100644 index 00000000000..ce10651cc92 --- /dev/null +++ b/bundles/action/org.openhab.action.dscalarm/META-INF/MANIFEST.MF @@ -0,0 +1,26 @@ +Manifest-Version: 1.0 +Private-Package: org.openhab.action.dscalarm.internal +Ignore-Package: org.openhab.action.dscalarm.internal +Bundle-License: http://www.eclipse.org/legal/epl-v10.html +Bundle-Name: openHAB DSC Alarm Action +Bundle-SymbolicName: org.openhab.action.dscalarm +Bundle-Vendor: openHAB.org +Bundle-Version: 1.8.0.qualifier +Bundle-Activator: org.openhab.action.dscalarm.internal.DSCAlarmActivator +Bundle-ManifestVersion: 2 +Bundle-Description: This is the DSC Alarm action of the open Home Automation Bus (openHAB) +Import-Package: org.openhab.core.items, + org.openhab.core.library.items, + org.openhab.core.library.types, + org.openhab.core.scriptengine.action, + org.openhab.core.types, + org.osgi.framework, + org.osgi.service.cm, + org.osgi.service.component, + org.slf4j, + org.openhab.binding.dscalarm +Bundle-DocURL: http://www.openhab.org +Bundle-RequiredExecutionEnvironment: JavaSE-1.6 +Service-Component: OSGI-INF/action.xml +Bundle-ClassPath: . +Bundle-ActivationPolicy: lazy diff --git a/bundles/action/org.openhab.action.dscalarm/OSGI-INF/action.xml b/bundles/action/org.openhab.action.dscalarm/OSGI-INF/action.xml new file mode 100644 index 00000000000..ac6abf1d223 --- /dev/null +++ b/bundles/action/org.openhab.action.dscalarm/OSGI-INF/action.xml @@ -0,0 +1,24 @@ + + + + + + + + + + + + + + + diff --git a/bundles/action/org.openhab.action.dscalarm/README.md b/bundles/action/org.openhab.action.dscalarm/README.md new file mode 100644 index 00000000000..5549954b2f3 --- /dev/null +++ b/bundles/action/org.openhab.action.dscalarm/README.md @@ -0,0 +1,87 @@ +# Documentation for the DSC Alarm Action Bundle + +## Introduction + +This bundle exposes openHAB Rule extensions to be used with the [DSC Alarm Binding](https://github.com/openhab/openhab/wiki/DSC-Alarm-Binding). + +It allows the sending of DSC Alarm specific commands from within [openHAB Rules](https://github.com/openhab/openhab/wiki/Rules): + +## Releases + +* 1.8.0 - First release + +## Configuration + +The DSC Alarm Action bundle relies on the DSC Alarm Binding being installed and configured, along with the installation of the DSC Alarm Action Bundle (JAR) file. + +## Extensions + +Currently the DSC Alarm Action Bundle supports a single rule extension with the following formats: + +* `sendDSCAlarmCommand(String command)` - sends a DSC Alarm command. +* `sendDSCAlarmCommand(String command, String data)` - same as above but with command specific required data. + +The 'command' parameter is a string numeric code. The following table shows which commands are supported: + + + + + + + + + + + + + + + + + + + + + + + + +
DSC Alarm Command CodeDescriptionDataSupported Interface
'000'PollNONEEnvisalink, IT100
'001'Status ReportNONEEnvisalink, IT100
'002'Labels RequestNONEIT100
'005'Network Login1-6 Character - [Password]Envisalink
'008'Dump Zone TimersNONEEnvisalink
'010'Set Time and DateNONEEnvisalink, IT100
'020'Command Output Control2 Characters - [Partition # (1-8)][PGM # (1-4)]Envisalink, IT100
'030'Partition Arm Control - Away1 Character - [Partition # (1-8)]Envisalink, IT100
'031'Partition Arm Control - Stay1 Character - [Partition # (1-8)]Envisalink, IT100
'032'Partition Arm Control - No Entry Delay1 Character - [Partition # (1-8)]Envisalink, IT100
'033'Partition Arm Control - With User Code5-7 Characters - [Partition # (1-8)][User Code (4-6)]Envisalink, IT100
'040'Partition Disarm Control - With User Code5-7 Characters - [Partition # (1-8)][User Code (4-6)]Envisalink, IT100
'055'Time Stamp Control1 Character - [On/Off (1,0)]Envisalink, IT100
'056'Time/Date Broadcast Control1 Character - [On/Off (1,0)]Envisalink, IT100
'057'Temperature Broadcast Control1 Character - [On/Off (1,0)]Envisalink, IT100
'058'Virtual Keypad Control1 Character - [On/Off (1,0)]IT100
'060'Trigger Panic Alarm1 Character - [1=Fire, 2=Ambulance, 3=Police]Envisalink, IT100
'070'Single Keystroke1 Character - [Single ASCII Character]Envisalink, IT100
'071'Keystroke String1-6 Characters - [1-6 ASCII Character String]Envisalink
'074'Keep Alive1 Character - [Partition # (1-8)]Envisalink
'200'Code Send4-6 Characters - [User Code (4-6)]Envisalink, IT100
+ +## Examples + +To invoke the action see the examples below: + +Add an item to your items file such as a switch: + +``` +Switch PollCommand "Send a poll command to the DSC Alarm System" +``` + +The following rule will trigger whenever the switch is turned ON: + +``` + rule "PollCommand" + when + Item PollCommand received command ON + then + sendDSCAlarmCommand("000") + end +``` + +Again add an item to your items file: + +``` +Switch BypassZone1 "Bypass Zone 1" +``` + +This rule triggers when the switch is turned ON: + +``` + rule "BypassZone1" + when + Item BypassZone1 received command ON + then + sendDSCAlarmCommand("071","*101#") + end +``` diff --git a/bundles/action/org.openhab.action.dscalarm/build.properties b/bundles/action/org.openhab.action.dscalarm/build.properties new file mode 100644 index 00000000000..30f33af0ad2 --- /dev/null +++ b/bundles/action/org.openhab.action.dscalarm/build.properties @@ -0,0 +1,6 @@ +source.. = src/main/java/,\ + src/main/resources/ +bin.includes = META-INF/,\ + .,\ + OSGI-INF/ +output.. = target/classes/ diff --git a/bundles/action/org.openhab.action.dscalarm/pom.xml b/bundles/action/org.openhab.action.dscalarm/pom.xml new file mode 100644 index 00000000000..efbb578c21c --- /dev/null +++ b/bundles/action/org.openhab.action.dscalarm/pom.xml @@ -0,0 +1,35 @@ + + + + + org.openhab.bundles + action + 1.8.0-SNAPSHOT + + + + org.openhab.action.dscalarm + org.openhab.action.dscalarm + openhab-addon-action-dscalarm + ${project.name} + + + 4.0.0 + org.openhab.action + org.openhab.action.dscalarm + + openHAB DSC Alarm Action + + eclipse-plugin + + + + + org.vafer + jdeb + + + + + diff --git a/bundles/action/org.openhab.action.dscalarm/src/main/java/org/openhab/action/dscalarm/internal/DSCAlarmAction.java b/bundles/action/org.openhab.action.dscalarm/src/main/java/org/openhab/action/dscalarm/internal/DSCAlarmAction.java new file mode 100644 index 00000000000..29817137cd0 --- /dev/null +++ b/bundles/action/org.openhab.action.dscalarm/src/main/java/org/openhab/action/dscalarm/internal/DSCAlarmAction.java @@ -0,0 +1,76 @@ +/** + * Copyright (c) 2010-2015, openHAB.org and others. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + */ +package org.openhab.action.dscalarm.internal; + +import org.openhab.binding.dscalarm.DSCAlarmActionProvider; +import org.openhab.core.scriptengine.action.ActionDoc; +import org.openhab.core.scriptengine.action.ParamDoc; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * This class provides static methods, for the DSC Alarm, that can be used in automation rules. + * + * @author Russell Stephens + * @since 1.8.0 + */ +public class DSCAlarmAction { + private static Logger logger = LoggerFactory.getLogger(DSCAlarmAction.class); + + /** + * Sends a string that is equivalent to a key sequence on an existing keypad. + */ + @ActionDoc(text = "Sends a DSC Alarm command that required no extra data.") + public static boolean sendDSCAlarmCommand( + @ParamDoc(name = "command", text = "The command to be sent to the DSC Alarm.") String command ) { + + return sendDSCAlarmCommandInternal(command, ""); + } + + @ActionDoc(text = "Sends a DSC Alarm command along with required data.") + public static boolean sendDSCAlarmCommand( + @ParamDoc(name = "command", text = "The command to be sent to the DSC Alarm.") String command, + @ParamDoc(name = "data", text = "The data string for the command.") String data) { + + return sendDSCAlarmCommandInternal(command, data); + } + + private static DSCAlarmActionProvider getDSCAlarmActionProvider() throws Exception { + DSCAlarmActionService actionService = DSCAlarmActionService.getDSCAlarmActionService(); + + if (actionService == null) { + throw new Exception(String.format("DSC Alarm Action Service is not configured!")); + } + + DSCAlarmActionProvider actionProvider = actionService.getDSCAlarmActionProvider(); + + if (actionProvider == null) { + throw new Exception(String.format("DSC Alarm Action Service is not configured!")); + } + + return actionProvider; + } + + private static boolean sendDSCAlarmCommandInternal(String command, String data) { + + try { + logger.debug("sendDSCAlarmCommandInternal(): Sending DSC Alarm command!"); + + DSCAlarmActionProvider actionProvider = getDSCAlarmActionProvider(); + + return actionProvider.sendDSCAlarmCommand(command, data); + + } catch (Exception e) { + logger.error("sendDSCAlarmCommandInternal(): Error Sending DSC Alarm Command: {}", e); + } + + return false; + } +} + diff --git a/bundles/action/org.openhab.action.dscalarm/src/main/java/org/openhab/action/dscalarm/internal/DSCAlarmActionService.java b/bundles/action/org.openhab.action.dscalarm/src/main/java/org/openhab/action/dscalarm/internal/DSCAlarmActionService.java new file mode 100644 index 00000000000..187a9c118d2 --- /dev/null +++ b/bundles/action/org.openhab.action.dscalarm/src/main/java/org/openhab/action/dscalarm/internal/DSCAlarmActionService.java @@ -0,0 +1,92 @@ +/** + * Copyright (c) 2010-2015, openHAB.org and others. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + */ +package org.openhab.action.dscalarm.internal; + +import java.util.Dictionary; + +import org.openhab.binding.dscalarm.DSCAlarmActionProvider; +import org.openhab.core.scriptengine.action.ActionService; +import org.osgi.service.cm.ConfigurationException; +import org.osgi.service.cm.ManagedService; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * This class registers an OSGi service for the DSC Alarm action. + * + * @author Russell Stephens + * @since 1.8.0 + */ +public class DSCAlarmActionService implements ActionService, ManagedService { + + private static Logger logger = LoggerFactory.getLogger(DSCAlarmActionService.class); + + private DSCAlarmActionProvider actionProvider = null; + private static DSCAlarmActionService actionService = null; + + public DSCAlarmActionService() { + } + + public void activate() { + logger.debug("DSC Alarm Action Service Activated!"); + actionService = this; + } + + public void deactivate() { + logger.debug("DSC Alarm Action Service Deactivated!"); + actionService = null; + } + + @Override + public String getActionClassName() { + return getActionClass().getCanonicalName(); + } + + @Override + public Class getActionClass() { + return DSCAlarmAction.class; + } + + @Override + public void updated(Dictionary properties) throws ConfigurationException { + } + + public static DSCAlarmActionService getDSCAlarmActionService() { + return actionService; + } + + /** + * Sets the DSC Alarm Action Provider for use by OSGi injection. + * + * @param actionProvider the DSC Alarm Action Provider (provided by the DSC Alarm Binding). + */ + public void setDSCAlarmActionProvider(DSCAlarmActionProvider actionProvider) { + this.actionProvider = actionProvider; + logger.trace("setDSCAlarmActionProvider(): DSC Alarm Action Provider Set!"); + } + + /** + * Resets the DSC Alarm Action Provider to null. + * + */ + public void resetDSCAlarmActionProvider() { + this.setDSCAlarmActionProvider(null); + logger.trace("resetDSCAlarmActionProvider(): DSC Alarm Action Provider Reset!"); + } + + /** + * Get the DSC Alarm Action Provider instance injected by OSGi. + * + * @return the DSC Alarm Action Provider associated with this Action Service. + */ + public DSCAlarmActionProvider getDSCAlarmActionProvider() { + return this.actionProvider; + } + +} diff --git a/bundles/action/org.openhab.action.dscalarm/src/main/java/org/openhab/action/dscalarm/internal/DSCAlarmActivator.java b/bundles/action/org.openhab.action.dscalarm/src/main/java/org/openhab/action/dscalarm/internal/DSCAlarmActivator.java new file mode 100644 index 00000000000..6c8f7b4e367 --- /dev/null +++ b/bundles/action/org.openhab.action.dscalarm/src/main/java/org/openhab/action/dscalarm/internal/DSCAlarmActivator.java @@ -0,0 +1,53 @@ +/** + * Copyright (c) 2010-2015, openHAB.org and others. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + */ +package org.openhab.action.dscalarm.internal; + +import org.osgi.framework.BundleActivator; +import org.osgi.framework.BundleContext; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * Extension of the default OSGi bundle activator + * + * @author Russell Stephens + * @since 1.8.0 + */ +public final class DSCAlarmActivator implements BundleActivator { + + private static Logger logger = LoggerFactory.getLogger(DSCAlarmActivator.class); + + private static BundleContext context; + + /** + * Called whenever the OSGi framework starts our bundle + */ + public void start(BundleContext bc) throws Exception { + context = bc; + logger.debug("DSC Alarm action has been started."); + } + + /** + * Called whenever the OSGi framework stops our bundle + */ + public void stop(BundleContext bc) throws Exception { + context = null; + logger.debug("DSC Alarm action has been stopped."); + } + + /** + * Returns the bundle context of this bundle + * + * @return the bundle context + */ + public static BundleContext getContext() { + return context; + } + +} diff --git a/bundles/action/org.openhab.action.dscalarm/src/main/resources/readme.txt b/bundles/action/org.openhab.action.dscalarm/src/main/resources/readme.txt new file mode 100644 index 00000000000..98698c670dc --- /dev/null +++ b/bundles/action/org.openhab.action.dscalarm/src/main/resources/readme.txt @@ -0,0 +1 @@ +Bundle resources go in here! \ No newline at end of file diff --git a/bundles/action/pom.xml b/bundles/action/pom.xml index 6c7fb256c15..eb0210de137 100644 --- a/bundles/action/pom.xml +++ b/bundles/action/pom.xml @@ -34,6 +34,7 @@ org.openhab.action.harmonyhub org.openhab.action.ecobee org.openhab.action.mqtt + org.openhab.action.dscalarm diff --git a/bundles/binding/org.openhab.binding.dscalarm/META-INF/MANIFEST.MF b/bundles/binding/org.openhab.binding.dscalarm/META-INF/MANIFEST.MF index 7e23e4af668..532e462167d 100644 --- a/bundles/binding/org.openhab.binding.dscalarm/META-INF/MANIFEST.MF +++ b/bundles/binding/org.openhab.binding.dscalarm/META-INF/MANIFEST.MF @@ -4,12 +4,12 @@ Bundle-SymbolicName: org.openhab.binding.dscalarm Bundle-Version: 1.8.0.qualifier Bundle-Activator: org.openhab.binding.dscalarm.internal.DSCAlarmActivator Bundle-Vendor: openHAB.org -Bundle-RequiredExecutionEnvironment: J2SE-1.5 +Bundle-RequiredExecutionEnvironment: JavaSE-1.6 Bundle-ManifestVersion: 2 Bundle-License: http://www.eclipse.org/legal/epl-v10.html Bundle-Description: This is the DSC Alarm binding of the open Home Automation Bus (openHAB) Import-Package: gnu.io, - org.apache.commons.io;version="2.0.1", + org.apache.commons.io, org.apache.commons.lang, org.eclipse.emf.common.util, org.eclipse.emf.ecore, @@ -30,7 +30,9 @@ Import-Package: gnu.io, org.slf4j Service-Component: OSGI-INF/activebinding.xml, OSGI-INF/genericbindingprovider.xml Bundle-ClassPath: . -Export-Package: org.openhab.binding.dscalarm +Export-Package: org.openhab.binding.dscalarm, + org.openhab.binding.dscalarm.internal +Bundle-ActivationPolicy: lazy diff --git a/bundles/binding/org.openhab.binding.dscalarm/OSGI-INF/activebinding.xml b/bundles/binding/org.openhab.binding.dscalarm/OSGI-INF/activebinding.xml index 20748a5ca81..2cf274e1976 100644 --- a/bundles/binding/org.openhab.binding.dscalarm/OSGI-INF/activebinding.xml +++ b/bundles/binding/org.openhab.binding.dscalarm/OSGI-INF/activebinding.xml @@ -15,6 +15,7 @@ + diff --git a/bundles/binding/org.openhab.binding.dscalarm/src/main/java/org/openhab/binding/dscalarm/DSCAlarmActionProvider.java b/bundles/binding/org.openhab.binding.dscalarm/src/main/java/org/openhab/binding/dscalarm/DSCAlarmActionProvider.java new file mode 100644 index 00000000000..1804b5fdbb2 --- /dev/null +++ b/bundles/binding/org.openhab.binding.dscalarm/src/main/java/org/openhab/binding/dscalarm/DSCAlarmActionProvider.java @@ -0,0 +1,14 @@ +package org.openhab.binding.dscalarm; + +public interface DSCAlarmActionProvider { + + /** + * Sends a DSC Alarm command + * @param command + * @param data TODO + * + * @return + */ + public boolean sendDSCAlarmCommand(String command, String data); + +} diff --git a/bundles/binding/org.openhab.binding.dscalarm/src/main/java/org/openhab/binding/dscalarm/internal/DSCAlarmActiveBinding.java b/bundles/binding/org.openhab.binding.dscalarm/src/main/java/org/openhab/binding/dscalarm/internal/DSCAlarmActiveBinding.java index a76b973e942..38743d86e6f 100644 --- a/bundles/binding/org.openhab.binding.dscalarm/src/main/java/org/openhab/binding/dscalarm/internal/DSCAlarmActiveBinding.java +++ b/bundles/binding/org.openhab.binding.dscalarm/src/main/java/org/openhab/binding/dscalarm/internal/DSCAlarmActiveBinding.java @@ -15,6 +15,7 @@ import java.util.Map; import org.apache.commons.lang.StringUtils; +import org.openhab.binding.dscalarm.DSCAlarmActionProvider; import org.openhab.binding.dscalarm.DSCAlarmBindingConfig; import org.openhab.binding.dscalarm.DSCAlarmBindingProvider; import org.openhab.binding.dscalarm.internal.connector.DSCAlarmConnectorType; @@ -42,7 +43,7 @@ * @since 1.6.0 */ -public class DSCAlarmActiveBinding extends AbstractActiveBinding implements ManagedService, DSCAlarmEventListener { +public class DSCAlarmActiveBinding extends AbstractActiveBinding implements ManagedService, DSCAlarmEventListener, DSCAlarmActionProvider { private static final Logger logger = LoggerFactory.getLogger(DSCAlarmActiveBinding.class); @@ -100,14 +101,14 @@ public class DSCAlarmActiveBinding extends AbstractActiveBinding${project.version} jar + + org.openhab.action + org.openhab.action.dscalarm + ${project.version} + jar + org.openhab.binding diff --git a/features/org.openhab.designer.feature/feature.xml b/features/org.openhab.designer.feature/feature.xml index 04573ab2537..8ee1ab8e5e9 100644 --- a/features/org.openhab.designer.feature/feature.xml +++ b/features/org.openhab.designer.feature/feature.xml @@ -488,4 +488,11 @@ version="0.0.0" unpack="false"/> + + From a5d9f22f4a3361dfbea8a6c87dba3139cbe76dbe Mon Sep 17 00:00:00 2001 From: Russell Stephens Date: Sun, 11 Oct 2015 09:43:17 -0400 Subject: [PATCH 2/2] Some more PR Review Changes --- bundles/action/org.openhab.action.dscalarm/.project | 2 +- .../binding/org.openhab.binding.dscalarm/META-INF/MANIFEST.MF | 3 +-- targetplatform/openHAB Designer (Mac).launch | 2 +- 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/bundles/action/org.openhab.action.dscalarm/.project b/bundles/action/org.openhab.action.dscalarm/.project index 822ea5302a6..30c4eb023c5 100644 --- a/bundles/action/org.openhab.action.dscalarm/.project +++ b/bundles/action/org.openhab.action.dscalarm/.project @@ -1,7 +1,7 @@ org.openhab.action.dscalarm - This is the ${binding-name} binding of the open Home Automation Bus (openHAB) + This is the ${binding-name} action bundle of the open Home Automation Bus (openHAB) diff --git a/bundles/binding/org.openhab.binding.dscalarm/META-INF/MANIFEST.MF b/bundles/binding/org.openhab.binding.dscalarm/META-INF/MANIFEST.MF index 532e462167d..30e950be5ab 100644 --- a/bundles/binding/org.openhab.binding.dscalarm/META-INF/MANIFEST.MF +++ b/bundles/binding/org.openhab.binding.dscalarm/META-INF/MANIFEST.MF @@ -30,8 +30,7 @@ Import-Package: gnu.io, org.slf4j Service-Component: OSGI-INF/activebinding.xml, OSGI-INF/genericbindingprovider.xml Bundle-ClassPath: . -Export-Package: org.openhab.binding.dscalarm, - org.openhab.binding.dscalarm.internal +Export-Package: org.openhab.binding.dscalarm Bundle-ActivationPolicy: lazy diff --git a/targetplatform/openHAB Designer (Mac).launch b/targetplatform/openHAB Designer (Mac).launch index 35f3854bf3e..06f8ba1c1d5 100644 --- a/targetplatform/openHAB Designer (Mac).launch +++ b/targetplatform/openHAB Designer (Mac).launch @@ -22,7 +22,7 @@ - +