public static final String CHANNELTYPE_SCENE_GROUP_ACTIVATE = "scene-group-activate";
public static final String CHANNELTYPE_AUTOMATION_ENABLED = "automation-enabled";
+ // Hub properties
+ public static final String PROPERTY_FIRMWARE_NAME = "firmwareName";
+ public static final String PROPERTY_RADIO_FIRMWARE_VERSION = "radioFirmwareVersion";
+
+ // Hub/shade properties
+ public static final String PROPERTY_FIRMWARE_VERSION = "firmwareVersion";
+
+ // Shade properties
public static final String PROPERTY_SHADE_TYPE = "type";
public static final String PROPERTY_SHADE_CAPABILITIES = "capabilities";
public static final String PROPERTY_SECONDARY_RAIL_DETECTED = "secondaryRailDetected";
public static final String PROPERTY_TILT_ANYWHERE_DETECTED = "tiltAnywhereDetected";
+ public static final String PROPERTY_MOTOR_FIRMWARE_VERSION = "motorFirmwareVersion";
public static final List<String> NETBIOS_NAMES = Arrays.asList("PDBU-Hub3.0", "PowerView-Hub");
import org.openhab.binding.hdpowerview.internal.api.ShadePosition;
import org.openhab.binding.hdpowerview.internal.api.requests.ShadeMove;
import org.openhab.binding.hdpowerview.internal.api.requests.ShadeStop;
+import org.openhab.binding.hdpowerview.internal.api.responses.FirmwareVersion;
import org.openhab.binding.hdpowerview.internal.api.responses.SceneCollections;
import org.openhab.binding.hdpowerview.internal.api.responses.Scenes;
import org.openhab.binding.hdpowerview.internal.api.responses.ScheduledEvents;
private Instant maintenanceScheduledEnd = Instant.now().minusSeconds(2 * maintenancePeriod);
private final String base;
+ private final String firmwareVersion;
private final String shades;
private final String sceneActivate;
private final String scenes;
public HDPowerViewWebTargets(HttpClient httpClient, String ipAddress) {
base = "http://" + ipAddress + "/api/";
shades = base + "shades/";
+ firmwareVersion = base + "fwversion/";
sceneActivate = base + "scenes";
scenes = base + "scenes/";
this.httpClient = httpClient;
}
+ /**
+ * Fetches a JSON package with firmware information for the hub.
+ *
+ * @return FirmwareVersion class instance
+ * @throws JsonParseException if there is a JSON parsing error
+ * @throws HubProcessingException if there is any processing error
+ * @throws HubMaintenanceException if the hub is down for maintenance
+ */
+ public @Nullable FirmwareVersion getFirmwareVersion()
+ throws JsonParseException, HubProcessingException, HubMaintenanceException {
+ String json = invoke(HttpMethod.GET, firmwareVersion, null, null);
+ return gson.fromJson(json, FirmwareVersion.class);
+ }
+
/**
* Fetches a JSON package that describes all shades in the hub, and wraps it in
* a Shades class instance
--- /dev/null
+/**
+ * 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.hdpowerview.internal.api;
+
+/**
+ * Firmware version information for HD PowerView components
+ *
+ * @author Jacob Laursen - Initial contribution
+ */
+public class Firmware {
+ public String name;
+ public int revision;
+ public int subRevision;
+ public int build;
+
+ @Override
+ public String toString() {
+ return String.format("%d.%d.%d", revision, subRevision, build);
+ }
+}
--- /dev/null
+/**
+ * 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.hdpowerview.internal.api.responses;
+
+/**
+ * Firmware information for an HD PowerView hub
+ *
+ * @author Jacob Laursen - Initial contribution
+ */
+public class FirmwareVersion {
+ public FirmwareVersions firmware;
+}
--- /dev/null
+/**
+ * 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.hdpowerview.internal.api.responses;
+
+import org.openhab.binding.hdpowerview.internal.api.Firmware;
+
+/**
+ * Firmware information for an HD PowerView hub
+ *
+ * @author Jacob Laursen - Initial contribution
+ */
+public class FirmwareVersions {
+ public Firmware mainProcessor;
+ public Firmware radio;
+}
import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.jdt.annotation.Nullable;
+import org.openhab.binding.hdpowerview.internal.api.Firmware;
import org.openhab.binding.hdpowerview.internal.api.ShadePosition;
/**
public @Nullable Boolean timedOut;
public int signalStrength;
public @Nullable Integer capabilities;
+ public @Nullable Firmware firmware;
+ public @Nullable Firmware motor;
public String getName() {
return new String(Base64.getDecoder().decode(name));
import org.openhab.binding.hdpowerview.internal.HDPowerViewWebTargets;
import org.openhab.binding.hdpowerview.internal.HubMaintenanceException;
import org.openhab.binding.hdpowerview.internal.HubProcessingException;
+import org.openhab.binding.hdpowerview.internal.api.Firmware;
+import org.openhab.binding.hdpowerview.internal.api.responses.FirmwareVersion;
+import org.openhab.binding.hdpowerview.internal.api.responses.FirmwareVersions;
import org.openhab.binding.hdpowerview.internal.api.responses.SceneCollections;
import org.openhab.binding.hdpowerview.internal.api.responses.SceneCollections.SceneCollection;
import org.openhab.binding.hdpowerview.internal.api.responses.Scenes;
private List<Scene> sceneCache = new CopyOnWriteArrayList<>();
private List<SceneCollection> sceneCollectionCache = new CopyOnWriteArrayList<>();
private List<ScheduledEvent> scheduledEventCache = new CopyOnWriteArrayList<>();
+ private @Nullable FirmwareVersions firmwareVersions;
private Boolean deprecatedChannelsCreated = false;
private final ChannelTypeUID sceneChannelTypeUID = new ChannelTypeUID(HDPowerViewBindingConstants.BINDING_ID,
private synchronized void poll() {
try {
logger.debug("Polling for state");
+ updateFirmwareProperties();
pollShades();
List<Scene> scenes = updateSceneChannels();
}
}
+ private void updateFirmwareProperties() throws JsonParseException, HubProcessingException, HubMaintenanceException {
+ if (firmwareVersions != null) {
+ return;
+ }
+ HDPowerViewWebTargets webTargets = this.webTargets;
+ if (webTargets == null) {
+ throw new ProcessingException("Web targets not initialized");
+ }
+ FirmwareVersion firmwareVersion = webTargets.getFirmwareVersion();
+ if (firmwareVersion == null || firmwareVersion.firmware == null) {
+ logger.warn("Unable to get firmware version.");
+ return;
+ }
+ this.firmwareVersions = firmwareVersion.firmware;
+ Firmware mainProcessor = firmwareVersion.firmware.mainProcessor;
+ if (mainProcessor == null) {
+ logger.warn("Main processor firmware version missing in response.");
+ return;
+ }
+ logger.debug("Main processor firmware version received: {}, {}", mainProcessor.name, mainProcessor.toString());
+ Map<String, String> properties = editProperties();
+ if (mainProcessor.name != null) {
+ properties.put(HDPowerViewBindingConstants.PROPERTY_FIRMWARE_NAME, mainProcessor.name);
+ }
+ properties.put(HDPowerViewBindingConstants.PROPERTY_FIRMWARE_VERSION, mainProcessor.toString());
+ Firmware radio = firmwareVersion.firmware.radio;
+ if (radio != null) {
+ logger.debug("Radio firmware version received: {}", radio.toString());
+ properties.put(HDPowerViewBindingConstants.PROPERTY_RADIO_FIRMWARE_VERSION, radio.toString());
+ }
+ updateProperties(properties);
+ }
+
private void pollShades() throws JsonParseException, HubProcessingException, HubMaintenanceException {
HDPowerViewWebTargets webTargets = this.webTargets;
if (webTargets == null) {
import org.openhab.binding.hdpowerview.internal.HubMaintenanceException;
import org.openhab.binding.hdpowerview.internal.HubProcessingException;
import org.openhab.binding.hdpowerview.internal.api.CoordinateSystem;
+import org.openhab.binding.hdpowerview.internal.api.Firmware;
import org.openhab.binding.hdpowerview.internal.api.ShadePosition;
import org.openhab.binding.hdpowerview.internal.api.responses.Shade;
import org.openhab.binding.hdpowerview.internal.api.responses.Shades.ShadeData;
if (shadeData != null) {
updateStatus(ThingStatus.ONLINE);
updateSoftProperties(shadeData);
+ updateFirmwareProperties(shadeData);
updateBindingStates(shadeData.positions);
updateBatteryLevel(shadeData.batteryStatus);
updateState(CHANNEL_SHADE_BATTERY_VOLTAGE,
}
}
+ private void updateFirmwareProperties(ShadeData shadeData) {
+ Map<String, String> properties = editProperties();
+ Firmware shadeFirmware = shadeData.firmware;
+ Firmware motorFirmware = shadeData.motor;
+ if (shadeFirmware != null) {
+ properties.put(PROPERTY_FIRMWARE_VERSION, shadeFirmware.toString());
+ }
+ if (motorFirmware != null) {
+ properties.put(PROPERTY_MOTOR_FIRMWARE_VERSION, motorFirmware.toString());
+ }
+ updateProperties(properties);
+ }
+
/**
* After a hard refresh, update the Thing's properties based on the contents of the provided ShadeData.
*