getThing().requestUpdates(1, true); // refresh config
break;
case SHELLY2_EVENT_SLEEP:
- logger.debug("{}: Device went to sleep mode", thingName);
+ logger.debug("{}: Connection terminated, e.g. device in sleep mode", thingName);
break;
case SHELLY2_EVENT_WIFICONNFAILED:
logger.debug("{}: WiFi connect failed, check setup, reason {}", thingName,
}
@Override
- public void onClose(int statusCode, String reason) {
+ public void onClose(int statusCode, String description) {
try {
- logger.debug("{}: WebSocket connection closed, status = {}/{}", thingName, statusCode, getString(reason));
- if (statusCode == StatusCode.ABNORMAL && !discovery && getProfile().alwaysOn) { // e.g. device rebooted
+ String reason = getString(description);
+ logger.debug("{}: WebSocket connection closed, status = {}/{}", thingName, statusCode, reason);
+ if ("Bye".equalsIgnoreCase(reason)) {
+ logger.debug("{}: Device went to sleep mode", thingName);
+ } else if (statusCode == StatusCode.ABNORMAL && !discovery && getProfile().alwaysOn) {
+ // e.g. device rebooted
thingOffline("WebSocket connection closed abnormal");
}
} catch (ShellyApiException e) {
@Override
public void onError(Throwable cause) {
- logger.debug("{}: WebSocket error", thingName);
+ logger.debug("{}: WebSocket error: {}", thingName, cause.getMessage());
if (thing != null && thing.getProfile().alwaysOn) {
thingOffline("WebSocket error");
}
import static org.openhab.binding.shelly.internal.util.ShellyUtils.*;
import java.util.ArrayList;
-import java.util.HashMap;
import java.util.Map;
+import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.jdt.annotation.Nullable;
import org.openhab.binding.shelly.internal.api.ShellyApiException;
import org.openhab.binding.shelly.internal.api.ShellyDeviceProfile;
*
* @author Markus Michels - Initial contribution
*/
+@NonNullByDefault
public class ShellyBluApi extends Shelly2ApiRpc {
private static final Logger logger = LoggerFactory.getLogger(ShellyBluApi.class);
private boolean connected = false; // true = BLU devices has connected
private ShellySettingsStatus deviceStatus = new ShellySettingsStatus();
private int lastPid = -1;
- private static final Map<String, String> MAP_INPUT_EVENT_TYPE = new HashMap<>();
- static {
- MAP_INPUT_EVENT_TYPE.put(SHELLY2_EVENT_1PUSH, SHELLY_BTNEVENT_1SHORTPUSH);
- MAP_INPUT_EVENT_TYPE.put(SHELLY2_EVENT_2PUSH, SHELLY_BTNEVENT_2SHORTPUSH);
- MAP_INPUT_EVENT_TYPE.put(SHELLY2_EVENT_3PUSH, SHELLY_BTNEVENT_3SHORTPUSH);
- MAP_INPUT_EVENT_TYPE.put(SHELLY2_EVENT_LPUSH, SHELLY_BTNEVENT_LONGPUSH);
- MAP_INPUT_EVENT_TYPE.put(SHELLY2_EVENT_LSPUSH, SHELLY_BTNEVENT_LONGSHORTPUSH);
- MAP_INPUT_EVENT_TYPE.put(SHELLY2_EVENT_SLPUSH, SHELLY_BTNEVENT_SHORTLONGPUSH);
- MAP_INPUT_EVENT_TYPE.put("1", SHELLY_BTNEVENT_1SHORTPUSH);
- MAP_INPUT_EVENT_TYPE.put("2", SHELLY_BTNEVENT_2SHORTPUSH);
- MAP_INPUT_EVENT_TYPE.put("3", SHELLY_BTNEVENT_3SHORTPUSH);
- MAP_INPUT_EVENT_TYPE.put("4", SHELLY_BTNEVENT_LONGPUSH);
- }
+ private static final Map<String, String> MAP_INPUT_EVENT_TYPE = Map.of( //
+ SHELLY2_EVENT_1PUSH, SHELLY_BTNEVENT_1SHORTPUSH, //
+ SHELLY2_EVENT_2PUSH, SHELLY_BTNEVENT_2SHORTPUSH, //
+ SHELLY2_EVENT_3PUSH, SHELLY_BTNEVENT_3SHORTPUSH, //
+ SHELLY2_EVENT_LPUSH, SHELLY_BTNEVENT_LONGPUSH, //
+ SHELLY2_EVENT_LSPUSH, SHELLY_BTNEVENT_LONGSHORTPUSH, //
+ SHELLY2_EVENT_SLPUSH, SHELLY_BTNEVENT_SHORTLONGPUSH, //
+ "1", SHELLY_BTNEVENT_1SHORTPUSH, //
+ "2", SHELLY_BTNEVENT_2SHORTPUSH, //
+ "3", SHELLY_BTNEVENT_3SHORTPUSH, //
+ "4", SHELLY_BTNEVENT_LONGPUSH);
/**
* Regular constructor - called by Thing handler
? tmpPrf.settings.sleepMode.period * 60 // minutes
: tmpPrf.settings.sleepMode.period * 3600; // hours
tmpPrf.updatePeriod += 60; // give 1min extra
- } else if ((tmpPrf.settings.coiot != null) && tmpPrf.settings.coiot.updatePeriod != null) {
+ } else if (tmpPrf.settings.coiot != null && tmpPrf.settings.coiot.updatePeriod != null) {
// Derive from CoAP update interval, usually 2*15+10s=40sec -> 70sec
tmpPrf.updatePeriod = Math.max(UPDATE_SETTINGS_INTERVAL_SECONDS,
2 * getInteger(tmpPrf.settings.coiot.updatePeriod)) + 10;
import java.util.Map;
import java.util.TreeMap;
+import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.jdt.annotation.Nullable;
import org.eclipse.jetty.client.HttpClient;
import org.openhab.binding.shelly.internal.api.ShellyDeviceProfile;
*
* @author Markus Michels - Initial contribution
*/
+@NonNullByDefault
public class ShellyBluSensorHandler extends ShellyBaseHandler {
private static final Logger logger = LoggerFactory.getLogger(ShellyBluSensorHandler.class);
super.initialize();
}
- public static void addBluThing(String gateway, Shelly2NotifyEvent e, ShellyThingTable thingTable) {
+ public static void addBluThing(String gateway, Shelly2NotifyEvent e, @Nullable ShellyThingTable thingTable) {
String model = substringBefore(getString(e.data.name), "-").toUpperCase();
String mac = e.data.addr.replaceAll(":", "");
String ttype = "";
thing-type.shelly.shellypluswdus.description = Shelly Wall Dimmer US Device
thing-type.shelly.shellyplus10v.description = Shelly Plus Dimmer 10V
-# Wall displays
-thing-type.shelly.shellywalldisplay.description = Shelly Wall Display with sensors and input/output
-
# Plus Mini Devices
thing-type.shelly.shellyplusmini1.description = Shelly Plus Mini 1 - Single Relay Switch
thing-type.shelly.shellyplusminipm.description = Shelly Plus Mini PM - Power Meter
thing-type.shelly.shellybludw.description = Shelly BLU Door/Window Sensor
thing-type.shelly.shellyblumotion.description = Shelly BLU Motion Sensor
- # Wall Displays
- thing-type.shelly.shellywalldisplay.description = Shelly Wall Display with sensors and input/output
+# Wall Displays
+thing-type.shelly.shellywalldisplay.description = Shelly Wall Display with sensors and input/output
# thing config - shellydevice
thing-type.config.shelly.deviceIp.label = IP Address
/*
- * This script uses the BLE scan functionality in scripting to pass scan reults to openHAB
- * Supported BLU Devices: SBBT , SBDW
+ * This script uses the BLE scan functionality in scripting to pass scan results to openHAB
+ * Supported BLU Devices: BLU Button 1, BLU Door/Window, BLU Motion
* Version 0.2
*/