Skip to content

Commit

Permalink
[electroluxair] Initial contribution (openhab#11116)
Browse files Browse the repository at this point in the history
* [electroluxair] Initial contribution of the electroluxair openHAB binding

Signed-off-by: Jan Gustafsson <jannegpriv@gmail.com>

* Updated after code review.

Signed-off-by: Jan Gustafsson <jannegpriv@gmail.com>

* Updated after code review and also copyright to 2022.

Signed-off-by: Jan Gustafsson <jannegpriv@gmail.com>

* [electroluxair] Initial contribution of the electroluxair openHAB binding

Signed-off-by: Jan Gustafsson <jannegpriv@gmail.com>

* Updated after code review.

Signed-off-by: Jan Gustafsson <jannegpriv@gmail.com>

* Updated after code review

Signed-off-by: Jan Gustafsson <jannegpriv@gmail.com>
  • Loading branch information
jannegpriv authored and Nemer_Daud committed Jan 28, 2022
1 parent e27308b commit 61bbef9
Show file tree
Hide file tree
Showing 20 changed files with 1,917 additions and 0 deletions.
1 change: 1 addition & 0 deletions CODEOWNERS
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@
/bundles/org.openhab.binding.ecobee/ @mhilbush
/bundles/org.openhab.binding.ecotouch/ @sibbi77
/bundles/org.openhab.binding.ekey/ @hmerk
/bundles/org.openhab.binding.electroluxair/ @jannegpriv
/bundles/org.openhab.binding.elerotransmitterstick/ @vbier
/bundles/org.openhab.binding.energenie/ @hmerk
/bundles/org.openhab.binding.enigma2/ @gdolfen
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 @@ -391,6 +391,11 @@
<artifactId>org.openhab.binding.ekey</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.openhab.addons.bundles</groupId>
<artifactId>org.openhab.binding.electroluxair</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.openhab.addons.bundles</groupId>
<artifactId>org.openhab.binding.elerotransmitterstick</artifactId>
Expand Down
13 changes: 13 additions & 0 deletions bundles/org.openhab.binding.electroluxair/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
92 changes: 92 additions & 0 deletions bundles/org.openhab.binding.electroluxair/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
# ElectroluxAir Binding

This is an openHAB binding for the Pure A9 Air Purifier, by Electrolux.

This binding uses the Electrolux Delta REST API.

![Electrolux Pure A9](doc/electrolux_pure_a9.png)

## Supported Things

This binding supports the following thing types:

- api: Bridge - Implements the API that is used to communicate with the Air Purifier


- electroluxpurea9: The Pure A9 Air Purifier

## Discovery

After the configuration of the Bridge, your Electrolux Pure A9 device will be automatically discovered and placed as a thing in the inbox.


### Configuration Options

Only the bridge require manual configuration. The Electrolux Pure A9 thing can be added by hand, or you can let the discovery mechanism automatically find it.


#### Bridge

| Parameter | Description | Type | Default | Required |
|-----------|--------------------------------------------------------------|--------|----------|----------|
| username | The username used to connect to the Electrolux Wellbeing app | String | NA | yes |
| password | The password used to connect to the Electrolux Wellbeing app | String | NA | yes |
| refresh | Specifies the refresh interval in second | Number | 600 | yes |

#### Electrolux Pure A9

| Parameter | Description | Type | Default | Required |
|-----------|-------------------------------------------------------------------------|--------|----------|----------|
| deviceId | Product ID of your Electrolux Pure A9 found in Electrolux Wellbeing app | Number | NA | yes |


## Channels

### Electrolux Pure A9

The following channels are supported:

| Channel Type ID | Item Type | Description |
|-----------------------------|-----------------------|------------------------------------------------------------------------------|
| temperature | Number:Temperature | This channel reports the current temperature. |
| humidity | Number:Dimensionless | This channel reports the current humidity in percentage. |
| tvoc | Number:Density | This channel reports the total Volatile Organic Compounds in microgram/m3. |
| pm1 | Number:Dimensionless | This channel reports the Particulate Matter 1 in ppb. |
| pm2_5 | Number:Dimensionless | This channel reports the Particulate Matter 2.5 in ppb. |
| pm10 | Number:Dimensionless | This channel reports the Particulate Matter 10 in ppb. |
| co2 | Number:Dimensionless | This channel reports the CO2 level in ppm. |
| fanSpeed | Number | This channel sets and reports the current fan speed (1-9). |
| filterLife | Number:Dimensionless | This channel reports the remaining filter life in %. |
| ionizer | Switch | This channel sets and reports the status of the ionizer function (On/Off). |
| doorOpen | Contact | This channel reports the status of door (Opened/Closed). |
| workMode | String | This channel sets and reports the current work mode (Auto, Manual, PowerOff.)|


## Full Example

### Things-file

````
// Bridge configuration
Bridge electroluxair:api:myAPI "Electrolux Delta API" [username="user@password.com", password="12345", refresh="300"] {
Thing electroluxpurea9 myElectroluxPureA9 "Electrolux Pure A9" [ deviceId="123456789" ]
}
````

## Items-file

````
// CO2
Number ElectroluxAirCO2 "Electrolux Air CO2 [%d ppm]" {channel="electroluxair:electroluxpurea9:myAPI:MyElectroluxPureA9:co2"}
// Temperature
Number:Temperature ElectroluxAirTemperature "Electrolux Air Temperature" {channel="electroluxair:electroluxpurea9:myAPI:myElectroluxPureA9:temperature"}
// Door status
Contact ElectroluxAirDoor "Electrolux Air Door Status" {channel="electroluxair:electroluxpurea9:myAPI:myElectroluxPureA9:doorOpen"}
// Work mode
String ElectroluxAirWorkModeSetting "ElectroluxAir Work Mode Setting" {channel="electroluxair:electroluxpurea9:myAPI:myElectroluxPureA9:workMode"}
// Fan speed
Number ElectroluxAirFanSpeed "Electrolux Air Fan Speed Setting" {channel="electroluxair:electroluxpurea9:myAPI:myElectroluxPureA9:fanSpeed"}
````

Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
17 changes: 17 additions & 0 deletions bundles/org.openhab.binding.electroluxair/pom.xml
Original file line number Diff line number Diff line change
@@ -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.3.0-SNAPSHOT</version>
</parent>

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

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

</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.electroluxair-${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-electroluxair" description="ElectroluxAir Binding" version="${project.version}">
<feature>openhab-runtime-base</feature>
<bundle start-level="80">mvn:org.openhab.addons.bundles/org.openhab.binding.electroluxair/${project.version}</bundle>
</feature>
</features>
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
/**
* 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.electroluxair.internal;

import java.util.Set;

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

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

public static final String BINDING_ID = "electroluxair";

// List of all Thing Type UIDs
public static final ThingTypeUID THING_TYPE_ELECTROLUX_PURE_A9 = new ThingTypeUID(BINDING_ID, "electroluxpurea9");
public static final ThingTypeUID THING_TYPE_BRIDGE = new ThingTypeUID(BINDING_ID, "api");

// List of all Channel ids
public static final String CHANNEL_STATUS = "status";
public static final String CHANNEL_TEMPERATURE = "temperature";
public static final String CHANNEL_HUMIDITY = "humidity";
public static final String CHANNEL_TVOC = "tvoc";
public static final String CHANNEL_PM1 = "pm1";
public static final String CHANNEL_PM25 = "pm2_5";
public static final String CHANNEL_PM10 = "pm10";
public static final String CHANNEL_CO2 = "co2";
public static final String CHANNEL_FILTER_LIFE = "filterLife";
public static final String CHANNEL_DOOR_OPEN = "doorOpen";
public static final String CHANNEL_FAN_SPEED = "fanSpeed";
public static final String CHANNEL_WORK_MODE = "workMode";
public static final String CHANNEL_IONIZER = "ionizer";

// List of all Properties ids
public static final String PROPERTY_BRAND = "brand";
public static final String PROPERTY_COLOUR = "colour";
public static final String PROPERTY_MODEL = "model";
public static final String PROPERTY_DEVICE = "device";
public static final String PROPERTY_FW_VERSION = "fwVersion";
public static final String PROPERTY_SERIAL_NUMBER = "serialNumber";
public static final String PROPERTY_WORKMODE = "workmode";

// List of all Commands
public static final String COMMAND_WORKMODE_POWEROFF = "PowerOff";
public static final String COMMAND_WORKMODE_AUTO = "Auto";
public static final String COMMAND_WORKMODE_MANUAL = "Manual";

public static final Set<ThingTypeUID> SUPPORTED_THING_TYPES_UIDS = Set.of(THING_TYPE_BRIDGE,
THING_TYPE_ELECTROLUX_PURE_A9);
}
Original file line number Diff line number Diff line change
@@ -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.electroluxair.internal;

import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.jdt.annotation.Nullable;

/**
* The {@link ElectroluxAirBridgeConfiguration} class contains fields mapping bridge configuration parameters.
*
* @author Jan Gustafsson - Initial contribution
*/
@NonNullByDefault
public class ElectroluxAirBridgeConfiguration {
public @Nullable String username;
public @Nullable String password;
public int refresh;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/**
* 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.electroluxair.internal;

import org.eclipse.jdt.annotation.NonNullByDefault;

/**
* The {@link ElectroluxAirConfiguration} class contains fields mapping thing configuration parameters.
*
* @author Jan Gustafsson - Initial contribution
*/
@NonNullByDefault
public class ElectroluxAirConfiguration {
public static final String DEVICE_ID_LABEL = "deviceId";

private String deviceId = "";

public String getDeviceId() {
return deviceId;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
/**
* 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.electroluxair.internal;

import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.jdt.annotation.Nullable;

/**
* {@link ElectroluxAirException} is used when there is exception communicating with Electrolux Delta API.
*
* @author Jan Gustafsson - Initial contribution
*/
@NonNullByDefault
public class ElectroluxAirException extends Exception {

private static final long serialVersionUID = 2543564118231301159L;

public ElectroluxAirException(Exception source) {
super(source);
}

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

@Override
public @Nullable String getMessage() {
Throwable throwable = getCause();
if (throwable != null) {
String localMessage = throwable.getMessage();
if (localMessage != null) {
return localMessage;
}
}
return "";
}
}
Loading

0 comments on commit 61bbef9

Please sign in to comment.