initial commit for mediala aio gateway
This commit is contained in:
parent
d434fc5e4e
commit
9649f64da8
|
@ -197,6 +197,7 @@
|
|||
/bundles/org.openhab.binding.mcp23017/ @aogorek
|
||||
/bundles/org.openhab.binding.meater/ @jannegpriv
|
||||
/bundles/org.openhab.binding.mecmeter/ @kaikreuzer
|
||||
/bundles/org.openhab.binding.mediolaaiogateway/ @Av3m
|
||||
/bundles/org.openhab.binding.melcloud/ @lucacalcaterra @paulianttila @thewiep
|
||||
/bundles/org.openhab.binding.mercedesme/ @weymann
|
||||
/bundles/org.openhab.binding.meteoalerte/ @clinique
|
||||
|
|
|
@ -976,6 +976,11 @@
|
|||
<artifactId>org.openhab.binding.mecmeter</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.openhab.addons.bundles</groupId>
|
||||
<artifactId>org.openhab.binding.mediolaaiogateway</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.openhab.addons.bundles</groupId>
|
||||
<artifactId>org.openhab.binding.melcloud</artifactId>
|
||||
|
|
|
@ -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 @@
|
|||
# MediolaAioGateway 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 MediolaAioGateway Binding
|
||||
#
|
||||
# Default secret key for the pairing of the MediolaAioGateway 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.mediolaaiogateway</artifactId>
|
||||
|
||||
<name>openHAB Add-ons :: Bundles :: MediolaAioGateway Binding</name>
|
||||
|
||||
</project>
|
|
@ -0,0 +1,9 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<features name="org.openhab.binding.mediolaaiogateway-${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-mediolaaiogateway" description="MediolaAioGateway Binding" version="${project.version}">
|
||||
<feature>openhab-runtime-base</feature>
|
||||
<bundle start-level="80">mvn:org.openhab.addons.bundles/org.openhab.binding.mediolaaiogateway/${project.version}</bundle>
|
||||
</feature>
|
||||
</features>
|
|
@ -0,0 +1,34 @@
|
|||
/**
|
||||
* Copyright (c) 2010-2021 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.mediolaaiogateway.internal;
|
||||
|
||||
import org.eclipse.jdt.annotation.NonNullByDefault;
|
||||
import org.openhab.core.thing.ThingTypeUID;
|
||||
|
||||
/**
|
||||
* The {@link MediolaAioGatewayBindingConstants} class defines common constants, which are
|
||||
* used across the whole binding.
|
||||
*
|
||||
* @author Av3m - Initial contribution
|
||||
*/
|
||||
@NonNullByDefault
|
||||
public class MediolaAioGatewayBindingConstants {
|
||||
|
||||
private static final String BINDING_ID = "mediolaaiogateway";
|
||||
|
||||
// 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-2021 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.mediolaaiogateway.internal;
|
||||
|
||||
/**
|
||||
* The {@link MediolaAioGatewayConfiguration} class contains fields mapping thing configuration parameters.
|
||||
*
|
||||
* @author Av3m - Initial contribution
|
||||
*/
|
||||
public class MediolaAioGatewayConfiguration {
|
||||
|
||||
/**
|
||||
* Sample configuration parameters. Replace with your own.
|
||||
*/
|
||||
public String hostname;
|
||||
public String password;
|
||||
public int refreshInterval;
|
||||
}
|
|
@ -0,0 +1,100 @@
|
|||
/**
|
||||
* Copyright (c) 2010-2021 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.mediolaaiogateway.internal;
|
||||
|
||||
import static org.openhab.binding.mediolaaiogateway.internal.MediolaAioGatewayBindingConstants.*;
|
||||
|
||||
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 MediolaAioGatewayHandler} is responsible for handling commands, which are
|
||||
* sent to one of the channels.
|
||||
*
|
||||
* @author Av3m - Initial contribution
|
||||
*/
|
||||
@NonNullByDefault
|
||||
public class MediolaAioGatewayHandler extends BaseThingHandler {
|
||||
|
||||
private final Logger logger = LoggerFactory.getLogger(MediolaAioGatewayHandler.class);
|
||||
|
||||
private @Nullable MediolaAioGatewayConfiguration config;
|
||||
|
||||
public MediolaAioGatewayHandler(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(MediolaAioGatewayConfiguration.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-2021 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.mediolaaiogateway.internal;
|
||||
|
||||
import static org.openhab.binding.mediolaaiogateway.internal.MediolaAioGatewayBindingConstants.*;
|
||||
|
||||
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 MediolaAioGatewayHandlerFactory} is responsible for creating things and thing
|
||||
* handlers.
|
||||
*
|
||||
* @author Av3m - Initial contribution
|
||||
*/
|
||||
@NonNullByDefault
|
||||
@Component(configurationPid = "binding.mediolaaiogateway", service = ThingHandlerFactory.class)
|
||||
public class MediolaAioGatewayHandlerFactory 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 MediolaAioGatewayHandler(thing);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,9 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<binding:binding id="mediolaaiogateway" 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>MediolaAioGateway Binding</name>
|
||||
<description>This is the binding for MediolaAioGateway.</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.mediolaaiogateway.name = <Your localized Binding name>
|
||||
binding.mediolaaiogateway.description = <Your localized Binding description>
|
||||
|
||||
# thing types
|
||||
thing-type.mediolaaiogateway.sample.label = <Your localized Thing label>
|
||||
thing-type.mediolaaiogateway.sample.description = <Your localized Thing description>
|
||||
|
||||
# thing type config description
|
||||
thing-type.config.mediolaaiogateway.sample.hostname.label = <Your localized config parameter label>
|
||||
thing-type.config.mediolaaiogateway.sample.hostname.description = <Your localized config parameter description>
|
||||
thing-type.config.mediolaaiogateway.sample.password.label = <Your localized config parameter label>
|
||||
thing-type.config.mediolaaiogateway.sample.password.description = <Your localized config parameter description>
|
||||
thing-type.config.mediolaaiogateway.sample.refreshInterval.label = <Your localized config parameter label>
|
||||
thing-type.config.mediolaaiogateway.sample.refreshInterval.description = <Your localized config parameter description>
|
||||
|
||||
# channel types
|
||||
channel-type.mediolaaiogateway.sample-channel.label = <Your localized Channel label>
|
||||
channel-type.mediolaaiogateway.sample-channel.description = <Your localized Channel description>
|
|
@ -0,0 +1,46 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<thing:thing-descriptions bindingId="mediolaaiogateway"
|
||||
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="MediolaAioGatewayBridge" />
|
||||
</supported-bridge-type-refs>
|
||||
-->
|
||||
|
||||
<label>MediolaAioGateway Binding Thing</label>
|
||||
<description>Sample thing for MediolaAioGateway 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 MediolaAioGateway Binding</description>
|
||||
</channel-type>
|
||||
</thing:thing-descriptions>
|
Loading…
Reference in New Issue