Skip to content

Commit

Permalink
[sensibo] Sensibo Binding initial contribution (#5576)
Browse files Browse the repository at this point in the history
Signed-off-by: Arne Seime <arne.seime@gmail.com>
  • Loading branch information
seime authored Mar 30, 2020
1 parent 09ead9d commit 6485e5e
Show file tree
Hide file tree
Showing 70 changed files with 5,735 additions and 0 deletions.
1 change: 1 addition & 0 deletions CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@
/bundles/org.openhab.binding.satel/ @druciak
/bundles/org.openhab.binding.seneye/ @nikotanghe
/bundles/org.openhab.binding.sensebox/ @hakan42
/bundles/org.openhab.binding.sensibo/ @seime
/bundles/org.openhab.binding.serialbutton/ @kaikreuzer
/bundles/org.openhab.binding.shelly/ @markus7017
/bundles/org.openhab.binding.siemensrds/ @andrewfg
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 @@ -784,6 +784,11 @@
<artifactId>org.openhab.binding.sensebox</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.openhab.addons.bundles</groupId>
<artifactId>org.openhab.binding.sensibo</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.openhab.addons.bundles</groupId>
<artifactId>org.openhab.binding.serialbutton</artifactId>
Expand Down
13 changes: 13 additions & 0 deletions bundles/org.openhab.binding.sensibo/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/openhab2-addons
83 changes: 83 additions & 0 deletions bundles/org.openhab.binding.sensibo/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
# Sensibo Binding

This binding integrates the Sensibo Sky aircondition remote control
See https://www.sensibo.com/

## Supported Things

This binding supports Sensibo Sky only.

* `account` = Sensibo API - the account bridge
* `sensibosky` = Sensibo Sky remote control

## Discovery

In order to do discovery, add a thing of type Sensibo API and add the API key.
API key can be obtained here: https://home.sensibo.com/me/api

## Thing Configuration

See full example below for how to configure using thing files.

### Account

* `apiKey` = API key obtained here: https://home.sensibo.com/me/api
* `refreshInterval` = number of seconds between refresh calls to the server

### Sensibo Sky

* `macAddress` = network mac address of device.

Can be found printed on the back of the device
Or you can find it during discovery.

## Channels

### Sensibo Sky

| Channel | Read/write | Item type | Description |
| ------------------- | ------------- | --------------------- | ----------- |
| currentTemperature | R | Number:Temperature | Measured temperature |
| currentHumidity | R | Number:Dimensionless | Measured relative humidity, reported in percent |
| targetTemperature | R/W | Number:Temperature | Current target temperature for this room |
| masterSwitch | R/W | Switch | Switch AC ON or OFF |
| mode | R/W | String | Current mode (cool, heat, etc, actual modes provided provided by the API) being active |
| fanLevel | R/W | String | Current fan level (low, auto etc, actual levels provided provided by the API |
| swingMode | R/W | String | Current swing mode (actual modes provided provided by the API |
| timer | R/W | Number | Number of seconds until AC is switched off automatically. Setting to a value less than 60 seconds will cancel timer |

## Full Example

sensibo.things:

```
Bridge sensibo:account:home "Sensibo account" [apiKey="XYZASDASDAD", refreshInterval=120] {
Thing sensibosky office "Sensibo Sky Office" [ macAddress="001122334455" ]
}
```

sensibo.items:

```
Number:Temperature AC_Office_Room_Current_Temperature "Temperature [%.1f %unit%]" <temperature> {channel="sensibo:sensibosky:home:office:currentTemperature"}
Number:Dimensionless AC_Office_Room_Current_Humidity "Relative humidity [%.1f %%]" <humidity > {channel="sensibo:sensibosky:home:office:currentHumidity"}
Number:Temperature AC_Office_Room_Target_Temperature "Target temperature [%d %unit%]" <temperature> {channel="sensibo:sensibosky:home:office:targetTemperature"}
String AC_Office_Room_Mode "AC mode [%s]" {channel="sensibo:sensibosky:home:office:mode"}
String AC_Office_Room_Swing_Mode "AC swing mode [%s]" {channel="sensibo:sensibosky:home:office:swingMode"}
Switch AC_Office_Heater_MasterSwitch "AC power [%s]" <switch> {channel="sensibo:sensibosky:home:office:masterSwitch"}
String AC_Office_Heater_Fan_Level "Fan level [%s]" <fan> {channel="sensibo:sensibosky:home:office:fanLevel"}
Number AC_Office_Heater_Timer "Timer seconds [%d]" <timer> {channel="sensibo:sensibosky:home:office:timer"}
```

sitemap:

```
Switch item=AC_Office_Heater_MasterSwitch
Selection item=AC_Office_Room_Mode
Setpoint item=AC_Office_Room_Target_Temperature
Selection item=AC_Office_Heater_Fan_Level
Selection item=AC_Office_Room_Swing_Mode
Text item=AC_Office_Room_Current_Temperature
Text item=AC_Office_Room_Current_Humidity
```

26 changes: 26 additions & 0 deletions bundles/org.openhab.binding.sensibo/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?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/maven-v4_0_0.xsd">

<modelVersion>4.0.0</modelVersion>

<parent>
<groupId>org.openhab.addons.bundles</groupId>
<artifactId>org.openhab.addons.reactor.bundles</artifactId>
<version>2.5.4-SNAPSHOT</version>
</parent>

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

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

<dependencies>
<dependency>
<groupId>com.github.tomakehurst</groupId>
<artifactId>wiremock-standalone</artifactId>
<version>2.23.0</version>
<scope>test</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.sensibo-${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-sensibo" description="Sensibo Binding" version="${project.version}">
<feature>openhab-runtime-base</feature>
<bundle start-level="80">mvn:org.openhab.addons.bundles/org.openhab.binding.sensibo/${project.version}</bundle>
</feature>
</features>
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
/**
* Copyright (c) 2010-2020 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.sensibo.internal;

import java.util.Collection;
import java.util.Collections;
import java.util.Locale;

import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.jdt.annotation.Nullable;
import org.eclipse.smarthome.core.thing.binding.ThingHandler;
import org.eclipse.smarthome.core.thing.binding.ThingHandlerService;
import org.eclipse.smarthome.core.thing.type.ChannelGroupType;
import org.eclipse.smarthome.core.thing.type.ChannelGroupTypeUID;
import org.eclipse.smarthome.core.thing.type.ChannelType;
import org.eclipse.smarthome.core.thing.type.ChannelTypeProvider;
import org.eclipse.smarthome.core.thing.type.ChannelTypeUID;
import org.openhab.binding.sensibo.internal.handler.SensiboSkyHandler;

/**
* Channel Type Provider that does a callback the SensiboSkyHandler that initiated it.
*
* @author Arne Seime - Initial contribution
*/
@NonNullByDefault
public class CallbackChannelsTypeProvider implements ChannelTypeProvider, ThingHandlerService {
private @NonNullByDefault({}) SensiboSkyHandler handler;

@Override
public Collection<ChannelType> getChannelTypes(@Nullable final Locale locale) {
return handler.getChannelTypes(locale);
}

@Override
public @Nullable ChannelType getChannelType(final ChannelTypeUID channelTypeUID, @Nullable final Locale locale) {
return handler.getChannelType(channelTypeUID, locale);
}

@Override
public @Nullable ChannelGroupType getChannelGroupType(final ChannelGroupTypeUID channelGroupTypeUID,
@Nullable final Locale locale) {
return null;
}

@Override
public Collection<ChannelGroupType> getChannelGroupTypes(@Nullable final Locale locale) {
return Collections.emptyList();
}

@Override
public ThingHandler getThingHandler() {
return handler;
}

@NonNullByDefault({})
@Override
public void setThingHandler(final ThingHandler handler) {
this.handler = (SensiboSkyHandler) handler;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
/**
* Copyright (c) 2010-2020 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.sensibo.internal;

import java.util.Collections;
import java.util.Set;
import java.util.stream.Collectors;
import java.util.stream.Stream;

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

/**
* The {@link SensiboBindingConstants} class defines common constants, which are
* used across the whole binding.
*
* @author Arne Seime - Initial contribution
*/
@NonNullByDefault
public class SensiboBindingConstants {
public static final String BINDING_ID = "sensibo";
// List of all Thing Type UIDs
public static final ThingTypeUID THING_TYPE_ACCOUNT = new ThingTypeUID(BINDING_ID, "account");
public static final ThingTypeUID THING_TYPE_SENSIBOSKY = new ThingTypeUID(BINDING_ID, "sensibosky");
// Fixed channels
public static final String CHANNEL_CURRENT_TEMPERATURE = "currentTemperature";
public static final String CHANNEL_CURRENT_HUMIDITY = "currentHumidity";
public static final String CHANNEL_MASTER_SWITCH = "masterSwitch";
public static final String CHANNEL_TIMER = "timer";

// Dynamic channels
public static final String CHANNEL_FAN_LEVEL = "fanLevel";
public static final String CHANNEL_MODE = "mode";
public static final String CHANNEL_SWING_MODE = "swingMode";
public static final String CHANNEL_TARGET_TEMPERATURE = "targetTemperature";

public static final String CHANNEL_TYPE_FAN_LEVEL = "fanLevel";
public static final String CHANNEL_TYPE_MODE = "mode";
public static final String CHANNEL_TYPE_SWING_MODE = "swing";
public static final String CHANNEL_TYPE_TARGET_TEMPERATURE = "targetTemperature";

public static final Set<String> DYNAMIC_CHANNEL_TYPES = Collections.unmodifiableSet(Stream
.of(CHANNEL_TYPE_FAN_LEVEL, CHANNEL_TYPE_MODE, CHANNEL_TYPE_SWING_MODE, CHANNEL_TYPE_TARGET_TEMPERATURE)
.collect(Collectors.toSet()));
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/**
* Copyright (c) 2010-2020 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.sensibo.internal;

import org.eclipse.jdt.annotation.NonNullByDefault;
import org.openhab.binding.sensibo.internal.dto.AbstractRequest;

/**
* The {@link SensiboCommunicationException} class wraps exceptions raised when communicating with the API
*
* @author Arne Seime - Initial contribution
*/
@NonNullByDefault
public class SensiboCommunicationException extends SensiboException {
private static final long serialVersionUID = 1L;

public SensiboCommunicationException(final String message, final Throwable cause) {
super(message, cause);
}

public SensiboCommunicationException(final String message) {
super(message);
}

public SensiboCommunicationException(final AbstractRequest req, final String overallStatus) {
super("Server responded with error to request " + req.getClass().getSimpleName() + "/" + req.getRequestUrl()
+ ": " + overallStatus);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/**
* Copyright (c) 2010-2020 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.sensibo.internal;

import org.eclipse.jdt.annotation.NonNullByDefault;

/**
* The {@link SensiboConfigurationException} class wraps exceptions raised when due to configuration errors
*
* @author Arne Seime - Initial contribution
*/
@NonNullByDefault
public class SensiboConfigurationException extends SensiboException {
private static final long serialVersionUID = 1L;

public SensiboConfigurationException(final String message) {
super(message);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/**
* Copyright (c) 2010-2020 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.sensibo.internal;

import org.eclipse.jdt.annotation.NonNullByDefault;

/**
* The {@link SensiboException} class wraps exceptions raised when communicating with the API
*
* @author Arne Seime - Initial contribution
*/
@NonNullByDefault
public abstract class SensiboException extends Exception {

private static final long serialVersionUID = 1L;

public SensiboException(String message) {
super(message);
}

public SensiboException(String message, Throwable cause) {
super(message, cause);
}
}
Loading

0 comments on commit 6485e5e

Please sign in to comment.