Skip to content

Commit

Permalink
[generacmobilelink| Initial Contribution (openhab#9322)
Browse files Browse the repository at this point in the history
* This is the initial contribution of the Generac MobileLink binding.  This allows the  Generac line of generators using their MobileLink cloud service to be monitored as things in openHAB.
* bump to 3.1

Signed-off-by: Dan Cunningham <[email protected]>
  • Loading branch information
digitaldan authored Dec 28, 2020
1 parent 4e79d39 commit 7c5947b
Show file tree
Hide file tree
Showing 21 changed files with 1,024 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 @@ -80,6 +80,7 @@
/bundles/org.openhab.binding.ftpupload/ @paulianttila
/bundles/org.openhab.binding.gardena/ @gerrieg
/bundles/org.openhab.binding.gce/ @clinique
/bundles/org.openhab.binding.generacmobilelink/ @digitaldan
/bundles/org.openhab.binding.globalcache/ @mhilbush
/bundles/org.openhab.binding.goecharger/ @SamuelBrucksch
/bundles/org.openhab.binding.gpstracker/ @gbicskei
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 @@ -386,6 +386,11 @@
<artifactId>org.openhab.binding.gce</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.openhab.addons.bundles</groupId>
<artifactId>org.openhab.binding.generacmobilelink</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.openhab.addons.bundles</groupId>
<artifactId>org.openhab.binding.globalcache</artifactId>
Expand Down
13 changes: 13 additions & 0 deletions bundles/org.openhab.binding.generacmobilelink/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
95 changes: 95 additions & 0 deletions bundles/org.openhab.binding.generacmobilelink/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
# Generac MobileLink Binding

This binding communicates with the Generac MobileLink API and reports on the status of Generac manufactured generators, including versions resold under the brands Eaton, Honeywell and Siemens.

## Supported Things


### MobileLink Account

A MobileLink account bridge thing represents a user's MobileLink account and is responsible for authentication and polling for updates.

ThingTypeUID: `account`

### Generator

A Generator thing represents a individual generator linked to an account bridge. Multiple generators are supported.

ThingTypeUID: `generator`

## Discovery

The MobileLink account bridge must be added manually. Once added, generator things will automatically be added to the inbox.

## Thing Configuration

### MobileLink Account

| Parameter | Description |
|-----------------|------------------------------------------------------------------------------------|
| username | The user name, typically an email address, used to login to the MobileLink service |
| password | The password used to login to the MobileLink service |
| refreshInterval | The frequency to poll for generator updates, minimum duration is 30 seconds |


## Channels

### Generator Channels

All channels are read-only.

| channel | type | description |
|-------------------------|----------------------|-------------------------------------------|
| connected | Switch | Connected status |
| greenLight | Switch | Green light state (typically auto mode) |
| yellowLight | Switch | Yellow light state |
| redLight | Switch | Red light state (typically off mode) |
| blueLight | Switch | Blue light state (typically running mode) |
| statusDate | DateTime | Status date (start of day) |
| status | String | General status |
| currentAlarmDescription | String | Current alarm description |
| runHours | Number:Time | Number of run hours |
| exerciseHours | Number:Time | Number of exercise hours |
| fuelType | Number | Fuel type |
| fuelLevel | Number:Dimensionless | Fuel level |
| batteryVoltage | String | Battery voltage status |
| serviceStatus | Switch | Service status |


## Full Example

### Things

```xtend
Bridge generacmobilelink:account:main "MobileLink Account" [ userName="[email protected]", password="secret",refreshInterval=60 ] {
Thing generator 123456 "MobileLink Generator" [ generatorId="123456" ]
}
```

### Items

```xtend
Switch GeneratorConnected "Connected [%s]" {channel="generacmobilelink:generator:main:123456:connected"}
Switch GeneratorGreenLight "Green Light [%s]" {channel="generacmobilelink:generator:main:123456:greenLight"}
Switch GeneratorYellowLight "Yellow Light [%s]" {channel="generacmobilelink:generator:main:123456:yellowLight"}
Switch GeneratorBlueLight "Blue Light [%s]" {channel="generacmobilelink:generator:main:123456:blueLight"}
Switch GeneratorRedLight "Red Light [%s]" {channel="generacmobilelink:generator:main:123456:redLight"}
String GeneratorStatus "Status [%s]" {channel="generacmobilelink:generator:main:123456:status"}
String GeneratorAlarm "Alarm [%s]" {channel="generacmobilelink:generator:main:123456:currentAlarmDescription"}
```

### Sitemap

```xtend
sitemap MobileLink label="Demo Sitemap" {
Frame label="Generator" {
Switch item=GeneratorConnected
Switch item=GeneratorGreenLight
Switch item=GeneratorYellowLight
Switch item=GeneratorBlueLight
Switch item=GeneratorRedLight
Text item=GeneratorStatus
Text item=GeneratorAlarm
}
}
```
17 changes: 17 additions & 0 deletions bundles/org.openhab.binding.generacmobilelink/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.1.0-SNAPSHOT</version>
</parent>

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

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

</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
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
-->
<features name="org.openhab.binding.generacmobilelink-${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-generacmobilelink" description="Generac MobileLink Binding" version="${project.version}">
<feature>openhab-runtime-base</feature>
<bundle start-level="80">mvn:org.openhab.addons.bundles/org.openhab.binding.generacmobilelink/${project.version}</bundle>
</feature>
</features>
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.generacmobilelink.internal;

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

/**
* The {@link GeneracMobileLinkBindingConstants} class defines common constants, which are
* used across the whole binding.
*
* @author Dan Cunningham - Initial contribution
*/
@NonNullByDefault
public class GeneracMobileLinkBindingConstants {
private static final String BINDING_ID = "generacmobilelink";
public static final ThingTypeUID THING_TYPE_ACCOUNT = new ThingTypeUID(BINDING_ID, "account");
public static final ThingTypeUID THING_TYPE_GENERATOR = new ThingTypeUID(BINDING_ID, "generator");
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/**
* 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.generacmobilelink.internal.config;

import org.eclipse.jdt.annotation.NonNullByDefault;

/**
* The {@link GeneracMobileLinkAccountConfiguration} class contains fields mapping thing configuration parameters.
*
* @author Dan Cunningham - Initial contribution
*/
@NonNullByDefault
public class GeneracMobileLinkAccountConfiguration {
public String username = "";
public String password = "";
public Integer refreshInterval = 60;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
/**
* 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.generacmobilelink.internal.discovery;

import static org.openhab.binding.generacmobilelink.internal.GeneracMobileLinkBindingConstants.THING_TYPE_GENERATOR;

import java.util.Set;

import org.eclipse.jdt.annotation.NonNullByDefault;
import org.openhab.binding.generacmobilelink.internal.GeneracMobileLinkBindingConstants;
import org.openhab.binding.generacmobilelink.internal.dto.GeneratorStatusDTO;
import org.openhab.core.config.discovery.AbstractDiscoveryService;
import org.openhab.core.config.discovery.DiscoveryResult;
import org.openhab.core.config.discovery.DiscoveryResultBuilder;
import org.openhab.core.thing.ThingTypeUID;
import org.openhab.core.thing.ThingUID;

/**
* The {@link GeneracMobileLinkDiscoveryService} is responsible for discovering generator things
*
* @author Dan Cunningham - Initial contribution
*/
@NonNullByDefault
public class GeneracMobileLinkDiscoveryService extends AbstractDiscoveryService {
private static final Set<ThingTypeUID> SUPPORTED_DISCOVERY_THING_TYPES_UIDS = Set.of(THING_TYPE_GENERATOR);

public GeneracMobileLinkDiscoveryService() {
super(SUPPORTED_DISCOVERY_THING_TYPES_UIDS, 0);
}

@Override
public Set<ThingTypeUID> getSupportedThingTypes() {
return SUPPORTED_DISCOVERY_THING_TYPES_UIDS;
}

@Override
public void startScan() {
}

@Override
public boolean isBackgroundDiscoveryEnabled() {
return false;
}

public void generatorDiscovered(GeneratorStatusDTO generator, ThingUID bridgeUID) {
DiscoveryResult result = DiscoveryResultBuilder
.create(new ThingUID(GeneracMobileLinkBindingConstants.THING_TYPE_GENERATOR, bridgeUID,
String.valueOf(generator.gensetID)))
.withLabel("MobileLink Generator " + generator.generatorName)
.withProperty("generatorId", String.valueOf(generator.gensetID))
.withRepresentationProperty("generatorId").withBridge(bridgeUID).build();
thingDiscovered(result);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/**
* 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.generacmobilelink.internal.dto;

/**
* {@link ErrorResponseDTO} object from the MobileLink API
*
* @author Dan Cunningham - Initial contribution
*/
public class ErrorResponseDTO {
public Integer errorCode;
public String errorMessage;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
/**
* 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.generacmobilelink.internal.dto;

/**
* {@link GeneratorStatusDTO} object from the MobileLink API
*
* @author Dan Cunningham - Initial contribution
*/
public class GeneratorStatusDTO {
public Integer gensetID;
public String generatorDate;
public String generatorName;
public String generatorSerialNumber;
public String generatorModel;
public String generatorDescription;
public String generatorMDN;
public String generatorImei;
public String generatorIccid;
public String generatorTetherSerial;
public Boolean connected;
public Boolean greenLightLit;
public Boolean yellowLightLit;
public Boolean redLightLit;
public Boolean blueLightLit;
public String generatorStatus;
public String generatorStatusDate;
public String currentAlarmDescription;
public Integer runHours;
public Integer exerciseHours;
public String batteryVoltage;
public Integer fuelType;
public Integer fuelLevel;
public String generatorBrandImageURL;
public Boolean generatorServiceStatus;
public String signalStrength;
public String deviceId;
public Integer deviceTypeId;
public String firmwareVersion;
public String timezone;
public String mACAddress;
public String iPAddress;
public String sSID;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/**
* 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.generacmobilelink.internal.dto;

import java.util.ArrayList;

/**
* {@link GeneratorStatusResponseDTO} response from the MobileLink API
*
* @author Dan Cunningham - Initial contribution
*/
@SuppressWarnings("serial")
public class GeneratorStatusResponseDTO extends ArrayList<GeneratorStatusDTO> {

}
Loading

0 comments on commit 7c5947b

Please sign in to comment.