initial commit for ecowitt binding
This commit is contained in:
parent
11a75e68d3
commit
5ae6572315
|
@ -431,12 +431,16 @@
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.openhab.addons.bundles</groupId>
|
<groupId>org.openhab.addons.bundles</groupId>
|
||||||
|
<<<<<<< HEAD
|
||||||
<artifactId>org.openhab.binding.ecovacs</artifactId>
|
<artifactId>org.openhab.binding.ecovacs</artifactId>
|
||||||
<version>${project.version}</version>
|
<version>${project.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.openhab.addons.bundles</groupId>
|
<groupId>org.openhab.addons.bundles</groupId>
|
||||||
<artifactId>org.openhab.binding.ecowatt</artifactId>
|
<artifactId>org.openhab.binding.ecowatt</artifactId>
|
||||||
|
=======
|
||||||
|
<artifactId>org.openhab.binding.ecowitt</artifactId>
|
||||||
|
>>>>>>> 833ca96673 (initial commit for ecowitt binding)
|
||||||
<version>${project.version}</version>
|
<version>${project.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
|
|
|
@ -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
|
|
@ -0,0 +1,56 @@
|
||||||
|
# ecowitt Binding
|
||||||
|
|
||||||
|
_Give some details about what this binding is meant for - a protocol, system, specific device._
|
||||||
|
|
||||||
|
_If possible, provide some resources like pictures, a video, etc. to give an impression of what can be done with this binding. You can place such resources into a `doc` folder next to this README.md._
|
||||||
|
|
||||||
|
## Supported Things
|
||||||
|
|
||||||
|
_Please describe the different supported things / devices within this section._
|
||||||
|
_Which different types are supported, which models were tested etc.?_
|
||||||
|
_Note that it is planned to generate some part of this based on the XML files within ```src/main/resources/OH-INF/thing``` of your binding._
|
||||||
|
|
||||||
|
## Discovery
|
||||||
|
|
||||||
|
_Describe the available auto-discovery features here. Mention for what it works and what needs to be kept in mind when using it._
|
||||||
|
|
||||||
|
## Binding Configuration
|
||||||
|
|
||||||
|
_If your binding requires or supports general configuration settings, please create a folder ```cfg``` and place the configuration file ```<bindingId>.cfg``` inside it. In this section, you should link to this file and provide some information about the options. The file could e.g. look like:_
|
||||||
|
|
||||||
|
```
|
||||||
|
# Configuration for the ecowitt Binding
|
||||||
|
#
|
||||||
|
# Default secret key for the pairing of the ecowitt Thing.
|
||||||
|
# It has to be between 10-40 (alphanumeric) characters.
|
||||||
|
# This may be changed by the user for security reasons.
|
||||||
|
secret=openHABSecret
|
||||||
|
```
|
||||||
|
|
||||||
|
_Note that it is planned to generate some part of this based on the information that is available within ```src/main/resources/OH-INF/binding``` of your binding._
|
||||||
|
|
||||||
|
_If your binding does not offer any generic configurations, you can remove this section completely._
|
||||||
|
|
||||||
|
## Thing Configuration
|
||||||
|
|
||||||
|
_Describe what is needed to manually configure a thing, either through the UI or via a thing-file. This should be mainly about its mandatory and optional configuration parameters. A short example entry for a thing file can help!_
|
||||||
|
|
||||||
|
_Note that it is planned to generate some part of this based on the XML files within ```src/main/resources/OH-INF/thing``` of your binding._
|
||||||
|
|
||||||
|
## Channels
|
||||||
|
|
||||||
|
_Here you should provide information about available channel types, what their meaning is and how they can be used._
|
||||||
|
|
||||||
|
_Note that it is planned to generate some part of this based on the XML files within ```src/main/resources/OH-INF/thing``` of your binding._
|
||||||
|
|
||||||
|
| channel | type | description |
|
||||||
|
|----------|--------|------------------------------|
|
||||||
|
| control | Switch | This is the control channel |
|
||||||
|
|
||||||
|
## Full Example
|
||||||
|
|
||||||
|
_Provide a full usage example based on textual configuration files (*.things, *.items, *.sitemap)._
|
||||||
|
|
||||||
|
## Any custom content here!
|
||||||
|
|
||||||
|
_Feel free to add additional sections for whatever you think should also be mentioned about your binding!_
|
|
@ -0,0 +1,17 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0"
|
||||||
|
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>3.2.0-SNAPSHOT</version>
|
||||||
|
</parent>
|
||||||
|
|
||||||
|
<artifactId>org.openhab.binding.ecowitt</artifactId>
|
||||||
|
|
||||||
|
<name>openHAB Add-ons :: Bundles :: ecowitt Binding</name>
|
||||||
|
|
||||||
|
</project>
|
|
@ -0,0 +1,9 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<features name="org.openhab.binding.ecowitt-${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-ecowitt" description="ecowitt Binding" version="${project.version}">
|
||||||
|
<feature>openhab-runtime-base</feature>
|
||||||
|
<bundle start-level="80">mvn:org.openhab.addons.bundles/org.openhab.binding.ecowitt/${project.version}</bundle>
|
||||||
|
</feature>
|
||||||
|
</features>
|
|
@ -0,0 +1,34 @@
|
||||||
|
/**
|
||||||
|
* Copyright (c) 2010-2022 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.ecowitt.internal;
|
||||||
|
|
||||||
|
import org.eclipse.jdt.annotation.NonNullByDefault;
|
||||||
|
import org.openhab.core.thing.ThingTypeUID;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The {@link ecowittBindingConstants} class defines common constants, which are
|
||||||
|
* used across the whole binding.
|
||||||
|
*
|
||||||
|
* @author Av3m - Initial contribution
|
||||||
|
*/
|
||||||
|
@NonNullByDefault
|
||||||
|
public class ecowittBindingConstants {
|
||||||
|
|
||||||
|
private static final String BINDING_ID = "ecowitt";
|
||||||
|
|
||||||
|
// List of all Thing Type UIDs
|
||||||
|
public static final ThingTypeUID THING_TYPE_SAMPLE = new ThingTypeUID(BINDING_ID, "sample");
|
||||||
|
|
||||||
|
// List of all Channel ids
|
||||||
|
public static final String CHANNEL_1 = "channel1";
|
||||||
|
}
|
|
@ -0,0 +1,28 @@
|
||||||
|
/**
|
||||||
|
* Copyright (c) 2010-2022 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.ecowitt.internal;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The {@link ecowittConfiguration} class contains fields mapping thing configuration parameters.
|
||||||
|
*
|
||||||
|
* @author Av3m - Initial contribution
|
||||||
|
*/
|
||||||
|
public class ecowittConfiguration {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sample configuration parameters. Replace with your own.
|
||||||
|
*/
|
||||||
|
public String hostname;
|
||||||
|
public String password;
|
||||||
|
public int refreshInterval;
|
||||||
|
}
|
|
@ -0,0 +1,100 @@
|
||||||
|
/**
|
||||||
|
* Copyright (c) 2010-2022 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.ecowitt.internal;
|
||||||
|
|
||||||
|
import static org.openhab.binding.ecowitt.internal.ecowittBindingConstants.*;
|
||||||
|
|
||||||
|
import org.eclipse.jdt.annotation.NonNullByDefault;
|
||||||
|
import org.eclipse.jdt.annotation.Nullable;
|
||||||
|
import org.openhab.core.thing.ChannelUID;
|
||||||
|
import org.openhab.core.thing.Thing;
|
||||||
|
import org.openhab.core.thing.ThingStatus;
|
||||||
|
import org.openhab.core.thing.binding.BaseThingHandler;
|
||||||
|
import org.openhab.core.types.Command;
|
||||||
|
import org.openhab.core.types.RefreshType;
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The {@link ecowittHandler} is responsible for handling commands, which are
|
||||||
|
* sent to one of the channels.
|
||||||
|
*
|
||||||
|
* @author Av3m - Initial contribution
|
||||||
|
*/
|
||||||
|
@NonNullByDefault
|
||||||
|
public class ecowittHandler extends BaseThingHandler {
|
||||||
|
|
||||||
|
private final Logger logger = LoggerFactory.getLogger(ecowittHandler.class);
|
||||||
|
|
||||||
|
private @Nullable ecowittConfiguration config;
|
||||||
|
|
||||||
|
public ecowittHandler(Thing thing) {
|
||||||
|
super(thing);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void handleCommand(ChannelUID channelUID, Command command) {
|
||||||
|
if (CHANNEL_1.equals(channelUID.getId())) {
|
||||||
|
if (command instanceof RefreshType) {
|
||||||
|
// TODO: handle data refresh
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO: handle command
|
||||||
|
|
||||||
|
// Note: if communication with thing fails for some reason,
|
||||||
|
// indicate that by setting the status with detail information:
|
||||||
|
// updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.COMMUNICATION_ERROR,
|
||||||
|
// "Could not control device at IP address x.x.x.x");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void initialize() {
|
||||||
|
config = getConfigAs(ecowittConfiguration.class);
|
||||||
|
|
||||||
|
// TODO: Initialize the handler.
|
||||||
|
// The framework requires you to return from this method quickly. Also, before leaving this method a thing
|
||||||
|
// status from one of ONLINE, OFFLINE or UNKNOWN must be set. This might already be the real thing status in
|
||||||
|
// case you can decide it directly.
|
||||||
|
// In case you can not decide the thing status directly (e.g. for long running connection handshake using WAN
|
||||||
|
// access or similar) you should set status UNKNOWN here and then decide the real status asynchronously in the
|
||||||
|
// background.
|
||||||
|
|
||||||
|
// set the thing status to UNKNOWN temporarily and let the background task decide for the real status.
|
||||||
|
// the framework is then able to reuse the resources from the thing handler initialization.
|
||||||
|
// we set this upfront to reliably check status updates in unit tests.
|
||||||
|
updateStatus(ThingStatus.UNKNOWN);
|
||||||
|
|
||||||
|
// Example for background initialization:
|
||||||
|
scheduler.execute(() -> {
|
||||||
|
boolean thingReachable = true; // <background task with long running initialization here>
|
||||||
|
// when done do:
|
||||||
|
if (thingReachable) {
|
||||||
|
updateStatus(ThingStatus.ONLINE);
|
||||||
|
} else {
|
||||||
|
updateStatus(ThingStatus.OFFLINE);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// These logging types should be primarily used by bindings
|
||||||
|
// logger.trace("Example trace message");
|
||||||
|
// logger.debug("Example debug message");
|
||||||
|
// logger.warn("Example warn message");
|
||||||
|
|
||||||
|
// Note: When initialization can NOT be done set the status with more details for further
|
||||||
|
// analysis. See also class ThingStatusDetail for all available status details.
|
||||||
|
// Add a description to give user information to understand why thing does not work as expected. E.g.
|
||||||
|
// updateStatus(ThingStatus.OFFLINE, ThingStatusDetail.CONFIGURATION_ERROR,
|
||||||
|
// "Can not access device as username and/or password are invalid");
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,55 @@
|
||||||
|
/**
|
||||||
|
* Copyright (c) 2010-2022 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.ecowitt.internal;
|
||||||
|
|
||||||
|
import static org.openhab.binding.ecowitt.internal.ecowittBindingConstants.*;
|
||||||
|
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
import org.eclipse.jdt.annotation.NonNullByDefault;
|
||||||
|
import org.eclipse.jdt.annotation.Nullable;
|
||||||
|
import org.openhab.core.thing.Thing;
|
||||||
|
import org.openhab.core.thing.ThingTypeUID;
|
||||||
|
import org.openhab.core.thing.binding.BaseThingHandlerFactory;
|
||||||
|
import org.openhab.core.thing.binding.ThingHandler;
|
||||||
|
import org.openhab.core.thing.binding.ThingHandlerFactory;
|
||||||
|
import org.osgi.service.component.annotations.Component;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The {@link ecowittHandlerFactory} is responsible for creating things and thing
|
||||||
|
* handlers.
|
||||||
|
*
|
||||||
|
* @author Av3m - Initial contribution
|
||||||
|
*/
|
||||||
|
@NonNullByDefault
|
||||||
|
@Component(configurationPid = "binding.ecowitt", service = ThingHandlerFactory.class)
|
||||||
|
public class ecowittHandlerFactory extends BaseThingHandlerFactory {
|
||||||
|
|
||||||
|
private static final Set<ThingTypeUID> SUPPORTED_THING_TYPES_UIDS = Set.of(THING_TYPE_SAMPLE);
|
||||||
|
|
||||||
|
@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_SAMPLE.equals(thingTypeUID)) {
|
||||||
|
return new ecowittHandler(thing);
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,9 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<binding:binding id="ecowitt" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xmlns:binding="https://openhab.org/schemas/binding/v1.0.0"
|
||||||
|
xsi:schemaLocation="https://openhab.org/schemas/binding/v1.0.0 https://openhab.org/schemas/binding-1.0.0.xsd">
|
||||||
|
|
||||||
|
<name>ecowitt Binding</name>
|
||||||
|
<description>This is the binding for ecowitt.</description>
|
||||||
|
|
||||||
|
</binding:binding>
|
|
@ -0,0 +1,21 @@
|
||||||
|
# FIXME: please substitute the xx with a proper locale, ie. de
|
||||||
|
# FIXME: please do not add the file to the repo if you add or change no content
|
||||||
|
# binding
|
||||||
|
binding.ecowitt.name = <Your localized Binding name>
|
||||||
|
binding.ecowitt.description = <Your localized Binding description>
|
||||||
|
|
||||||
|
# thing types
|
||||||
|
thing-type.ecowitt.sample.label = <Your localized Thing label>
|
||||||
|
thing-type.ecowitt.sample.description = <Your localized Thing description>
|
||||||
|
|
||||||
|
# thing type config description
|
||||||
|
thing-type.config.ecowitt.sample.hostname.label = <Your localized config parameter label>
|
||||||
|
thing-type.config.ecowitt.sample.hostname.description = <Your localized config parameter description>
|
||||||
|
thing-type.config.ecowitt.sample.password.label = <Your localized config parameter label>
|
||||||
|
thing-type.config.ecowitt.sample.password.description = <Your localized config parameter description>
|
||||||
|
thing-type.config.ecowitt.sample.refreshInterval.label = <Your localized config parameter label>
|
||||||
|
thing-type.config.ecowitt.sample.refreshInterval.description = <Your localized config parameter description>
|
||||||
|
|
||||||
|
# channel types
|
||||||
|
channel-type.ecowitt.sample-channel.label = <Your localized Channel label>
|
||||||
|
channel-type.ecowitt.sample-channel.description = <Your localized Channel description>
|
|
@ -0,0 +1,46 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<thing:thing-descriptions bindingId="ecowitt"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xmlns:thing="https://openhab.org/schemas/thing-description/v1.0.0"
|
||||||
|
xsi:schemaLocation="https://openhab.org/schemas/thing-description/v1.0.0 https://openhab.org/schemas/thing-description-1.0.0.xsd">
|
||||||
|
|
||||||
|
<!-- Sample Thing Type -->
|
||||||
|
<thing-type id="sample">
|
||||||
|
<!-- Comment this in for Things which need a Bridge to function.
|
||||||
|
<supported-bridge-type-refs>
|
||||||
|
<bridge-type-ref id="ecowittBridge" />
|
||||||
|
</supported-bridge-type-refs>
|
||||||
|
-->
|
||||||
|
|
||||||
|
<label>ecowitt Binding Thing</label>
|
||||||
|
<description>Sample thing for ecowitt Binding</description>
|
||||||
|
|
||||||
|
<channels>
|
||||||
|
<channel id="channel1" typeId="sample-channel"/>
|
||||||
|
</channels>
|
||||||
|
|
||||||
|
<config-description>
|
||||||
|
<parameter name="hostname" type="text" required="true">
|
||||||
|
<context>network-address</context>
|
||||||
|
<label>Hostname</label>
|
||||||
|
<description>Hostname or IP address of the device</description>
|
||||||
|
</parameter>
|
||||||
|
<parameter name="password" type="text" required="true">
|
||||||
|
<context>password</context>
|
||||||
|
<label>Password</label>
|
||||||
|
<description>Passwort to access the device</description>
|
||||||
|
</parameter>
|
||||||
|
<parameter name="refreshInterval" type="integer" unit="s" min="1">
|
||||||
|
<label>Refresh Interval</label>
|
||||||
|
<description>Interval the device is polled in sec.</description>
|
||||||
|
</parameter>
|
||||||
|
</config-description>
|
||||||
|
</thing-type>
|
||||||
|
|
||||||
|
<!-- Sample Channel Type -->
|
||||||
|
<channel-type id="sample-channel">
|
||||||
|
<item-type>Number:Temperature</item-type>
|
||||||
|
<label>Example Temperature</label><!-- Use uppercase words, except prepositions. 2-3 words, max 25 chars -->
|
||||||
|
<description>Sample channel for ecowitt Binding</description>
|
||||||
|
</channel-type>
|
||||||
|
</thing:thing-descriptions>
|
|
@ -120,6 +120,7 @@
|
||||||
<module>org.openhab.binding.ecotouch</module>
|
<module>org.openhab.binding.ecotouch</module>
|
||||||
<module>org.openhab.binding.ecovacs</module>
|
<module>org.openhab.binding.ecovacs</module>
|
||||||
<module>org.openhab.binding.ecowatt</module>
|
<module>org.openhab.binding.ecowatt</module>
|
||||||
|
<module>org.openhab.binding.ecowitt</module>
|
||||||
<module>org.openhab.binding.ekey</module>
|
<module>org.openhab.binding.ekey</module>
|
||||||
<module>org.openhab.binding.electroluxair</module>
|
<module>org.openhab.binding.electroluxair</module>
|
||||||
<module>org.openhab.binding.elerotransmitterstick</module>
|
<module>org.openhab.binding.elerotransmitterstick</module>
|
||||||
|
|
Loading…
Reference in New Issue