Skip to content

Commit

Permalink
3.4 backport of Generac 2.0 binding
Browse files Browse the repository at this point in the history
Signed-off-by: Dan Cunningham <dan@digitaldan.com>
  • Loading branch information
digitaldan committed Mar 18, 2023
1 parent 3bab21f commit 46aef12
Show file tree
Hide file tree
Showing 20 changed files with 771 additions and 387 deletions.
83 changes: 50 additions & 33 deletions bundles/org.openhab.binding.generacmobilelink/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,22 +36,25 @@ The MobileLink account bridge must be added manually. Once added, generator thin

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 |
| Channel ID | Item Type | Description |
|----------------------|-----------------------------|-----------------------------------|
| heroImageUrl | String | Hero Image URL |
| statusLabel | String | Status Label |
| statusText | String | Status Text |
| activationDate | DateTime | Activation Date |
| deviceSsid | String | Device SSID |
| status | Number | Status |
| isConnected | Switch | Is Connected |
| isConnecting | Switch | Is Connecting |
| showWarning | Switch | Show Warning |
| hasMaintenanceAlert | Switch | Has Maintenance Alert |
| lastSeen | DateTime | Last Seen |
| connectionTime | DateTime | Connection Time |
| runHours | Number:Time | Number of Hours Run |
| batteryVoltage | Number:ElectricPotential | Battery Voltage |
| hoursOfProtection | Number:Time | Number of Hours of Protection |
| signalStrength | Number:Dimensionless | Signal Strength |


## Full Example

Expand All @@ -66,27 +69,41 @@ Bridge generacmobilelink:account:main "MobileLink Account" [ userName="foo@bar.c
### Items

```java
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"}
String GeneratorHeroImageUrl "Hero Image URL [%s]" { channel="generacmobilelink:generator:main:123456:heroImageUrl" }
String GeneratorStatusLabel "Status Label [%s]" { channel="generacmobilelink:generator:main:123456:statusLabel" }
String GeneratorStatusText "Status Text [%s]" { channel="generacmobilelink:generator:main:123456:statusText" }
DateTime GeneratorActivationDate "Activation Date [%s]" { channel="generacmobilelink:generator:main:123456:activationDate" }
String GeneratorDeviceSsid "Device SSID [%s]" { channel="generacmobilelink:generator:main:123456:deviceSsid" }
Number GeneratorStatus "Status [%d]" { channel="generacmobilelink:generator:main:123456:status" }
Switch GeneratorIsConnected "Is Connected [%s]" { channel="generacmobilelink:generator:main:123456:isConnected" }
Switch GeneratorIsConnecting "Is Connecting [%s]" { channel="generacmobilelink:generator:main:123456:isConnecting" }
Switch GeneratorShowWarning "Show Warning [%s]" { channel="generacmobilelink:generator:main:123456:showWarning" }
Switch GeneratorHasMaintenanceAlert "Has Maintenance Alert [%s]" { channel="generacmobilelink:generator:main:123456:hasMaintenanceAlert" }
DateTime GeneratorLastSeen "Last Seen [%s]" { channel="generacmobilelink:generator:main:123456:lastSeen" }
DateTime GeneratorConnectionTime "Connection Time [%s]" { channel="generacmobilelink:generator:main:123456:connectionTime" }
Number:Time GeneratorRunHours "Number of Hours Run [%d]" { channel="generacmobilelink:generator:main:123456:runHours" }
Number:ElectricPotential GeneratorBatteryVoltage "Battery Voltage [%d]v" { channel="generacmobilelink:generator:main:123456:batteryVoltage" }
Number:Time GeneratorHoursOfProtection "Number of Hours of Protection [%d]" { channel="generacmobilelink:generator:main:123456:hoursOfProtection" }
Number:Dimensionless GeneratorSignalStrength "Signal Strength [%d]" { channel="generacmobilelink:generator:main:123456:signalStrength" }

```

### Sitemap

```perl
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
}
sitemap generacmobilelink label="Generac MobileLink"
{
Frame label="Generator Status" {
Text item=GeneratorStatus
Text item=GeneratorStatusLabel
Text item=GeneratorStatusText
}

Frame label="Generator Properties" {
Text item=GeneratorRunHours
Text item=GeneratorHoursOfProtection
Text item=GeneratorBatteryVoltage
Text item=GeneratorSignalStrength
}
}
```
12 changes: 11 additions & 1 deletion bundles/org.openhab.binding.generacmobilelink/pom.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?><project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
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>

Expand All @@ -12,4 +14,12 @@

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

<dependencies>
<dependency>
<groupId>org.jsoup</groupId>
<artifactId>jsoup</artifactId>
<version>1.14.3</version>
<scope>provided</scope>
</dependency>
</dependencies>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

<feature name="openhab-binding-generacmobilelink" description="Generac MobileLink Binding" version="${project.version}">
<feature>openhab-runtime-base</feature>
<bundle dependency="true">mvn:org.jsoup/jsoup/1.14.3</bundle>
<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
Expand Up @@ -10,16 +10,17 @@
*
* SPDX-License-Identifier: EPL-2.0
*/
package org.openhab.binding.generacmobilelink.internal.dto;
package org.openhab.binding.generacmobilelink.internal.config;

import java.util.ArrayList;
import org.eclipse.jdt.annotation.NonNullByDefault;

/**
* {@link GeneratorStatusResponseDTO} response from the MobileLink API
* The {@link GeneracMobileLinkGeneratorConfiguration} class contains fields mapping thing configuration parameters.
*
* @author Dan Cunningham - Initial contribution
*/
@SuppressWarnings("serial")
public class GeneratorStatusResponseDTO extends ArrayList<GeneratorStatusDTO> {
@NonNullByDefault
public class GeneracMobileLinkGeneratorConfiguration {

public String generatorId = "";
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,15 @@

import org.eclipse.jdt.annotation.NonNullByDefault;
import org.openhab.binding.generacmobilelink.internal.GeneracMobileLinkBindingConstants;
import org.openhab.binding.generacmobilelink.internal.dto.GeneratorStatusDTO;
import org.openhab.binding.generacmobilelink.internal.dto.Apparatus;
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
* The {@link GeneracMobileLinkDiscoveryService} is responsible for discovering device things
*
* @author Dan Cunningham - Initial contribution
*/
Expand All @@ -52,12 +52,13 @@ public boolean isBackgroundDiscoveryEnabled() {
return false;
}

public void generatorDiscovered(GeneratorStatusDTO generator, ThingUID bridgeUID) {
public void generatorDiscovered(Apparatus apparatus, 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))
String.valueOf(apparatus.apparatusId)))
.withLabel("MobileLink Generator " + apparatus.name)
.withProperty("serialNumber", String.valueOf(apparatus.serialNumber))
.withProperty("generatorId", String.valueOf(apparatus.apparatusId))
.withRepresentationProperty("generatorId").withBridge(bridgeUID).build();
thingDiscovered(result);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/**
* 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.generacmobilelink.internal.dto;

/**
* The {@link Account} represents a Generac Account
*
* @author Dan Cunningham - Initial contribution
*/
public class Account {
public String userId;
public String firstName;
public String lastName;
public String[] emails;
public String[] phoneNumbers;
public String[] groups;
public MobileLinkSettings mobileLinkSettings;

public class MobileLinkSettings {
public DisplaySettings displaySettings;

public class DisplaySettings {
public String distanceUom;
public String temperatureUom;
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
/**
* 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.generacmobilelink.internal.dto;

import java.util.List;

/**
* The {@link Apparatus} represents a Generac Apparatus (Generator)
*
* @author Dan Cunningham - Initial contribution
*/
public class Apparatus {
public int apparatusId;
public String serialNumber;
public String name;
public int type;
public String localizedAddress;
public String materialDescription;
public String heroImageUrl;
public int apparatusStatus;
public boolean isConnected;
public boolean isConnecting;
public boolean showWarning;
public Weather weather;
public String preferredDealerName;
public String preferredDealerPhone;
public String preferredDealerEmail;
public boolean isDealerManaged;
public boolean isDealerUnmonitored;
public String modelNumber;
public String panelId;
public List<Property> properties;

public class Weather {
public Temperature temperature;
public int iconCode;

public class Temperature {
public double value;
public String unit;
public int unitType;
}
}

public class Property {
public String name;
public Value value;
public int type;

public class Value {
public int type;
public String status;
public boolean isLegacy;
public boolean isDunning;
public String deviceId;
public String deviceType;
public String signalStrength;
public String batteryLevel;
}
}

public class Device {
public String deviceId;
public String deviceType;
public String signalStrength;
public String batteryLevel;
public String status;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
/**
* 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.generacmobilelink.internal.dto;

/**
* The {@link ApparatusDetail} represents the details of a Generac Apparatus
*
* @author Dan Cunningham - Initial contribution
*/
public class ApparatusDetail {
public int apparatusId;
public String name;
public String serialNumber;
public int apparatusClassification;
public String panelId;
public String activationDate;
public String deviceType;
public String deviceSsid;
public String shortDeviceId;
public int apparatusStatus;
public String heroImageUrl;
public String statusLabel;
public String statusText;
public String eCodeLabel;
public Weather weather;
public boolean isConnected;
public boolean isConnecting;
public boolean showWarning;
public boolean hasMaintenanceAlert;
public String lastSeen;
public String connectionTimestamp;
public Address address;
public Property[] properties;
public Subscription subscription;
public boolean enrolledInVpp;
public boolean hasActiveVppEvent;
public ProductInfo[] productInfo;
public boolean hasDisconnectedNotificationsOn;

public class Weather {
public Temperature temperature;
public int iconCode;

public class Temperature {
public double value;
public String unit;
public int unitType;
}
}

public class Address {
public String line1;
public String line2;
public String city;
public String region;
public String country;
public String postalCode;
}

public class Property {
public String name;
public String value;
public int type;
}

public class Subscription {
public int type;
public int status;
public boolean isLegacy;
public boolean isDunning;
}

public class ProductInfo {
public String name;
public String value;
public int type;
}
}
Loading

0 comments on commit 46aef12

Please sign in to comment.