forked from openhab/openhab-addons
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add new channels for water and power consumption for washing machines…
… and dishwashers. (openhab#11298) Fixes openhab#11297 Signed-off-by: Jacob Laursen <jacob-github@vindvejr.dk> Signed-off-by: Dave J Schoepel <dave@theschoepels.com>
- Loading branch information
Showing
20 changed files
with
333 additions
and
38 deletions.
There are no files selected for viewing
49 changes: 49 additions & 0 deletions
49
...nding.miele/src/main/java/org/openhab/binding/miele/internal/ExtendedDeviceStateUtil.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,49 @@ | ||
/** | ||
* Copyright (c) 2010-2021 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.miele.internal; | ||
|
||
import java.nio.charset.StandardCharsets; | ||
|
||
/** | ||
* The {@link ExtendedDeviceStateUtil} class contains utility methods for parsing | ||
* ExtendedDeviceState information | ||
* | ||
* @author Jacob Laursen - Added power/water consumption channels | ||
*/ | ||
public class ExtendedDeviceStateUtil { | ||
private static final byte[] HEX_ARRAY = "0123456789ABCDEF".getBytes(StandardCharsets.US_ASCII); | ||
|
||
/** | ||
* Convert byte array to hex representation. | ||
*/ | ||
public static String bytesToHex(byte[] bytes) { | ||
byte[] hexChars = new byte[bytes.length * 2]; | ||
for (int j = 0; j < bytes.length; j++) { | ||
int v = bytes[j] & 0xFF; | ||
hexChars[j * 2] = HEX_ARRAY[v >>> 4]; | ||
hexChars[j * 2 + 1] = HEX_ARRAY[v & 0x0F]; | ||
} | ||
|
||
return new String(hexChars, StandardCharsets.UTF_8); | ||
} | ||
|
||
/** | ||
* Convert string consisting of 8 bit characters to byte array. | ||
* Note: This simple operation has been extracted and pure here to document | ||
* and ensure correct behavior for 8 bit characters that should be turned | ||
* into single bytes without any UTF-8 encoding. | ||
*/ | ||
public static byte[] stringToBytes(String input) { | ||
return input.getBytes(StandardCharsets.ISO_8859_1); | ||
} | ||
} |
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
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
23 changes: 23 additions & 0 deletions
23
...src/main/java/org/openhab/binding/miele/internal/handler/ExtendedDeviceStateListener.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,23 @@ | ||
/** | ||
* Copyright (c) 2010-2021 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.miele.internal.handler; | ||
|
||
/** | ||
* Appliance handlers can implement the {@link ExtendedDeviceStateListener} interface | ||
* to extract additional information from the ExtendedDeviceState property. | ||
* | ||
* @author Jacob Laursen - Added power/water consumption channels | ||
*/ | ||
public interface ExtendedDeviceStateListener { | ||
void onApplianceExtendedStateChanged(byte[] extendedDeviceState); | ||
} |
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
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
Oops, something went wrong.