Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[hdpowerview] Preparation for Generation 3 API #13352

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/**
* 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;

import java.util.Base64;

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

/**
* Abstract class for state of a Shade as returned by an HD PowerView hub.
*
* @author Andy Lintner - Initial contribution
* @author Andrew Fiddian-Green - Refactored into separate class
*/
@NonNullByDefault
public abstract class ShadeData {
// fields common to Generation 1/2 and 3 hubs
public int id;
public @Nullable String name;
public int roomId;
public int type;
public int batteryStatus;
public @Nullable ShadePosition positions;
public int signalStrength;
public @Nullable Integer capabilities;
public @Nullable Firmware firmware;

public String getName() {
return new String(Base64.getDecoder().decode(name));
}

public abstract BatteryKind getBatteryKind();

public abstract int version();
}

Large diffs are not rendered by default.

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.hdpowerview.internal.api._v1;

import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.jdt.annotation.Nullable;
import org.openhab.binding.hdpowerview.internal.api.BatteryKind;
import org.openhab.binding.hdpowerview.internal.api.Firmware;
import org.openhab.binding.hdpowerview.internal.api.ShadeData;

/**
* State of a Shade as returned by an HD PowerView hub of Generation 1 or 2.
*
* @author Andrew Fiddian-Green - Initial contribution
*/
@NonNullByDefault
public class ShadeDataV1 extends ShadeData {
// fields for Generation 1/2 hubs only; NOTE: all these are Nullable
public int groupId;
public int order;
public double batteryStrength;
public boolean batteryIsLow;
public @Nullable Boolean timedOut;
public @Nullable Firmware motor;
// note: in old JSON batteryKind was a string but now it's a number; fortunately GSON string accepts either
public @Nullable String batteryKind;

@Override
public BatteryKind getBatteryKind() {
return BatteryKind.fromString(batteryKind);
}

@Override
public int version() {
return 1;
}
}
Loading