forked from openhab/openhab-addons
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[unifi] Fix portoverride to not remove any other data
When a user has configured additional settings on a PoE port, like name. These settings where lost when changing the PoEPort status in openHAB. This was because in the binding only some information of the override was stored and when writing th new state this information would have been send too. In this change the object to store the override has been replaced by a plain json object. Therefor we don't have to know what is in it and all information is kept. Signed-off-by: Hilbrand Bouwkamp <[email protected]>
- Loading branch information
Showing
13 changed files
with
273 additions
and
175 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
72 changes: 0 additions & 72 deletions
72
...ding.unifi/src/main/java/org/openhab/binding/unifi/internal/api/dto/UnfiPortOverride.java
This file was deleted.
Oops, something went wrong.
61 changes: 61 additions & 0 deletions
61
...src/main/java/org/openhab/binding/unifi/internal/api/dto/UnfiPortOverrideJsonElement.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
/** | ||
* 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.unifi.internal.api.dto; | ||
|
||
import com.google.gson.JsonElement; | ||
import com.google.gson.JsonObject; | ||
|
||
/** | ||
* The {@link UnfiPortOverride} represents the data model of UniFi port override. | ||
* Using plain JsonObject to make sure any data in the object is not lost when writing the data back to the UniFi | ||
* device. | ||
* | ||
* @author Hilbrand Bouwkamp - Initial contribution | ||
*/ | ||
public class UnfiPortOverrideJsonElement { | ||
|
||
private static final String PORT_IDX = "port_idx"; | ||
private static final String PORT_CONF_ID = "port_conf_id"; | ||
private static final String POE_MODE = "poe_mode"; | ||
|
||
private final JsonObject jsonObject; | ||
|
||
public UnfiPortOverrideJsonElement(final JsonElement element) { | ||
this.jsonObject = element.getAsJsonObject(); | ||
} | ||
|
||
public JsonObject getJsonObject() { | ||
return jsonObject; | ||
} | ||
|
||
public int getPortIdx() { | ||
return jsonObject.get(PORT_IDX).getAsInt(); | ||
} | ||
|
||
public String getPortConfId() { | ||
return jsonObject.get(PORT_CONF_ID).getAsString(); | ||
} | ||
|
||
public String getPoeMode() { | ||
return jsonObject.get(POE_MODE).getAsString(); | ||
} | ||
|
||
public void setPoeMode(final String poeMode) { | ||
jsonObject.addProperty(POE_MODE, poeMode); | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return jsonObject.toString(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 0 additions & 42 deletions
42
...ng.unifi/src/main/java/org/openhab/binding/unifi/internal/api/dto/UniFiPortOverrides.java
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.