Skip to content

Commit 46aef12

Browse files
committed
3.4 backport of Generac 2.0 binding
Signed-off-by: Dan Cunningham <dan@digitaldan.com>
1 parent 3bab21f commit 46aef12

20 files changed

+771
-387
lines changed

bundles/org.openhab.binding.generacmobilelink/README.md

Lines changed: 50 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -36,22 +36,25 @@ The MobileLink account bridge must be added manually. Once added, generator thin
3636

3737
All channels are read-only.
3838

39-
| channel | type | description |
40-
|-------------------------|----------------------|-------------------------------------------|
41-
| connected | Switch | Connected status |
42-
| greenLight | Switch | Green light state (typically auto mode) |
43-
| yellowLight | Switch | Yellow light state |
44-
| redLight | Switch | Red light state (typically off mode) |
45-
| blueLight | Switch | Blue light state (typically running mode) |
46-
| statusDate | DateTime | Status date (start of day) |
47-
| status | String | General status |
48-
| currentAlarmDescription | String | Current alarm description |
49-
| runHours | Number:Time | Number of run hours |
50-
| exerciseHours | Number:Time | Number of exercise hours |
51-
| fuelType | Number | Fuel type |
52-
| fuelLevel | Number:Dimensionless | Fuel level |
53-
| batteryVoltage | String | Battery voltage status |
54-
| serviceStatus | Switch | Service status |
39+
| Channel ID | Item Type | Description |
40+
|----------------------|-----------------------------|-----------------------------------|
41+
| heroImageUrl | String | Hero Image URL |
42+
| statusLabel | String | Status Label |
43+
| statusText | String | Status Text |
44+
| activationDate | DateTime | Activation Date |
45+
| deviceSsid | String | Device SSID |
46+
| status | Number | Status |
47+
| isConnected | Switch | Is Connected |
48+
| isConnecting | Switch | Is Connecting |
49+
| showWarning | Switch | Show Warning |
50+
| hasMaintenanceAlert | Switch | Has Maintenance Alert |
51+
| lastSeen | DateTime | Last Seen |
52+
| connectionTime | DateTime | Connection Time |
53+
| runHours | Number:Time | Number of Hours Run |
54+
| batteryVoltage | Number:ElectricPotential | Battery Voltage |
55+
| hoursOfProtection | Number:Time | Number of Hours of Protection |
56+
| signalStrength | Number:Dimensionless | Signal Strength |
57+
5558

5659
## Full Example
5760

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

6871
```java
69-
Switch GeneratorConnected "Connected [%s]" {channel="generacmobilelink:generator:main:123456:connected"}
70-
Switch GeneratorGreenLight "Green Light [%s]" {channel="generacmobilelink:generator:main:123456:greenLight"}
71-
Switch GeneratorYellowLight "Yellow Light [%s]" {channel="generacmobilelink:generator:main:123456:yellowLight"}
72-
Switch GeneratorBlueLight "Blue Light [%s]" {channel="generacmobilelink:generator:main:123456:blueLight"}
73-
Switch GeneratorRedLight "Red Light [%s]" {channel="generacmobilelink:generator:main:123456:redLight"}
74-
String GeneratorStatus "Status [%s]" {channel="generacmobilelink:generator:main:123456:status"}
75-
String GeneratorAlarm "Alarm [%s]" {channel="generacmobilelink:generator:main:123456:currentAlarmDescription"}
72+
String GeneratorHeroImageUrl "Hero Image URL [%s]" { channel="generacmobilelink:generator:main:123456:heroImageUrl" }
73+
String GeneratorStatusLabel "Status Label [%s]" { channel="generacmobilelink:generator:main:123456:statusLabel" }
74+
String GeneratorStatusText "Status Text [%s]" { channel="generacmobilelink:generator:main:123456:statusText" }
75+
DateTime GeneratorActivationDate "Activation Date [%s]" { channel="generacmobilelink:generator:main:123456:activationDate" }
76+
String GeneratorDeviceSsid "Device SSID [%s]" { channel="generacmobilelink:generator:main:123456:deviceSsid" }
77+
Number GeneratorStatus "Status [%d]" { channel="generacmobilelink:generator:main:123456:status" }
78+
Switch GeneratorIsConnected "Is Connected [%s]" { channel="generacmobilelink:generator:main:123456:isConnected" }
79+
Switch GeneratorIsConnecting "Is Connecting [%s]" { channel="generacmobilelink:generator:main:123456:isConnecting" }
80+
Switch GeneratorShowWarning "Show Warning [%s]" { channel="generacmobilelink:generator:main:123456:showWarning" }
81+
Switch GeneratorHasMaintenanceAlert "Has Maintenance Alert [%s]" { channel="generacmobilelink:generator:main:123456:hasMaintenanceAlert" }
82+
DateTime GeneratorLastSeen "Last Seen [%s]" { channel="generacmobilelink:generator:main:123456:lastSeen" }
83+
DateTime GeneratorConnectionTime "Connection Time [%s]" { channel="generacmobilelink:generator:main:123456:connectionTime" }
84+
Number:Time GeneratorRunHours "Number of Hours Run [%d]" { channel="generacmobilelink:generator:main:123456:runHours" }
85+
Number:ElectricPotential GeneratorBatteryVoltage "Battery Voltage [%d]v" { channel="generacmobilelink:generator:main:123456:batteryVoltage" }
86+
Number:Time GeneratorHoursOfProtection "Number of Hours of Protection [%d]" { channel="generacmobilelink:generator:main:123456:hoursOfProtection" }
87+
Number:Dimensionless GeneratorSignalStrength "Signal Strength [%d]" { channel="generacmobilelink:generator:main:123456:signalStrength" }
88+
7689
```
7790

7891
### Sitemap
7992

8093
```perl
81-
sitemap MobileLink label="Demo Sitemap" {
82-
Frame label="Generator" {
83-
Switch item=GeneratorConnected
84-
Switch item=GeneratorGreenLight
85-
Switch item=GeneratorYellowLight
86-
Switch item=GeneratorBlueLight
87-
Switch item=GeneratorRedLight
88-
Text item=GeneratorStatus
89-
Text item=GeneratorAlarm
90-
}
94+
sitemap generacmobilelink label="Generac MobileLink"
95+
{
96+
Frame label="Generator Status" {
97+
Text item=GeneratorStatus
98+
Text item=GeneratorStatusLabel
99+
Text item=GeneratorStatusText
100+
}
101+
102+
Frame label="Generator Properties" {
103+
Text item=GeneratorRunHours
104+
Text item=GeneratorHoursOfProtection
105+
Text item=GeneratorBatteryVoltage
106+
Text item=GeneratorSignalStrength
107+
}
91108
}
92109
```

bundles/org.openhab.binding.generacmobilelink/pom.xml

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
<?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">
1+
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
24

35
<modelVersion>4.0.0</modelVersion>
46

@@ -12,4 +14,12 @@
1214

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

17+
<dependencies>
18+
<dependency>
19+
<groupId>org.jsoup</groupId>
20+
<artifactId>jsoup</artifactId>
21+
<version>1.14.3</version>
22+
<scope>provided</scope>
23+
</dependency>
24+
</dependencies>
1525
</project>

bundles/org.openhab.binding.generacmobilelink/src/main/feature/feature.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
<feature name="openhab-binding-generacmobilelink" description="Generac MobileLink Binding" version="${project.version}">
66
<feature>openhab-runtime-base</feature>
7+
<bundle dependency="true">mvn:org.jsoup/jsoup/1.14.3</bundle>
78
<bundle start-level="80">mvn:org.openhab.addons.bundles/org.openhab.binding.generacmobilelink/${project.version}</bundle>
89
</feature>
910
</features>
Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,17 @@
1010
*
1111
* SPDX-License-Identifier: EPL-2.0
1212
*/
13-
package org.openhab.binding.generacmobilelink.internal.dto;
13+
package org.openhab.binding.generacmobilelink.internal.config;
1414

15-
import java.util.ArrayList;
15+
import org.eclipse.jdt.annotation.NonNullByDefault;
1616

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

25+
public String generatorId = "";
2526
}

bundles/org.openhab.binding.generacmobilelink/src/main/java/org/openhab/binding/generacmobilelink/internal/discovery/GeneracMobileLinkDiscoveryService.java

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,15 @@
1818

1919
import org.eclipse.jdt.annotation.NonNullByDefault;
2020
import org.openhab.binding.generacmobilelink.internal.GeneracMobileLinkBindingConstants;
21-
import org.openhab.binding.generacmobilelink.internal.dto.GeneratorStatusDTO;
21+
import org.openhab.binding.generacmobilelink.internal.dto.Apparatus;
2222
import org.openhab.core.config.discovery.AbstractDiscoveryService;
2323
import org.openhab.core.config.discovery.DiscoveryResult;
2424
import org.openhab.core.config.discovery.DiscoveryResultBuilder;
2525
import org.openhab.core.thing.ThingTypeUID;
2626
import org.openhab.core.thing.ThingUID;
2727

2828
/**
29-
* The {@link GeneracMobileLinkDiscoveryService} is responsible for discovering generator things
29+
* The {@link GeneracMobileLinkDiscoveryService} is responsible for discovering device things
3030
*
3131
* @author Dan Cunningham - Initial contribution
3232
*/
@@ -52,12 +52,13 @@ public boolean isBackgroundDiscoveryEnabled() {
5252
return false;
5353
}
5454

55-
public void generatorDiscovered(GeneratorStatusDTO generator, ThingUID bridgeUID) {
55+
public void generatorDiscovered(Apparatus apparatus, ThingUID bridgeUID) {
5656
DiscoveryResult result = DiscoveryResultBuilder
5757
.create(new ThingUID(GeneracMobileLinkBindingConstants.THING_TYPE_GENERATOR, bridgeUID,
58-
String.valueOf(generator.gensetID)))
59-
.withLabel("MobileLink Generator " + generator.generatorName)
60-
.withProperty("generatorId", String.valueOf(generator.gensetID))
58+
String.valueOf(apparatus.apparatusId)))
59+
.withLabel("MobileLink Generator " + apparatus.name)
60+
.withProperty("serialNumber", String.valueOf(apparatus.serialNumber))
61+
.withProperty("generatorId", String.valueOf(apparatus.apparatusId))
6162
.withRepresentationProperty("generatorId").withBridge(bridgeUID).build();
6263
thingDiscovered(result);
6364
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
/**
2+
* Copyright (c) 2010-2022 Contributors to the openHAB project
3+
*
4+
* See the NOTICE file(s) distributed with this work for additional
5+
* information.
6+
*
7+
* This program and the accompanying materials are made available under the
8+
* terms of the Eclipse Public License 2.0 which is available at
9+
* http://www.eclipse.org/legal/epl-2.0
10+
*
11+
* SPDX-License-Identifier: EPL-2.0
12+
*/
13+
package org.openhab.binding.generacmobilelink.internal.dto;
14+
15+
/**
16+
* The {@link Account} represents a Generac Account
17+
*
18+
* @author Dan Cunningham - Initial contribution
19+
*/
20+
public class Account {
21+
public String userId;
22+
public String firstName;
23+
public String lastName;
24+
public String[] emails;
25+
public String[] phoneNumbers;
26+
public String[] groups;
27+
public MobileLinkSettings mobileLinkSettings;
28+
29+
public class MobileLinkSettings {
30+
public DisplaySettings displaySettings;
31+
32+
public class DisplaySettings {
33+
public String distanceUom;
34+
public String temperatureUom;
35+
}
36+
}
37+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
/**
2+
* Copyright (c) 2010-2022 Contributors to the openHAB project
3+
*
4+
* See the NOTICE file(s) distributed with this work for additional
5+
* information.
6+
*
7+
* This program and the accompanying materials are made available under the
8+
* terms of the Eclipse Public License 2.0 which is available at
9+
* http://www.eclipse.org/legal/epl-2.0
10+
*
11+
* SPDX-License-Identifier: EPL-2.0
12+
*/
13+
package org.openhab.binding.generacmobilelink.internal.dto;
14+
15+
import java.util.List;
16+
17+
/**
18+
* The {@link Apparatus} represents a Generac Apparatus (Generator)
19+
*
20+
* @author Dan Cunningham - Initial contribution
21+
*/
22+
public class Apparatus {
23+
public int apparatusId;
24+
public String serialNumber;
25+
public String name;
26+
public int type;
27+
public String localizedAddress;
28+
public String materialDescription;
29+
public String heroImageUrl;
30+
public int apparatusStatus;
31+
public boolean isConnected;
32+
public boolean isConnecting;
33+
public boolean showWarning;
34+
public Weather weather;
35+
public String preferredDealerName;
36+
public String preferredDealerPhone;
37+
public String preferredDealerEmail;
38+
public boolean isDealerManaged;
39+
public boolean isDealerUnmonitored;
40+
public String modelNumber;
41+
public String panelId;
42+
public List<Property> properties;
43+
44+
public class Weather {
45+
public Temperature temperature;
46+
public int iconCode;
47+
48+
public class Temperature {
49+
public double value;
50+
public String unit;
51+
public int unitType;
52+
}
53+
}
54+
55+
public class Property {
56+
public String name;
57+
public Value value;
58+
public int type;
59+
60+
public class Value {
61+
public int type;
62+
public String status;
63+
public boolean isLegacy;
64+
public boolean isDunning;
65+
public String deviceId;
66+
public String deviceType;
67+
public String signalStrength;
68+
public String batteryLevel;
69+
}
70+
}
71+
72+
public class Device {
73+
public String deviceId;
74+
public String deviceType;
75+
public String signalStrength;
76+
public String batteryLevel;
77+
public String status;
78+
}
79+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
/**
2+
* Copyright (c) 2010-2022 Contributors to the openHAB project
3+
*
4+
* See the NOTICE file(s) distributed with this work for additional
5+
* information.
6+
*
7+
* This program and the accompanying materials are made available under the
8+
* terms of the Eclipse Public License 2.0 which is available at
9+
* http://www.eclipse.org/legal/epl-2.0
10+
*
11+
* SPDX-License-Identifier: EPL-2.0
12+
*/
13+
package org.openhab.binding.generacmobilelink.internal.dto;
14+
15+
/**
16+
* The {@link ApparatusDetail} represents the details of a Generac Apparatus
17+
*
18+
* @author Dan Cunningham - Initial contribution
19+
*/
20+
public class ApparatusDetail {
21+
public int apparatusId;
22+
public String name;
23+
public String serialNumber;
24+
public int apparatusClassification;
25+
public String panelId;
26+
public String activationDate;
27+
public String deviceType;
28+
public String deviceSsid;
29+
public String shortDeviceId;
30+
public int apparatusStatus;
31+
public String heroImageUrl;
32+
public String statusLabel;
33+
public String statusText;
34+
public String eCodeLabel;
35+
public Weather weather;
36+
public boolean isConnected;
37+
public boolean isConnecting;
38+
public boolean showWarning;
39+
public boolean hasMaintenanceAlert;
40+
public String lastSeen;
41+
public String connectionTimestamp;
42+
public Address address;
43+
public Property[] properties;
44+
public Subscription subscription;
45+
public boolean enrolledInVpp;
46+
public boolean hasActiveVppEvent;
47+
public ProductInfo[] productInfo;
48+
public boolean hasDisconnectedNotificationsOn;
49+
50+
public class Weather {
51+
public Temperature temperature;
52+
public int iconCode;
53+
54+
public class Temperature {
55+
public double value;
56+
public String unit;
57+
public int unitType;
58+
}
59+
}
60+
61+
public class Address {
62+
public String line1;
63+
public String line2;
64+
public String city;
65+
public String region;
66+
public String country;
67+
public String postalCode;
68+
}
69+
70+
public class Property {
71+
public String name;
72+
public String value;
73+
public int type;
74+
}
75+
76+
public class Subscription {
77+
public int type;
78+
public int status;
79+
public boolean isLegacy;
80+
public boolean isDunning;
81+
}
82+
83+
public class ProductInfo {
84+
public String name;
85+
public String value;
86+
public int type;
87+
}
88+
}

0 commit comments

Comments
 (0)