Skip to content

Commit

Permalink
Merge remote-tracking branch 'central/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
Nebula83 committed Jun 7, 2017
2 parents cc0ba30 + 7b76fc6 commit 832bac1
Show file tree
Hide file tree
Showing 29 changed files with 1,242 additions and 50 deletions.
39 changes: 39 additions & 0 deletions ISSUE_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<!-- Provide a general summary of the issue in the *Title* above -->
<!-- If the issue is related to a binding, please include its short name in -->
<!-- square brackets in the title - Example: "[astro] My issue..." -->

<!-- Important: Please contact the openHAB community forum for questions or -->
<!-- for configuration and usage guidance: https://community.openhab.org -->

<!-- Feel free to delete any comment lines in the template (starting with "<!--") -->

## Expected Behavior
<!-- If you're describing a bug, tell us what should happen -->
<!-- If you're suggesting a change/improvement, tell us how it should work -->

## Current Behavior
<!-- If describing a bug, tell us what happens instead of the expected behavior -->
<!-- Include related log information (preferably debug level) and related configs. -->
<!-- Use file attachment for log and config information longer than a few lines -->
<!-- If suggesting a change/improvement, explain the difference from current behavior -->
<!-- For improvements, discuss at community.openhab.org first and include link to topic -->

## Possible Solution
<!-- Not obligatory, but suggest a fix/reason for the bug, -->
<!-- or ideas how to implement the addition or change -->

## Steps to Reproduce (for Bugs)
<!-- Provide a link to a live example, or an unambiguous set of steps to -->
<!-- reproduce this bug. Include code to reproduce, if relevant -->
1.
2.

## Context
<!-- How has this issue affected you? What are you trying to accomplish? -->
<!-- Providing context helps us come up with a solution that is most useful in the real world -->

## Your Environment
<!-- Include as many relevant details about the environment you experienced the bug in -->
* Version used: (e.g., openhab and addon versions)
* Environment name and version (e.g. Chrome 39, node.js 5.4, Java 8, ...):
* Operating System and version (desktop or mobile, Windows 10, Raspbian Jessie, ...):
38 changes: 38 additions & 0 deletions PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<!-- Thanks for contributing to the openHAB project! -->
<!-- Please describe the goal and effect of your PR here. -->
<!-- Pay attention to the below notes and to *the guidelines* for this repository. -->
<!-- Feel free to delete any comment lines in the template (starting with "<!--"). -->

<!-- TITLE -->

<!-- Please provide a PR summary in the *Title* above, according to the following schema: -->
<!-- - If related to one specific addon: Mention the addon shortname in square brackets -->
<!-- e.g. "[exec]", "[netatmo]" or "[tesla]" -->
<!-- - If the PR is work in progress: Add "[WIP]" -->
<!-- - Give a short meaningful description in imperative mood -->
<!-- e.g. "Add support for device XYZ" or "Fix wrongly handled exception" -->
<!-- for a new add-on/binding: "Initial contribution" -->
<!-- Examples: -->
<!-- - "[homematic] Improve communication with weak signal devices" -->
<!-- - "[timemachine][WIP] Initial contribution" -->
<!-- - "Update contribution guidelines on new signing rules" -->

<!-- DESCRIPTION -->

<!-- Please give a few sentences describing the overall goals of the pull request. -->
<!-- Give enough details to make the improvement and changes of the PR understandable -->
<!-- to both developers and tech-savy users. -->

<!-- Please keep the following in mind: -->
<!-- - What is the classification of the PR, e.g. Bugfix, Improvement, Novel Addition, ... ? -->
<!-- - Did you describe the PRs motivation and goal? -->
<!-- - Did you provide a link to any prior discussion, e.g. an issue or community forum thread? -->
<!-- - Did you describe new features for the end user? -->
<!-- - Did you describe any noteworthy changes in usage for the end user? -->
<!-- - Was the documentation updated accordingly, e.g. the addon README? -->
<!-- - Does your contribution follow the coding guidelines: -->
<!-- http://docs.openhab.org/developers/development/guidelines.html -->
<!-- - Did you check for any (relevant) issues from the static code analysis: -->
<!-- http://docs.openhab.org/developers/development/bindings.html#static-code-analysis -->
<!-- - Did you sign-off your work: -->
<!-- http://docs.openhab.org/developers/contributing/contributing#sign-your-work -->
20 changes: 10 additions & 10 deletions addons/binding/org.openhab.binding.feed/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,16 +32,16 @@ No binding configuration required.

The binding supports following channels

| Channel Type ID | Item Type | Description |
|------------------|------------------------|--------------|----------------- |------------- |
| latest-title | String | Contains the title of the last feed entry. |
| latest-description | String | Contains the description of last feed entry. |
| latest-date | DateTime | Contains the published date of the last feed entry. |
| author | String | The name of the feed author, if author is present |
| title | String | The title of the feed |
| description | String | Description of the feed |
| last-update | DateTime | The last update date of the feed |
| number-of-entries | Number | Number of entries in the feed |
| Channel Type ID | Item Type | Description |
|--------------------|-----------|-----------------------------------------------------|
| latest-title | String | Contains the title of the last feed entry. |
| latest-description | String | Contains the description of last feed entry. |
| latest-date | DateTime | Contains the published date of the last feed entry. |
| author | String | The name of the feed author, if author is present |
| title | String | The title of the feed |
| description | String | Description of the feed |
| last-update | DateTime | The last update date of the feed |
| number-of-entries | Number | Number of entries in the feed |

## Full Example

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ public void setPower(boolean on, MilightThingState state) {
sendQueue.queueRepeatable(uidc(CAT_POWER_SET), new byte[] { command_on[zone], 0x00, 0x55 });
} else {
sendQueue.queueRepeatable(uidc(CAT_POWER_SET), new byte[] { command_off[zone], 0x00, 0x55 });
state.brightness = 0;
}
}

Expand Down Expand Up @@ -104,17 +105,17 @@ public void changeColorTemperature(int color_temp_relative, MilightThingState st
state.colorTemperature = Math.min(100, Math.max(state.colorTemperature + color_temp_relative, 0));
final byte c_on[] = { command_on[zone], 0x00, 0x55 };
final byte c_temp[] = { (byte) (color_temp_relative > 0 ? 0x3E : 0x3F), 0x00, 0x55 };
sendQueue.queue(QueueItem.createRepeatable(uidc(CAT_COLOR_SET), c_on).addNonRepeatable(c_temp));
sendQueue.queue(QueueItem.createRepeatable(c_on).addNonRepeatable(c_temp));
}

// This just emulates an absolute brightness command with the relative commands.
@Override
public void setBrightness(int value, MilightThingState state) {
if (value <= 0) {
sendQueue.queueRepeatable(uidc(CAT_POWER_SET), new byte[] { command_off[zone], 0x00, 0x55 });
setPower(false, state);
return;
} else if (value >= 100) {
sendQueue.queueRepeatable(uidc(CAT_BRIGHTNESS_SET), new byte[] { command_full[zone], 0x00, 0x55 });
setFull(zone, state);
return;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,7 @@ public class Parser {
private static final Logger logger = LoggerFactory.getLogger(Parser.class);

private static final Pattern pattern = Pattern.compile("^\\s+([a-z\\s._]+)[:=]\\s*<?\"?([^>\"]+)\"?>?$");
private static final Pattern volumePattern = Pattern.compile(
"^(0|front-left):( *[0-9]+ \\/)? *([0-9]+)% *\\/? *([0-9\\-, dB]+)?(1|front-right):( *[0-9]+ \\/)? *([0-9]+)% *\\/? *([0-9\\-, dB]+)?$");
private static final Pattern volumePattern = Pattern.compile("^([\\w\\-]+):( *[\\d]+ \\/)? *([\\d]+)% *\\/? *([\\d\\-., dB]+)?$");
private static final Pattern fallBackPattern = Pattern
.compile("^([0-9]+)([a-z\\s._]+)[:=]\\s*<?\"?([^>\"]+)\"?>?$");
private static final Pattern numberValuePattern = Pattern.compile("^([0-9]+).*$");
Expand Down Expand Up @@ -265,7 +264,7 @@ public static List<Source> parseSources(String raw, PulseaudioClient client) {
source.setVolume(Integer.valueOf(parseVolume(properties.get("volume"))));
}
if (properties.containsKey("monitor_of")) {
source.setMonitorOf(client.getSink(Integer.valueOf(parseVolume(properties.get("monitor_of")))));
source.setMonitorOf(client.getSink(Integer.valueOf(properties.get("monitor_of"))));
}
sources.add(source);
}
Expand Down Expand Up @@ -341,9 +340,19 @@ public static List<SourceOutput> parseSourceOutputs(String raw, PulseaudioClient
* @return
*/
private static int parseVolume(String vol) {
Matcher matcher = volumePattern.matcher(vol);
if (matcher.find()) {
return Math.round((Integer.valueOf(matcher.group(3)) + Integer.valueOf(matcher.group(7))) / 2);
int volumeTotal = 0;
int nChannels = 0;
for (String channel : vol.split(", ")) {
Matcher matcher = volumePattern.matcher(channel.trim());
if (matcher.find()) {
volumeTotal += Integer.valueOf(matcher.group(3));
nChannels++;
} else {
logger.debug("Unable to parse channel volume '{}'", channel);
}
}
if (nChannels > 0) {
return Math.round(volumeTotal / nChannels);
}
return 0;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,40 @@
*/
package org.openhab.binding.rfxcom.internal.messages;

import static org.junit.Assert.assertArrayEquals;
import static org.openhab.binding.rfxcom.internal.messages.RFXComBaseMessage.PacketType.HOME_CONFORT;

import javax.xml.bind.DatatypeConverter;

import org.junit.Test;
import org.openhab.binding.rfxcom.internal.exceptions.RFXComMessageNotImplementedException;

import org.openhab.binding.rfxcom.internal.exceptions.RFXComException;
import org.openhab.binding.rfxcom.internal.messages.RFXComHomeConfortMessage;
import org.openhab.binding.rfxcom.internal.messages.RFXComHomeConfortMessage.SubType;
import org.openhab.binding.rfxcom.internal.messages.RFXComHomeConfortMessage.Commands;


/**
* Test for RFXCom-binding
*
* @author Martin van Wingerden
* @author Martin van Wingerden - Initial contribution of empty test
* @author Mike Jagdis - added message handling and real test
* @since 2.0.0
*/
public class RFXComHomeConfortTest {
@Test(expected = RFXComMessageNotImplementedException.class)
public void checkNotImplemented() throws Exception {
RFXComMessageFactory.createMessage(HOME_CONFORT);
private void testMessage(SubType subType, Commands command, String deviceId, String data)
throws RFXComException {

RFXComHomeConfortMessage message = (RFXComHomeConfortMessage) RFXComMessageFactory.createMessage(HOME_CONFORT);
message.setSubType(subType);
message.command = command;
message.setDeviceId(deviceId);

assertArrayEquals(DatatypeConverter.parseHexBinary(data), message.decodeMessage());
}

@Test
public void testMessage1() throws RFXComException {
testMessage(SubType.TEL_010, Commands.GROUP_ON, "1118739.A.4", "0C1B0000111213410403000000");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,38 @@
*/
package org.openhab.binding.rfxcom.internal.messages;

import static org.junit.Assert.assertEquals;
import static org.openhab.binding.rfxcom.internal.messages.RFXComBaseMessage.PacketType.SECURITY2;
import static org.openhab.binding.rfxcom.internal.messages.RFXComSecurity2Message.SubType;

import javax.xml.bind.DatatypeConverter;

import org.junit.Test;
import org.openhab.binding.rfxcom.internal.exceptions.RFXComMessageNotImplementedException;
import org.openhab.binding.rfxcom.internal.exceptions.RFXComException;

/**
* Test for RFXCom-binding
*
* @author Martin van Wingerden
* @author Martin van Wingerden - Initial contribution of empty test
* @author Mike Jagdis - added message handling and real test
* @since 2.0.0
*/
public class RFXComSecurity2MessageTest {
@Test(expected = RFXComMessageNotImplementedException.class)
public void checkNotImplemented() throws Exception {
RFXComMessageFactory.createMessage(SECURITY2);

@Test
public void testSomeMessages() throws RFXComException {
String hexMessage = "1C21020000000000131211C30000000000000000000000000000000045";
byte[] message = DatatypeConverter.parseHexBinary(hexMessage);

RFXComSecurity2Message msg = (RFXComSecurity2Message) RFXComMessageFactory.createMessage(message);
assertEquals("SubType", SubType.RAW_AES_KEELOQ, msg.subType);
assertEquals("Seq Number", 0, msg.seqNbr);
assertEquals("Sensor Id", "51450387", msg.getDeviceId());
assertEquals("Button Status", 12, msg.buttonStatus);
assertEquals("Battery Level", 4, msg.batteryLevel);
assertEquals("Signal Level", 5, msg.signalLevel);

byte[] decoded = msg.decodeMessage();
assertEquals("Message converted back", hexMessage, DatatypeConverter.printHexBinary(decoded));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,63 @@
*/
package org.openhab.binding.rfxcom.internal.messages;

import static org.junit.Assert.assertEquals;

import javax.xml.bind.DatatypeConverter;
import org.junit.Test;
import org.openhab.binding.rfxcom.internal.exceptions.RFXComMessageNotImplementedException;

import org.openhab.binding.rfxcom.internal.exceptions.RFXComException;
import org.openhab.binding.rfxcom.internal.messages.RFXComBaseMessage.PacketType;

/**
* Test for RFXCom-binding
*
* @author Martin van Wingerden
* @author Mike Jagdis
* @since 1.9.0
*/
public class RFXComUVMessageTest {
@Test(expected = RFXComMessageNotImplementedException.class)
public void checkNotImplemented() throws Exception {
// TODO Note that this message is supported in the 1.9 binding
RFXComMessageFactory.createMessage(PacketType.UV);
@Test
public void testMessage1() throws RFXComException {
String hexMessage = "095703123421194731E9";

byte[] message = DatatypeConverter.parseHexBinary(hexMessage);
RFXComUVMessage msg = (RFXComUVMessage) RFXComMessageFactory.createMessage(message);

assertEquals("SubType", RFXComUVMessage.SubType.UV3, msg.subType);
assertEquals("Seq Number", 18, msg.seqNbr);
assertEquals("Sensor Id", "13345", msg.getDeviceId());

assertEquals("UV", 2.5, msg.uv, 0.001);
assertEquals("Temperature", 1822.5, msg.temperature, 0.001);

assertEquals("Signal Level", 14, msg.signalLevel);
assertEquals("Battery Level", 9, msg.batteryLevel);

byte[] decoded = msg.decodeMessage();

assertEquals("Message converted back", hexMessage, DatatypeConverter.printHexBinary(decoded));
}

@Test
public void testMessage2() throws RFXComException {
String hexMessage = "09570312342119C731E9";

byte[] message = DatatypeConverter.parseHexBinary(hexMessage);
RFXComUVMessage msg = (RFXComUVMessage) RFXComMessageFactory.createMessage(message);

assertEquals("SubType", RFXComUVMessage.SubType.UV3, msg.subType);
assertEquals("Seq Number", 18, msg.seqNbr);
assertEquals("Sensor Id", "13345", msg.getDeviceId());

assertEquals("UV", 2.5, msg.uv, 0.001);
assertEquals("Temperature", -1822.5, msg.temperature, 0.001);

assertEquals("Signal Level", 14, msg.signalLevel);
assertEquals("Battery Level", 9, msg.batteryLevel);

byte[] decoded = msg.decodeMessage();

assertEquals("Message converted back", hexMessage, DatatypeConverter.printHexBinary(decoded));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,11 @@
<description>Enable BlindsT0 messages to RFXCOM transceiver.</description>
<default>false</default>
</parameter>
<parameter name="enableFS20" type="boolean">
<label>FS20/Legrand CAD messages</label>
<description>Enable FS20/Legrand CAD messages to RFXCOM transceiver.</description>
<default>false</default>
</parameter>
<parameter name="enableLaCrosse" type="boolean">
<label>La Crosse messages</label>
<description>Enable La Crosse messages to RFXCOM transceiver.</description>
Expand Down Expand Up @@ -138,6 +143,16 @@
<description>Enable X10 messages to RFXCOM transceiver.</description>
<default>false</default>
</parameter>
<parameter name="enableHomeConfort" type="boolean">
<label>HomeConfort messages</label>
<description>Enable HomeConfort messages to RFXCOM transceiver.</description>
<default>false</default>
</parameter>
<parameter name="enableKEELOQ" type="boolean">
<label>KEELOQ messages</label>
<description>Enable KEELOQ messages to RFXCOM transceiver.</description>
<default>false</default>
</parameter>

</config-description>
</bridge-type>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,11 @@
<description>Enable BlindsT0 messages to RFXCOM transceiver.</description>
<default>false</default>
</parameter>
<parameter name="enableFS20" type="boolean">
<label>FS20/Legrand CAD messages</label>
<description>Enable FS20/Legrand CAD messages to RFXCOM transceiver.</description>
<default>false</default>
</parameter>
<parameter name="enableLaCrosse" type="boolean">
<label>La Crosse messages</label>
<description>Enable La Crosse messages to RFXCOM transceiver.</description>
Expand Down Expand Up @@ -138,6 +143,16 @@
<description>Enable X10 messages to RFXCOM transceiver.</description>
<default>false</default>
</parameter>
<parameter name="enableHomeConfort" type="boolean">
<label>HomeConfort messages</label>
<description>Enable HomeConfort messages to RFXCOM transceiver.</description>
<default>false</default>
</parameter>
<parameter name="enableKEELOQ" type="boolean">
<label>KEELOQ messages</label>
<description>Enable KEELOQ messages to RFXCOM transceiver.</description>
<default>false</default>
</parameter>

</config-description>
</bridge-type>
Expand Down
Loading

0 comments on commit 832bac1

Please sign in to comment.