Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/main' into openhab#13456-hue-c…
Browse files Browse the repository at this point in the history
…lip2
  • Loading branch information
andrewfg committed Mar 13, 2023
2 parents 6975089 + 709dc49 commit fbc6618
Show file tree
Hide file tree
Showing 150 changed files with 3,867 additions and 940 deletions.
5 changes: 4 additions & 1 deletion .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,13 @@ Pay attention to the below notes and to *the guidelines* for this repository.
Feel free to delete any comment sections in the template (starting with "<!--").
ATTENTION: Don't use "git merge" when working with your pull request branch!
This can clutter your Git history and make your PR unuseable.
This can clutter your Git history and make your PR unusable.
Use "git rebase" instead. See this forum post for further details:
https://community.openhab.org/t/rebase-your-code-or-how-to-fix-your-git-history-before-requesting-a-pull/129358
All PRs should be created using the "main" branch as base.
Important bugfixes are cherry-picked by maintainers to the patch release branch after a PR has been merged.
Add one or more appropriate labels to make your PR show up in the release notes.
E.g. enhancement, bug, documentation, new binding
This can only be done by yourself if you already contributed to this repo.
Expand Down
1 change: 1 addition & 0 deletions CODEOWNERS
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,7 @@
/bundles/org.openhab.binding.mqtt.homie/ @davidgraeff
/bundles/org.openhab.binding.mycroft/ @dalgwen
/bundles/org.openhab.binding.mybmw/ @weymann @ntruchsess
/bundles/org.openhab.binding.mynice/ @clinique
/bundles/org.openhab.binding.myq/ @digitaldan
/bundles/org.openhab.binding.mystrom/ @pail23
/bundles/org.openhab.binding.nanoleaf/ @raepple @stefan-hoehn
Expand Down
5 changes: 5 additions & 0 deletions bom/openhab-addons/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1081,6 +1081,11 @@
<artifactId>org.openhab.binding.mybmw</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.openhab.addons.bundles</groupId>
<artifactId>org.openhab.binding.mynice</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.openhab.addons.bundles</groupId>
<artifactId>org.openhab.binding.myq</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion bundles/org.openhab.automation.groovyscripting/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Groovy Scripting

This add-on provides support for [Groovy](https://groovy-lang.org/) 4.0.7 that can be used as a scripting language within automation rules and which eliminates the need to manually install Groovy.
This add-on provides support for [Groovy](https://groovy-lang.org/) 4.0.9 that can be used as a scripting language within automation rules and which eliminates the need to manually install Groovy.

## Creating Groovy Scripts

Expand Down
40 changes: 38 additions & 2 deletions bundles/org.openhab.automation.groovyscripting/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
<name>openHAB Add-ons :: Bundles :: Automation :: Groovy Scripting</name>

<properties>
<bnd.importpackage>com.ibm.icu.*;resolution:=optional,groovy.runtime.metaclass;resolution:=optional,groovyjarjarantlr4.stringtemplate;resolution:=optional,org.abego.treelayout.*;resolution:=optional,org.apache.ivy.*;resolution:=optional,org.stringtemplate.v4.*;resolution:=optional</bnd.importpackage>
<groovy.version>4.0.7</groovy.version>
<bnd.importpackage>com.ibm.icu.*;resolution:=optional,groovy.runtime.metaclass;resolution:=optional,groovyjarjarantlr4.stringtemplate;resolution:=optional,org.abego.treelayout.*;resolution:=optional,org.apache.ivy.*;resolution:=optional,org.fusesource.jansi.*;resolution:=optional,org.stringtemplate.v4.*;resolution:=optional</bnd.importpackage>
<groovy.version>4.0.9</groovy.version>
</properties>

<dependencies>
Expand All @@ -32,12 +32,48 @@
<version>${groovy.version}</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.apache.groovy</groupId>
<artifactId>groovy-json</artifactId>
<version>${groovy.version}</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.apache.groovy</groupId>
<artifactId>groovy-xml</artifactId>
<version>${groovy.version}</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.apache.groovy</groupId>
<artifactId>groovy-yaml</artifactId>
<version>${groovy.version}</version>
<scope>compile</scope>
</dependency>
</dependencies>

<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>biz.aQute.bnd</groupId>
<artifactId>bnd-maven-plugin</artifactId>
<configuration>
<bnd><![CDATA[${oh.bndDefaults}
Require-Capability:
osgi.extender:=
filter:="(osgi.extender=osgi.serviceloader.processor)",
osgi.serviceloader:=
filter:="(osgi.serviceloader=org.apache.groovy.json.FastStringServiceFactory)";
cardinality:=multiple
SPI-Provider: *
SPI-Consumer: *
]]>
</bnd>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>

</project>
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public class GroovyScriptEngineFactory extends AbstractScriptEngineFactory {
.flatMap(List::stream) //
.collect(Collectors.toUnmodifiableList());

private final GroovyClassLoader gcl = new GroovyClassLoader();
private final GroovyClassLoader gcl = new GroovyClassLoader(GroovyScriptEngineFactory.class.getClassLoader());

public GroovyScriptEngineFactory() {
String scriptDir = OpenHAB.getConfigFolder() + File.separator + FILE_DIRECTORY;
Expand Down
2 changes: 1 addition & 1 deletion bundles/org.openhab.automation.jrubyscripting/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

<properties>
<bnd.importpackage>com.sun.nio.*;resolution:=optional,com.sun.security.*;resolution:=optional,org.apache.tools.ant.*;resolution:=optional,org.bouncycastle.*;resolution:=optional,org.joda.*;resolution:=optional,sun.management.*;resolution:=optional,sun.nio.*;resolution:=optional,jakarta.annotation;resolution:=optional</bnd.importpackage>
<jruby.version>9.3.9.0</jruby.version>
<jruby.version>9.4.2.0</jruby.version>
</properties>

<dependencies>
Expand Down
41 changes: 37 additions & 4 deletions bundles/org.openhab.binding.androiddebugbridge/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,40 @@ The configuration depends on the application, device and version used.

This is a sample of the mediaStateJSONConfig thing configuration - the `label` is optional:

`[{"name": "com.amazon.tv.launcher", "mode": "idle"}, {"name": "org.jellyfin.androidtv", "mode": "wake_lock", "wakeLockPlayStates": [2,3]}, {"name": "com.amazon.firetv.youtube", "label":"YouTube", "mode": "wake_lock", "wakeLockPlayStates": [2]}]`
```json
[
{
"name": "com.amazon.tv.launcher",
"mode": "idle",
"label": "Home"
},
{
"name": "org.jellyfin.androidtv",
"mode": "wake_lock",
"label": "Jellyfin",
"wakeLockPlayStates": [
2,
3
]
},
{
"name": "com.amazon.firetv.youtube",
"label": "YouTube",
"mode": "wake_lock",
"wakeLockPlayStates": [
2
]
},
{
"name": "com.netflix.ninja",
"label": "Netflix",
"mode": "wake_lock",
"wakeLockPlayStates": [
4
]
}
]
```

## Record/Send input events

Expand Down Expand Up @@ -102,17 +135,17 @@ Please note that events could fail if the input method is removed, for example i
| record-input | String | Capture events, generate the equivalent command and store it under the provided name |
| recorded-input | String | Emulates previously captured input events by name |
| shutdown | String | Power off/reboot device (allowed values POWER_OFF, REBOOT) |
| awake-state | OnOff | Awake state value. |
| awake-state | Switch | Awake state value. |
| wake-lock | Number | Power wake lock value |
| screen-state | Switch | Screen power state |

### Start Intent

This channel allows to invoke the 'am start' command, the syntax for it is:
<package/activity>||<<arg name>> <arg value>||...
`<package/activity>||<<arg name>> <arg value>||...`

This is a sample:
com.netflix.ninja/.MainActivity||<a>android.intent.action.VIEW||<d>netflix://title/80025384||<f>0x10000020||<es>amzn_deeplink_data 80025384
`com.netflix.ninja/.MainActivity||<a>android.intent.action.VIEW||<d>netflix://title/80025384||<f>0x10000020||<es>amzn_deeplink_data 80025384`

Not all the [arguments](https://developer.android.com/studio/command-line/adb#IntentSpec) are supported. Please open an issue or pull request if you need more.

Expand Down
9 changes: 5 additions & 4 deletions bundles/org.openhab.binding.bluetooth.radoneye/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,11 @@ As any other Bluetooth device, RadonEye devices are discovered automatically by

Supported configuration parameters for the things:

| Property | Type | Default | Required | Description |
|---------------------------------|---------|---------|----------|-----------------------------------------------------------------|
| address | String | | Yes | Bluetooth address of the device (in format "XX:XX:XX:XX:XX:XX") |
| refreshInterval | Integer | 300 | No | How often a refresh shall occur in seconds |
| Property | Type | Default | Required | Description |
|-----------------|---------|---------|----------|-----------------------------------------------------------------|
| address | String | | Yes | Bluetooth address of the device (in format "XX:XX:XX:XX:XX:XX") |
| fwVersion | Integer | 1 | No | The major version of the firmware on the device |
| refreshInterval | Integer | 300 | No | How often a refresh shall occur in seconds |

## Channels

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
*/
package org.openhab.binding.bluetooth.radoneye.internal;

import java.util.Optional;
import java.util.UUID;
import java.util.concurrent.ScheduledFuture;
import java.util.concurrent.TimeUnit;
Expand Down Expand Up @@ -45,10 +44,9 @@ abstract public class AbstractRadoneyeHandler extends BeaconBluetoothHandler {
private final Logger logger = LoggerFactory.getLogger(AbstractRadoneyeHandler.class);

private AtomicInteger sinceLastReadSec = new AtomicInteger();
private Optional<RadoneyeConfiguration> configuration = Optional.empty();
private RadoneyeConfiguration configuration = new RadoneyeConfiguration();
private @Nullable ScheduledFuture<?> scheduledTask;

private volatile int refreshInterval;
private volatile int errorConnectCounter;
private volatile int errorReadCounter;
private volatile int errorWriteCounter;
Expand Down Expand Up @@ -78,16 +76,14 @@ public AbstractRadoneyeHandler(Thing thing) {
public void initialize() {
logger.debug("Initialize");
super.initialize();
configuration = Optional.of(getConfigAs(RadoneyeConfiguration.class));
logger.debug("Using configuration: {}", configuration.get());
configuration = getConfigAs(RadoneyeConfiguration.class);
logger.debug("Using configuration: {}", configuration);
cancelScheduledTask();
configuration.ifPresent(cfg -> {
refreshInterval = cfg.refreshInterval;
logger.debug("Start scheduled task to read device in every {} seconds", refreshInterval);
scheduledTask = scheduler.scheduleWithFixedDelay(this::executePeridioc, CHECK_PERIOD_SEC, CHECK_PERIOD_SEC,
TimeUnit.SECONDS);
});
sinceLastReadSec.set(refreshInterval); // update immediately
logger.debug("Start scheduled task to read device in every {} seconds", configuration.refreshInterval);
scheduledTask = scheduler.scheduleWithFixedDelay(this::executePeridioc, CHECK_PERIOD_SEC, CHECK_PERIOD_SEC,
TimeUnit.SECONDS);

sinceLastReadSec.set(configuration.refreshInterval); // update immediately
}

@Override
Expand Down Expand Up @@ -293,7 +289,16 @@ public void onConnectionStateChange(BluetoothConnectionStatusNotification connec
private boolean isTimeToRead() {
int sinceLastRead = sinceLastReadSec.get();
logger.debug("Time since last update: {} sec", sinceLastRead);
return sinceLastRead >= refreshInterval;
return sinceLastRead >= configuration.refreshInterval;
}

/**
* Provides the configured major firmware version
*
* @return the major firmware version configured
*/
protected int getFwVersion() {
return configuration.fwVersion;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,11 @@
@NonNullByDefault
public class RadoneyeConfiguration {
public String address = "";
public int refreshInterval;
public int fwVersion = 1;
public int refreshInterval = 300;

@Override
public String toString() {
return "[address=" + address + ", refreshInterval=" + refreshInterval + "]";
return "[address=" + address + ", fwVersion=" + fwVersion + ", refreshInterval=" + refreshInterval + "]";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,26 +30,41 @@
public class RadoneyeDataParser {
public static final String RADON = "radon";

private static final int EXPECTED_DATA_LEN = 20;
private static final int EXPECTED_DATA_LEN_V1 = 20;
private static final int EXPECTED_DATA_LEN_V2 = 12;
private static final int EXPECTED_VER_PLUS = 1;

private static final Logger logger = LoggerFactory.getLogger(RadoneyeDataParser.class);

private RadoneyeDataParser() {
}

public static Map<String, Number> parseRd200Data(int[] data) throws RadoneyeParserException {
public static Map<String, Number> parseRd200Data(int fwVersion, int[] data) throws RadoneyeParserException {
logger.debug("Parsed data length: {}", data.length);
logger.debug("Parsed data: {}", data);
if (data.length == EXPECTED_DATA_LEN) {
final Map<String, Number> result = new HashMap<>();

int[] radonArray = subArray(data, 2, 6);
result.put(RADON, new BigDecimal(readFloat(radonArray) * 37));
return result;
} else {
throw new RadoneyeParserException(String.format("Illegal data structure length '%d'", data.length));
final Map<String, Number> result = new HashMap<>();

switch (fwVersion) {
case 1:
if (data.length != EXPECTED_DATA_LEN_V1) {
throw new RadoneyeParserException(String.format("Illegal data structure length '%d'", data.length));
}

int[] radonArray = subArray(data, 2, 6);
result.put(RADON, new BigDecimal(readFloat(radonArray) * 37));
break;
case 2:
if (data.length != EXPECTED_DATA_LEN_V2) {
throw new RadoneyeParserException(String.format("Illegal data structure length '%d'", data.length));
}

result.put(RADON, intFromBytes(data[2], data[3]));
break;
default:
throw new UnsupportedOperationException("fwVersion: " + fwVersion + " is not implemented");
}
return result;
}

private static int intFromBytes(int lowByte, int highByte) {
Expand Down
Loading

0 comments on commit fbc6618

Please sign in to comment.