Skip to content
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

[intellicenter2] Initial contribution #13334

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CODEOWNERS
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@
/bundles/org.openhab.binding.icloud/ @openhab/add-ons-maintainers
/bundles/org.openhab.binding.ihc/ @paulianttila
/bundles/org.openhab.binding.insteon/ @jsetton
/bundles/org.openhab.binding.intellicenter2/ @valdisrigdon
/bundles/org.openhab.binding.intesis/ @hmerk
/bundles/org.openhab.binding.iotawatt/ @PRosenb
/bundles/org.openhab.binding.ipcamera/ @Skinah
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 @@ -841,6 +841,11 @@
<artifactId>org.openhab.binding.insteon</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.openhab.addons.bundles</groupId>
<artifactId>org.openhab.binding.intellicenter2</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.openhab.addons.bundles</groupId>
<artifactId>org.openhab.binding.intesis</artifactId>
Expand Down
13 changes: 13 additions & 0 deletions bundles/org.openhab.binding.intellicenter2/NOTICE
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
76 changes: 76 additions & 0 deletions bundles/org.openhab.binding.intellicenter2/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
# IntelliCenter2 Binding

_Give some details about what this binding is meant for - a protocol, system, specific device._

_If possible, provide some resources like pictures (only PNG is supported currently), 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._

_Put each sentence in a separate line to improve readability of diffs._

## Supported Things

_Please describe the different supported things / devices including their ThingTypeUID 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._

- `bridge`: Short description of the Bridge, if any
- `sample`: Short description of the Thing with the ThingTypeUID `sample`

## 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 IntelliCenter2 Binding
#
# Default secret key for the pairing of the IntelliCenter2 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._

_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._

### `sample` Thing Configuration

| Name | Type | Description | Default | Required | Advanced |
|-----------------|---------|---------------------------------------|---------|----------|----------|
| hostname | text | Hostname or IP address of the device | N/A | yes | no |
| password | text | Password to access the device | N/A | yes | no |
| refreshInterval | integer | Interval the device is polled in sec. | 600 | no | yes |

## 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 | Read/Write | Description |
|---------|--------|------------|-----------------------------|
| control | Switch | RW | This is the control channel |

## Full Example

_Provide a full usage example based on textual configuration files._
_*.things, *.items examples are mandatory as textual configuration is well used by many users._
_*.sitemap examples are optional._

## Any custom content here!

_Feel free to add additional sections for whatever you think should also be mentioned about your binding!_
Comment on lines +3 to +76
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please document the binding in this file.

25 changes: 25 additions & 0 deletions bundles/org.openhab.binding.intellicenter2/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?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 https://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>4.3.0-SNAPSHOT</version>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
<version>4.3.0-SNAPSHOT</version>
<version>5.0.0-SNAPSHOT</version>

</parent>

<artifactId>org.openhab.binding.intellicenter2</artifactId>

<name>openHAB Add-ons :: Bundles :: IntelliCenter2 Binding</name>

<dependencies>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>14.0.1</version>
<scope>provided</scope>
</dependency>
</dependencies>

</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<features name="org.openhab.binding.intellicenter2-${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-intellicenter2" description="IntelliCenter2 Binding" version="${project.version}">
<feature>openhab-runtime-base</feature>
<bundle start-level="80">mvn:org.openhab.addons.bundles/org.openhab.binding.intellicenter2/${project.version}</bundle>
</feature>
</features>
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
/**
* Copyright (c) 2010-2024 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.intellicenter2.internal;

import org.eclipse.jdt.annotation.NonNullByDefault;
import org.openhab.core.thing.ThingTypeUID;

/**
* The {@link IntelliCenter2BindingConstants} class defines common constants, which are
* used across the whole binding.
*
* @author Valdis Rigdon - Initial contribution
*/
@NonNullByDefault
public class IntelliCenter2BindingConstants {

private static final String BINDING_ID = "intellicenter2";

// List of all Thing Type UIDs
public static final ThingTypeUID THING_TYPE_POOL = new ThingTypeUID(BINDING_ID, "pool");
public static final ThingTypeUID THING_TYPE_FEATURE = new ThingTypeUID(BINDING_ID, "feature");
public static final ThingTypeUID THING_TYPE_LIGHT = new ThingTypeUID(BINDING_ID, "light");
public static final ThingTypeUID THING_TYPE_PUMP = new ThingTypeUID(BINDING_ID, "pump");
public static final ThingTypeUID THING_TYPE_SENSOR = new ThingTypeUID(BINDING_ID, "sensor");
public static final ThingTypeUID BRIDGE_TYPE_BRIDGE = new ThingTypeUID(BINDING_ID, "bridge");

// List of all Channel ids
public static final String CHANNEL_CURRENT_TEMPERATURE = "current-temperature";
public static final String CHANNEL_TARGET_TEMPERATURE = "target-temperature";
public static final String CHANNEL_HEATER_STATUS = "heater-status";
public static final String CHANNEL_FEATURE_ON_OFF = "feature-on-off";
public static final String CHANNEL_LIGHT_COLOR = "light-color";
public static final String CHANNEL_LIGHT_POWER = "light-power";
public static final String CHANNEL_PUMP_GPM = "pump-gpm";
public static final String CHANNEL_PUMP_RPM = "pump-rpm";
public static final String CHANNEL_PUMP_POWER = "pump-power";
public static final String CHANNEL_SENSOR_PROBE = "sensor-probe";
public static final String CHANNEL_SENSOR_SOURCE = "sensor-source";
public static final String CHANNEL_SENSOR_CALIB = "sensor-calib";
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/**
* Copyright (c) 2010-2024 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
*/
/**

* Copyright (c) 2010-2024 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.intellicenter2.internal;

import org.eclipse.jdt.annotation.NonNullByDefault;

/**
* The {@link IntelliCenter2Configuration} class contains fields mapping thing configuration parameters.
*
* @author Valdis Rigdon - Initial contribution
*/
@NonNullByDefault
public class IntelliCenter2Configuration {

public String hostname = "";
public int port = 6681;

@Override
public String toString() {
return getClass().getSimpleName() + "{hostname=" + hostname + ", port=" + port + "}";
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
/**
* Copyright (c) 2010-2024 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.intellicenter2.internal;

import static org.openhab.binding.intellicenter2.internal.IntelliCenter2BindingConstants.BRIDGE_TYPE_BRIDGE;
import static org.openhab.binding.intellicenter2.internal.IntelliCenter2BindingConstants.THING_TYPE_FEATURE;
import static org.openhab.binding.intellicenter2.internal.IntelliCenter2BindingConstants.THING_TYPE_LIGHT;
import static org.openhab.binding.intellicenter2.internal.IntelliCenter2BindingConstants.THING_TYPE_POOL;
import static org.openhab.binding.intellicenter2.internal.IntelliCenter2BindingConstants.THING_TYPE_PUMP;
import static org.openhab.binding.intellicenter2.internal.IntelliCenter2BindingConstants.THING_TYPE_SENSOR;

import java.util.Set;

import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.jdt.annotation.Nullable;
import org.openhab.binding.intellicenter2.internal.handler.IntelliCenter2BridgeHandler;
import org.openhab.binding.intellicenter2.internal.handler.IntelliCenter2FeatureHandler;
import org.openhab.binding.intellicenter2.internal.handler.IntelliCenter2LightHandler;
import org.openhab.binding.intellicenter2.internal.handler.IntelliCenter2PoolHandler;
import org.openhab.binding.intellicenter2.internal.handler.IntelliCenter2PumpHandler;
import org.openhab.binding.intellicenter2.internal.handler.IntelliCenter2SensorHandler;
import org.openhab.core.thing.Bridge;
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;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
* The {@link IntelliCenter2HandlerFactory} is responsible for creating things and thing
* handlers.
*
* @author Valdis Rigdon - Initial contribution
*/
@NonNullByDefault
@Component(configurationPid = "binding.intellicenter2", service = ThingHandlerFactory.class)
public class IntelliCenter2HandlerFactory extends BaseThingHandlerFactory {

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

public static final Set<ThingTypeUID> SUPPORTED_THING_TYPES_UIDS = Set.of(BRIDGE_TYPE_BRIDGE, THING_TYPE_POOL,
THING_TYPE_FEATURE, THING_TYPE_LIGHT, THING_TYPE_PUMP, THING_TYPE_SENSOR);

public IntelliCenter2HandlerFactory() {
super();
}

@Override
public boolean supportsThingType(ThingTypeUID thingTypeUID) {
return SUPPORTED_THING_TYPES_UIDS.contains(thingTypeUID);
}

@Override
protected @Nullable ThingHandler createHandler(Thing thing) {
final ThingTypeUID thingTypeUID = thing.getThingTypeUID();
logger.debug("Creating handler for {}", thingTypeUID);
if (thingTypeUID.equals(BRIDGE_TYPE_BRIDGE)) {
return new IntelliCenter2BridgeHandler((Bridge) thing);
} else if (thingTypeUID.equals(THING_TYPE_POOL)) {
return new IntelliCenter2PoolHandler(thing);
} else if (thingTypeUID.equals(THING_TYPE_FEATURE)) {
return new IntelliCenter2FeatureHandler(thing);
} else if (thingTypeUID.equals(THING_TYPE_LIGHT)) {
return new IntelliCenter2LightHandler(thing);
} else if (thingTypeUID.equals(THING_TYPE_PUMP)) {
return new IntelliCenter2PumpHandler(thing);
} else if (thingTypeUID.equals(THING_TYPE_SENSOR)) {
return new IntelliCenter2SensorHandler(thing);
}
logger.error("Unable to create handler for {}", thingTypeUID);
return null;
}
}
Loading