Skip to content

Commit

Permalink
[miio] Minor improvement documentation & deviceId update message (ope…
Browse files Browse the repository at this point in the history
…nhab#11046)

* [miio] Minor improvement documentation & message
* [miio] minor cleanup from sat
* miio] fix another minor datetimeformat SAT issue

Signed-off-by: Marcel Verpaalen <[email protected]>
Signed-off-by: Dave J Schoepel <[email protected]>
  • Loading branch information
marcelrv authored and dschoepel committed Nov 9, 2021
1 parent 5806c04 commit f7009b2
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 14 deletions.
8 changes: 5 additions & 3 deletions bundles/org.openhab.binding.miio/README.base.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,17 +80,19 @@ However, for devices that are unsupported, you may override the value and try to
| model | text | false | Device model string, used to determine the subtype |
| refreshInterval | integer | false | Refresh interval for refreshing the data in seconds. (0=disabled) |
| timeout | integer | false | Timeout time in milliseconds |
| communication | test | false | Communicate direct or via cloud (options values: 'direct', 'cloud') |
| communication | text | false | Communicate direct or via cloud (options values: 'direct', 'cloud') |
| cloudServer | text | false | Identifies the country server to use in case of cloud communication |

Note: Suggest to use the cloud communication only for devices that require it. It is unknown at this time if Xiaomi has a rate limit or other limitations on the cloud usage. e.g. if having many devices would trigger some throttling from the cloud side.
Note: Suggest to use the cloud communication only for devices that require it.
It is unknown at this time if Xiaomi has a rate limit or other limitations on the cloud usage. e.g. if having many devices would trigger some throttling from the cloud side.

### Example Thing file

`Thing miio:basic:light "My Light" [ host="192.168.x.x", token="put here your token", deviceId="326xxxx", model="philips.light.bulb", communication="direct" ]`

or in case of unknown models include the model information of a similar device that is supported:

`Thing miio:vacuum:s50 "vacuum" @ "livingroom" [ host="192.168.15.20", token="xxxxxxx", deviceId="326xxxx", model="roborock.vacuum.s4", communication="direct" ]`
`Thing miio:vacuum:s50 "vacuum" @ "livingroom" [ host="192.168.15.20", token="xxxxxxx", deviceId="326xxxx", model="roborock.vacuum.s4", communication="direct", cloudServer="de" ]`

# Advanced: Unsupported devices

Expand Down
8 changes: 5 additions & 3 deletions bundles/org.openhab.binding.miio/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,17 +80,19 @@ However, for devices that are unsupported, you may override the value and try to
| model | text | false | Device model string, used to determine the subtype |
| refreshInterval | integer | false | Refresh interval for refreshing the data in seconds. (0=disabled) |
| timeout | integer | false | Timeout time in milliseconds |
| communication | test | false | Communicate direct or via cloud (options values: 'direct', 'cloud') |
| communication | text | false | Communicate direct or via cloud (options values: 'direct', 'cloud') |
| cloudServer | text | false | Identifies the country server to use in case of cloud communication |

Note: Suggest to use the cloud communication only for devices that require it. It is unknown at this time if Xiaomi has a rate limit or other limitations on the cloud usage. e.g. if having many devices would trigger some throttling from the cloud side.
Note: Suggest to use the cloud communication only for devices that require it.
It is unknown at this time if Xiaomi has a rate limit or other limitations on the cloud usage. e.g. if having many devices would trigger some throttling from the cloud side.

### Example Thing file

`Thing miio:basic:light "My Light" [ host="192.168.x.x", token="put here your token", deviceId="326xxxx", model="philips.light.bulb", communication="direct" ]`

or in case of unknown models include the model information of a similar device that is supported:

`Thing miio:vacuum:s50 "vacuum" @ "livingroom" [ host="192.168.15.20", token="xxxxxxx", deviceId="326xxxx", model="roborock.vacuum.s4", communication="direct" ]`
`Thing miio:vacuum:s50 "vacuum" @ "livingroom" [ host="192.168.15.20", token="xxxxxxx", deviceId="326xxxx", model="roborock.vacuum.s4", communication="direct", cloudServer="de" ]`

# Advanced: Unsupported devices

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ public class ActionConditions {
* @param value
* @return RGB value + brightness as first byte
*/
private static @Nullable JsonElement HsvToBRGB(@Nullable Command command, @Nullable JsonElement value) {
private static @Nullable JsonElement hsvToBRGB(@Nullable Command command, @Nullable JsonElement value) {
if (command != null && command instanceof HSBType) {
HSBType hsb = (HSBType) command;
Color color = Color.getHSBColor(hsb.getHue().floatValue() / 360, hsb.getSaturation().floatValue() / 100,
Expand Down Expand Up @@ -171,7 +171,7 @@ public class ActionConditions {
case "BRIGHTNESSEXISTING":
return brightnessExists(value);
case "HSVTOBRGB":
return HsvToBRGB(command, value);
return hsvToBRGB(command, value);
case "BRIGHTNESSONOFF":
return brightness(value);
case "HSBONLY":
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,8 @@ protected void disconnected(@Nullable String message) {
String deviceId = configuration.deviceId;
if (deviceId.length() == 8 && deviceId.matches("^.*[a-zA-Z]+.*$")) {
logger.warn(
"As per openHAB version 3.2 the deviceId is no longer a string with hexadecimals, instead it is a string with the numeric respresentation of the deviceId. If you continue seeing this message, update deviceId in your thing configuration");
"As per openHAB version 3.2 the deviceId is no longer a string with hexadecimals, instead it is a string with the numeric respresentation of the deviceId. If you continue seeing this message, update deviceId in your thing configuration. Expected change for thing '{}': Update current deviceId: '{}' to '{}'",
getThing().getUID(), deviceId, Utils.fromHEX(deviceId));
deviceId = "";
}
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.IOException;
import java.text.SimpleDateFormat;
import java.time.Instant;
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.time.ZonedDateTime;
import java.time.format.DateTimeFormatter;
import java.util.Collections;
import java.util.Date;
import java.util.Map.Entry;
import java.util.Set;
import java.util.concurrent.ConcurrentHashMap;
Expand Down Expand Up @@ -89,7 +89,7 @@
public class MiIoVacuumHandler extends MiIoAbstractHandler {
private final Logger logger = LoggerFactory.getLogger(MiIoVacuumHandler.class);
private static final float MAP_SCALE = 2.0f;
private static final SimpleDateFormat DATEFORMATTER = new SimpleDateFormat("yyyyMMdd-HHmmss");
private static final DateTimeFormatter DATEFORMATTER = DateTimeFormatter.ofPattern("yyyyMMdd-HHmmss");
private static final Gson GSON = new GsonBuilder().serializeNulls().create();
private final ChannelUID mapChannelUid;

Expand Down Expand Up @@ -654,7 +654,7 @@ private State getMap(String map) {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
if (logger.isDebugEnabled()) {
final String mapPath = BINDING_USERDATA_PATH + File.separator + map
+ DATEFORMATTER.format(new Date()) + ".rrmap";
+ LocalDateTime.now().format(DATEFORMATTER) + ".rrmap";
CloudUtil.writeBytesToFileNio(mapData, mapPath);
logger.debug("Mapdata saved to {}", mapPath);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@
"actions": [
{
"command": "start_cf",
"parameterType": "EMPTY",
"parameterType": "NONE",
"parameters": [
0,
0,
Expand Down

0 comments on commit f7009b2

Please sign in to comment.