-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
[Worxlandroid] Initial contribution #16893
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
clinique
wants to merge
20
commits into
openhab:main
Choose a base branch
from
clinique:worxlandroid
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
7948d21
Worxlandroid new binding
clinique c72a4ab
Applying spotless
clinique de635ea
Code cleansing started
clinique 3ae5a65
Updated to 4.3 and two SAT corrections
clinique c73c363
Adding https://github.com/clinique/openhab-addons/pull/24
clinique ed0170e
Code review n°1 corrections
clinique 77bb4cd
Code review n°2 corrections
clinique 30b58ac
Code review n°3 corrections
clinique c090241
Restoring lost Netatmo file
clinique cfe369c
Code review n°4
clinique f9d88a7
Adding Nils family name
clinique afad02b
Pom update to 5.0
clinique 39bdf9f
Update the headers
clinique 38a8098
Pom update to 5.1
clinique de4ea46
Remove unwanted netatmo file.
clinique d3bbd17
Restore Netatmo file
clinique 898fa75
Forgot ressource files
clinique a4fe63a
Rebased
clinique 18d657a
Update feature.xml
clinique 586b348
Redoing pom.xml modifications
clinique File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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,13 @@ | ||
| 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 |
Large diffs are not rendered by default.
Oops, something went wrong.
24 changes: 24 additions & 0 deletions
24
bundles/org.openhab.binding.worxlandroid/images/landroid.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or 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,32 @@ | ||
| <?xml version="1.0" encoding="UTF-8"?> | ||
| <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
| 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>5.1.0-SNAPSHOT</version> | ||
| </parent> | ||
|
|
||
| <artifactId>org.openhab.binding.worxlandroid</artifactId> | ||
|
|
||
| <name>openHAB Add-ons :: Bundles :: Worx Landroid Binding</name> | ||
|
|
||
| <dependencies> | ||
| <dependency> | ||
| <groupId>software.amazon.awssdk.iotdevicesdk</groupId> | ||
| <artifactId>aws-iot-device-sdk</artifactId> | ||
| <version>1.27.4</version> | ||
| <scope>provided</scope> | ||
| </dependency> | ||
| <dependency> | ||
| <groupId>software.amazon.awssdk.crt</groupId> | ||
| <artifactId>aws-crt</artifactId> | ||
| <version>0.38.13</version> | ||
| <scope>provided</scope> | ||
| </dependency> | ||
| </dependencies> | ||
|
|
||
| </project> |
10 changes: 10 additions & 0 deletions
10
bundles/org.openhab.binding.worxlandroid/src/main/feature/feature.xml
This file contains hidden or 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,10 @@ | ||
| <?xml version="1.0" encoding="UTF-8"?> | ||
| <features name="org.openhab.binding.worxlandroid-${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-worxlandroid" description="Worx Landroid Binding" version="${project.version}"> | ||
| <feature>openhab-runtime-base</feature> | ||
| <bundle start-level="80">mvn:org.openhab.addons.bundles/org.openhab.binding.worxlandroid/${project.version}</bundle> | ||
lsiepel marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| <bundle dependency="true">mvn:org.openhab.osgiify/software.amazon.awssdk.iotdevicesdk.aws-iot-device-sdk/1.27.4</bundle> | ||
| </feature> | ||
| </features> | ||
110 changes: 110 additions & 0 deletions
110
...src/main/java/org/openhab/binding/worxlandroid/internal/WorxLandroidBindingConstants.java
This file contains hidden or 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,110 @@ | ||
| /* | ||
| * Copyright (c) 2010-2025 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.worxlandroid.internal; | ||
|
|
||
| import java.util.Set; | ||
|
|
||
| import org.eclipse.jdt.annotation.NonNullByDefault; | ||
| import org.openhab.core.thing.ThingTypeUID; | ||
|
|
||
| /** | ||
| * The {@link WorxLandroidBindingConstants} class defines datCommon constants, which are | ||
| * used across the whole binding. | ||
| * | ||
| * @author Nils Billing - Initial contribution | ||
| */ | ||
| @NonNullByDefault | ||
| public class WorxLandroidBindingConstants { | ||
|
|
||
| public static final String BINDING_ID = "worxlandroid"; | ||
|
|
||
| // List of all Thing Type UIDs | ||
| public static final ThingTypeUID THING_TYPE_BRIDGE = new ThingTypeUID(BINDING_ID, "bridge"); | ||
| public static final ThingTypeUID THING_TYPE_MOWER = new ThingTypeUID(BINDING_ID, "mower"); | ||
|
|
||
| public static final Set<ThingTypeUID> SUPPORTED_THING_TYPES = Set.of(THING_TYPE_MOWER); | ||
|
|
||
| // Channel group ids | ||
| public static final String GROUP_COMMON = "common"; | ||
| public static final String GROUP_CONFIG = "config"; | ||
| public static final String GROUP_MULTI_ZONES = "multi-zones"; | ||
| public static final String GROUP_SCHEDULE = "schedule"; | ||
| public static final String GROUP_ONE_TIME = "one-time"; | ||
| public static final String GROUP_BATTERY = "battery"; | ||
| public static final String GROUP_ORIENTATION = "orientation"; | ||
| public static final String GROUP_METRICS = "metrics"; | ||
| public static final String GROUP_RAIN = "rain"; | ||
| public static final String GROUP_WIFI = "wifi"; | ||
| public static final String GROUP_AWS = "aws"; | ||
|
|
||
| // List channel ids | ||
| // common | ||
| public static final String CHANNEL_ONLINE_TIMESTAMP = "online-timestamp"; | ||
| public static final String CHANNEL_ACTION = "action"; | ||
| public static final String CHANNEL_ENABLE = "enable"; | ||
| public static final String CHANNEL_ONLINE = "online"; | ||
| public static final String CHANNEL_LOCK = "lock"; | ||
| public static final String CHANNEL_RSSI = "rssi"; | ||
|
|
||
| // AWS | ||
| public static final String CHANNEL_POLL = "poll"; | ||
| public static final String CHANNEL_CONNECTED = "connected"; | ||
|
|
||
| // cfgCommon | ||
| public static final String CHANNEL_TIMESTAMP = "timestamp"; | ||
| public static final String CHANNEL_COMMAND = "command"; | ||
| public static final String CHANNEL_DELAY = "delay"; | ||
|
|
||
| // cfgSc | ||
| public static final String CHANNEL_TIME_EXTENSION = "time-extension"; | ||
| public static final String CHANNEL_MODE = "mode"; | ||
| public static final String CHANNEL_START = "next-start"; | ||
| public static final String CHANNEL_STOP = "next-stop"; | ||
|
|
||
| // cfgScXXXday | ||
| public static final String CHANNEL_DURATION = "duration"; | ||
| public static final String CHANNEL_EDGECUT = "edgecut"; | ||
| public static final String CHANNEL_TIME = "time"; | ||
|
|
||
| // datCommon | ||
| public static final String CHANNEL_WIFI_QUALITY = "wifi-quality"; | ||
| public static final String CHANNEL_LAST_ZONE = "last-zone"; | ||
| public static final String CHANNEL_STATUS_CODE = "status"; | ||
| public static final String CHANNEL_ERROR_CODE = "error"; | ||
|
|
||
| // datBattery | ||
| public static final String CHANNEL_TEMPERATURE = "temperature"; | ||
| public static final String CHANNEL_VOLTAGE = "voltage"; | ||
| public static final String CHANNEL_LEVEL = "level"; | ||
| public static final String CHANNEL_CHARGE_CYCLES = "charge-cycles"; | ||
| public static final String CHANNEL_CHARGE_CYCLES_TOTAL = "charge-cycles-total"; | ||
| public static final String CHANNEL_CHARGING = "charging"; | ||
|
|
||
| // datDmp | ||
| public static final String CHANNEL_PITCH = "pitch"; | ||
| public static final String CHANNEL_ROLL = "roll"; | ||
| public static final String CHANNEL_YAW = "yaw"; | ||
|
|
||
| // datSt | ||
| public static final String CHANNEL_BLADE_TIME = "blade-time"; | ||
| public static final String CHANNEL_BLADE_TIME_TOTAL = "blade-time-total"; | ||
| public static final String CHANNEL_DISTANCE = "distance"; | ||
| public static final String CHANNEL_TOTAL_TIME = "total-time"; | ||
|
|
||
| // datRain | ||
| public static final String CHANNEL_RAIN_STATE = "state"; | ||
| public static final String CHANNEL_RAIN_COUNTER = "counter"; | ||
|
|
||
| public static final String CHANNEL_PREFIX_ALLOCATION = "allocation-%d"; | ||
| public static final String CHANNEL_PREFIX_ZONE = "zone-%d"; | ||
| } |
98 changes: 98 additions & 0 deletions
98
...d/src/main/java/org/openhab/binding/worxlandroid/internal/WorxLandroidHandlerFactory.java
This file contains hidden or 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,98 @@ | ||
| /* | ||
| * Copyright (c) 2010-2025 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.worxlandroid.internal; | ||
|
|
||
| import static org.openhab.binding.worxlandroid.internal.WorxLandroidBindingConstants.*; | ||
|
|
||
| import java.util.HashMap; | ||
| import java.util.Hashtable; | ||
| import java.util.Map; | ||
| import java.util.Set; | ||
|
|
||
| import org.eclipse.jdt.annotation.NonNullByDefault; | ||
| import org.eclipse.jdt.annotation.Nullable; | ||
| import org.openhab.binding.worxlandroid.internal.api.WorxApiHandler; | ||
| import org.openhab.binding.worxlandroid.internal.discovery.MowerDiscoveryService; | ||
| import org.openhab.binding.worxlandroid.internal.handler.WorxLandroidBridgeHandler; | ||
| import org.openhab.binding.worxlandroid.internal.handler.WorxLandroidMowerHandler; | ||
| import org.openhab.core.auth.client.oauth2.OAuthFactory; | ||
| import org.openhab.core.config.discovery.DiscoveryService; | ||
| import org.openhab.core.thing.Bridge; | ||
| import org.openhab.core.thing.Thing; | ||
| import org.openhab.core.thing.ThingTypeUID; | ||
| import org.openhab.core.thing.ThingUID; | ||
| import org.openhab.core.thing.binding.BaseThingHandlerFactory; | ||
| import org.openhab.core.thing.binding.ThingHandler; | ||
| import org.openhab.core.thing.binding.ThingHandlerFactory; | ||
| import org.osgi.framework.ServiceRegistration; | ||
| import org.osgi.service.component.annotations.Activate; | ||
| import org.osgi.service.component.annotations.Component; | ||
| import org.osgi.service.component.annotations.Reference; | ||
|
|
||
| /** | ||
| * The {@link WorxLandroidHandlerFactory} is responsible for creating things and thing | ||
| * handlers. | ||
| * | ||
| * @author Nils Billing - Initial contribution | ||
| * @author Gaël L'hopital - Added oAuthFactory | ||
| */ | ||
| @NonNullByDefault | ||
| @Component(configurationPid = "binding.worxlandroid", service = ThingHandlerFactory.class) | ||
| public class WorxLandroidHandlerFactory extends BaseThingHandlerFactory { | ||
| private static final Set<ThingTypeUID> SUPPORTED_THING_TYPES_UIDS = Set.of(THING_TYPE_MOWER, THING_TYPE_BRIDGE); | ||
|
|
||
| private final Map<ThingUID, ServiceRegistration<?>> discoveryServiceRegs = new HashMap<>(); | ||
| private final OAuthFactory oAuthFactory; | ||
| private final WorxApiHandler worxApiHandler; | ||
|
|
||
| @Activate | ||
| public WorxLandroidHandlerFactory(final @Reference OAuthFactory oAuthFactory, | ||
| final @Reference WorxApiHandler worxApiHandler) { | ||
| this.oAuthFactory = oAuthFactory; | ||
| this.worxApiHandler = worxApiHandler; | ||
| } | ||
|
|
||
| @Override | ||
| public boolean supportsThingType(ThingTypeUID thingTypeUID) { | ||
| return SUPPORTED_THING_TYPES_UIDS.contains(thingTypeUID); | ||
| } | ||
|
|
||
| @Override | ||
| protected @Nullable ThingHandler createHandler(Thing thing) { | ||
| ThingTypeUID thingTypeUID = thing.getThingTypeUID(); | ||
|
|
||
| if (THING_TYPE_BRIDGE.equals(thingTypeUID)) { | ||
| WorxLandroidBridgeHandler bridgeHandler = new WorxLandroidBridgeHandler((Bridge) thing, worxApiHandler, | ||
| oAuthFactory); | ||
| MowerDiscoveryService discoveryService = new MowerDiscoveryService(bridgeHandler); | ||
| discoveryServiceRegs.put(thing.getUID(), bundleContext.registerService(DiscoveryService.class.getName(), | ||
| discoveryService, new Hashtable<>())); | ||
|
|
||
| return bridgeHandler; | ||
| } else if (THING_TYPE_MOWER.equals(thingTypeUID)) { | ||
| return new WorxLandroidMowerHandler(thing, worxApiHandler.getDeserializer()); | ||
| } | ||
| return null; | ||
| } | ||
|
|
||
| @Override | ||
| protected void removeHandler(ThingHandler handler) { | ||
| if (handler instanceof WorxLandroidBridgeHandler) { | ||
| ServiceRegistration<?> serviceReg = discoveryServiceRegs.remove(handler.getThing().getUID()); | ||
| if (serviceReg != null) { | ||
| serviceReg.unregister(); | ||
| } | ||
| } | ||
| super.removeHandler(handler); | ||
| } | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.