From 9945fda3075833af21422e3fef15ff2e8b684538 Mon Sep 17 00:00:00 2001 From: Bob Adair Date: Thu, 18 Nov 2021 18:28:48 -0500 Subject: [PATCH 1/2] [lutron] Set default monitoring types for HomeWorks Signed-off-by: Bob Adair --- .../internal/handler/IPBridgeHandler.java | 20 +++--- .../internal/protocol/lip/Monitoring.java | 65 +++++++++++++++++++ 2 files changed, 77 insertions(+), 8 deletions(-) create mode 100644 bundles/org.openhab.binding.lutron/src/main/java/org/openhab/binding/lutron/internal/protocol/lip/Monitoring.java diff --git a/bundles/org.openhab.binding.lutron/src/main/java/org/openhab/binding/lutron/internal/handler/IPBridgeHandler.java b/bundles/org.openhab.binding.lutron/src/main/java/org/openhab/binding/lutron/internal/handler/IPBridgeHandler.java index 61c6cf4e9bae..d5fb1b9c16c9 100644 --- a/bundles/org.openhab.binding.lutron/src/main/java/org/openhab/binding/lutron/internal/handler/IPBridgeHandler.java +++ b/bundles/org.openhab.binding.lutron/src/main/java/org/openhab/binding/lutron/internal/handler/IPBridgeHandler.java @@ -33,6 +33,7 @@ import org.openhab.binding.lutron.internal.protocol.LutronCommandNew; import org.openhab.binding.lutron.internal.protocol.lip.LutronCommandType; import org.openhab.binding.lutron.internal.protocol.lip.LutronOperation; +import org.openhab.binding.lutron.internal.protocol.lip.Monitoring; import org.openhab.binding.lutron.internal.protocol.lip.TargetType; import org.openhab.core.thing.Bridge; import org.openhab.core.thing.ChannelUID; @@ -57,11 +58,6 @@ public class IPBridgeHandler extends LutronBridgeHandler { private static final String DB_UPDATE_DATE_FORMAT = "MM/dd/yyyy HH:mm:ss"; - private static final Integer MONITOR_PROMPT = 12; - private static final Integer MONITOR_SYSVAR = 10; - private static final Integer MONITOR_ENABLE = 1; - private static final Integer MONITOR_DISABLE = 2; - private static final Integer SYSTEM_DBEXPORTDATETIME = 10; private static final int MAX_LOGIN_ATTEMPTS = 2; @@ -208,8 +204,9 @@ private synchronized void connect() { // Disable prompts sendCommand(new LIPCommand(TargetType.BRIDGE, LutronOperation.EXECUTE, LutronCommandType.MONITORING, null, - MONITOR_PROMPT, MONITOR_DISABLE)); + Monitoring.PROMPT, Monitoring.ACTION_DISABLE)); + initMonitoring(); if (requireSysvarMonitoring.get()) { setSysvarMonitoring(true); } @@ -457,10 +454,17 @@ private void scanForDevices() { } } + private void initMonitoring() { + for (Integer monitorType : Monitoring.REQUIRED_SET) { + sendCommand(new LIPCommand(TargetType.BRIDGE, LutronOperation.EXECUTE, LutronCommandType.MONITORING, null, + monitorType, Monitoring.ACTION_ENABLE)); + } + } + private void setSysvarMonitoring(boolean enable) { - Integer setting = (enable) ? MONITOR_ENABLE : MONITOR_DISABLE; + Integer setting = (enable) ? Monitoring.ACTION_ENABLE : Monitoring.ACTION_DISABLE; sendCommand(new LIPCommand(TargetType.BRIDGE, LutronOperation.EXECUTE, LutronCommandType.MONITORING, null, - MONITOR_SYSVAR, setting)); + Monitoring.SYSVAR, setting)); } @Override diff --git a/bundles/org.openhab.binding.lutron/src/main/java/org/openhab/binding/lutron/internal/protocol/lip/Monitoring.java b/bundles/org.openhab.binding.lutron/src/main/java/org/openhab/binding/lutron/internal/protocol/lip/Monitoring.java new file mode 100644 index 000000000000..7708049ce2bc --- /dev/null +++ b/bundles/org.openhab.binding.lutron/src/main/java/org/openhab/binding/lutron/internal/protocol/lip/Monitoring.java @@ -0,0 +1,65 @@ +/** + * 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.lutron.internal.protocol.lip; + +import java.util.Collections; +import java.util.Set; +import java.util.stream.Collectors; +import java.util.stream.Stream; + +import org.eclipse.jdt.annotation.NonNullByDefault; + +/** + * The {@link Monitoring} class defines constants for LIP Monitoring types + * + * @author Bob Adair - Initial contribution + */ +@NonNullByDefault +public class Monitoring { + // Monitoring Actions + public static final Integer ACTION_ENABLE = 1; + public static final Integer ACTION_DISABLE = 2; + + // Monitoring Types + public static final Integer DIAG = 1; + public static final Integer EVENT = 2; + public static final Integer BUTTON = 3; + public static final Integer LED = 4; + public static final Integer ZONE = 5; + public static final Integer OCCUPANCY = 6; + public static final Integer PHOTOSENSOR = 7; + public static final Integer SCENE = 8; + public static final Integer TIMECLOCK = 9; + public static final Integer SYSVAR = 10; + public static final Integer REPLY = 11; + public static final Integer PROMPT = 12; + public static final Integer DEVICE = 14; + public static final Integer ADDRESS = 15; + public static final Integer SEQUENCE = 16; + public static final Integer HVAC = 17; + public static final Integer MODE = 18; + public static final Integer PRESET = 19; + public static final Integer L1RUNTIME = 20; + public static final Integer L2RUNTIME = 21; + public static final Integer DIAGERROR = 22; + public static final Integer SHADEGRP = 23; + public static final Integer PARTITION = 24; + public static final Integer SYSTEM = 25; + public static final Integer SENSORGROUP = 26; + public static final Integer TEMPSENSOR = 27; + public static final Integer ALL = 255; + + /** Set of monitoring types which must be enabled */ + public static final Set REQUIRED_SET = Collections.unmodifiableSet( + Stream.of(BUTTON, LED, ZONE, OCCUPANCY, SCENE, TIMECLOCK, REPLY, HVAC, MODE).collect(Collectors.toSet())); +} From 54f52411b0db9a6c0c8cad71998ac3098b1b0e02 Mon Sep 17 00:00:00 2001 From: Bob Adair Date: Tue, 7 Dec 2021 14:26:13 -0500 Subject: [PATCH 2/2] [lutron] update for review comment Signed-off-by: Bob Adair --- .../binding/lutron/internal/protocol/lip/Monitoring.java | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/bundles/org.openhab.binding.lutron/src/main/java/org/openhab/binding/lutron/internal/protocol/lip/Monitoring.java b/bundles/org.openhab.binding.lutron/src/main/java/org/openhab/binding/lutron/internal/protocol/lip/Monitoring.java index 7708049ce2bc..948e9fc66745 100644 --- a/bundles/org.openhab.binding.lutron/src/main/java/org/openhab/binding/lutron/internal/protocol/lip/Monitoring.java +++ b/bundles/org.openhab.binding.lutron/src/main/java/org/openhab/binding/lutron/internal/protocol/lip/Monitoring.java @@ -12,10 +12,7 @@ */ package org.openhab.binding.lutron.internal.protocol.lip; -import java.util.Collections; import java.util.Set; -import java.util.stream.Collectors; -import java.util.stream.Stream; import org.eclipse.jdt.annotation.NonNullByDefault; @@ -60,6 +57,6 @@ public class Monitoring { public static final Integer ALL = 255; /** Set of monitoring types which must be enabled */ - public static final Set REQUIRED_SET = Collections.unmodifiableSet( - Stream.of(BUTTON, LED, ZONE, OCCUPANCY, SCENE, TIMECLOCK, REPLY, HVAC, MODE).collect(Collectors.toSet())); + public static final Set REQUIRED_SET = Set.of(BUTTON, LED, ZONE, OCCUPANCY, SCENE, TIMECLOCK, REPLY, HVAC, + MODE); }