diff --git a/pyisy/constants.py b/pyisy/constants.py index 3fef6d7..7e2ef01 100644 --- a/pyisy/constants.py +++ b/pyisy/constants.py @@ -192,6 +192,7 @@ CLIMATE_SETPOINT_MIN_GAP = 2 +CMD_BACKLIGHT = "BL" CMD_BEEP = "BEEP" CMD_BRIGHTEN = "BRT" CMD_CLIMATE_FAN_SETTING = "CLIFS" @@ -338,6 +339,7 @@ "WINDCH": "wind_chill", "WINDDIR": "wind_direction", "WVOL": "water_volume", + CMD_BACKLIGHT: "backlight", CMD_BEEP: "beep", CMD_BRIGHTEN: "bright", CMD_CLIMATE_FAN_SETTING: "fan_state", @@ -407,11 +409,13 @@ FAMILY_ZMATTER_ZWAVE: "ZMatter_Z-Wave", } -UOM_SECONDS = "57" -UOM_FAN_MODES = "99" UOM_CLIMATE_MODES = "98" UOM_CLIMATE_MODES_ZWAVE = "67" UOM_DOUBLE_TEMP = "101" +UOM_FAN_MODES = "99" +UOM_INDEX = "25" +UOM_PERCENTAGE = "51" +UOM_SECONDS = "57" UOM_FRIENDLY_NAME = { "1": "A", @@ -436,7 +440,7 @@ "22": "%RH", "23": "inHg", "24": "in/hr", - "25": "index", + UOM_INDEX: "index", "26": "K", "27": "keyword", "28": "kg", @@ -462,7 +466,7 @@ "48": "MPH", "49": "m/s", "50": "Ω", - "51": "%", + UOM_PERCENTAGE: "%", "52": "lbs", "53": "pf", "54": "ppm", @@ -984,3 +988,155 @@ NODE_IS_NEW = 0x20 # brand new node NODE_TO_DELETE = 0x40 # has to be deleted later NODE_IS_DEVICE_ROOT = 0x80 # root device such as KPL load + +BACKLIGHT_SUPPORT = { + "DimmerMotorSwitch": UOM_PERCENTAGE, + "DimmerMotorSwitch_ADV": UOM_PERCENTAGE, + "DimmerLampSwitch": UOM_PERCENTAGE, + "DimmerLampSwitch_ADV": UOM_PERCENTAGE, + "DimmerSwitchOnly": UOM_PERCENTAGE, + "DimmerSwitchOnly_ADV": UOM_PERCENTAGE, + "KeypadDimmer": UOM_INDEX, + "KeypadDimmer_ADV": UOM_INDEX, + "RelayLampSwitch": UOM_PERCENTAGE, + "RelayLampSwitch_ADV": UOM_PERCENTAGE, + "RelaySwitchOnlyPlusQuery": UOM_PERCENTAGE, + "RelaySwitchOnlyPlusQuery_ADV": UOM_PERCENTAGE, + "RelaySwitchOnly": UOM_PERCENTAGE, + "RelaySwitchOnly_ADV": UOM_PERCENTAGE, + "KeypadRelay": UOM_INDEX, + "KeypadRelay_ADV": UOM_INDEX, + "KeypadButton": UOM_INDEX, + "KeypadButton_ADV": UOM_INDEX, +} + +BACKLIGHT_INDEX = [ + "On 0 / Off 0", + "On 1 / Off 0", + "On 2 / Off 0", + "On 3 / Off 0", + "On 4 / Off 0", + "On 5 / Off 0", + "On 6 / Off 0", + "On 7 / Off 0", + "On 8 / Off 0", + "On 9 / Off 0", + "On 10 / Off 0", + "On 11 / Off 0", + "On 12 / Off 0", + "On 13 / Off 0", + "On 14 / Off 0", + "On 15 / Off 0", + "On 0 / Off 1", + "On 1 / Off 1", + "On 2 / Off 1", + "On 3 / Off 1", + "On 4 / Off 1", + "On 5 / Off 1", + "On 6 / Off 1", + "On 7 / Off 1", + "On 8 / Off 1", + "On 9 / Off 1", + "On 10 / Off 1", + "On 11 / Off 1", + "On 12 / Off 1", + "On 13 / Off 1", + "On 14 / Off 1", + "On 15 / Off 1", + "On 0 / Off 2", + "On 1 / Off 2", + "On 2 / Off 2", + "On 3 / Off 2", + "On 4 / Off 2", + "On 5 / Off 2", + "On 6 / Off 2", + "On 7 / Off 2", + "On 8 / Off 2", + "On 9 / Off 2", + "On 10 / Off 2", + "On 11 / Off 2", + "On 12 / Off 2", + "On 13 / Off 2", + "On 14 / Off 2", + "On 15 / Off 2", + "On 0 / Off 3", + "On 1 / Off 3", + "On 2 / Off 3", + "On 3 / Off 3", + "On 4 / Off 3", + "On 5 / Off 3", + "On 6 / Off 3", + "On 7 / Off 3", + "On 8 / Off 3", + "On 9 / Off 3", + "On 10 / Off 3", + "On 11 / Off 3", + "On 12 / Off 3", + "On 13 / Off 3", + "On 14 / Off 3", + "On 15 / Off 3", + "On 0 / Off 4", + "On 1 / Off 4", + "On 2 / Off 4", + "On 3 / Off 4", + "On 4 / Off 4", + "On 5 / Off 4", + "On 6 / Off 4", + "On 7 / Off 4", + "On 8 / Off 4", + "On 9 / Off 4", + "On 10 / Off 4", + "On 11 / Off 4", + "On 12 / Off 4", + "On 13 / Off 4", + "On 14 / Off 4", + "On 15 / Off 4", + "On 0 / Off 5", + "On 1 / Off 5", + "On 2 / Off 5", + "On 3 / Off 5", + "On 4 / Off 5", + "On 5 / Off 5", + "On 6 / Off 5", + "On 7 / Off 5", + "On 8 / Off 5", + "On 9 / Off 5", + "On 10 / Off 5", + "On 11 / Off 5", + "On 12 / Off 5", + "On 13 / Off 5", + "On 14 / Off 5", + "On 15 / Off 5", + "On 0 / Off 6", + "On 1 / Off 6", + "On 2 / Off 6", + "On 3 / Off 6", + "On 4 / Off 6", + "On 5 / Off 6", + "On 6 / Off 6", + "On 7 / Off 6", + "On 8 / Off 6", + "On 9 / Off 6", + "On 10 / Off 6", + "On 11 / Off 6", + "On 12 / Off 6", + "On 13 / Off 6", + "On 14 / Off 6", + "On 15 / Off 6", + "On 0 / Off 7", + "On 1 / Off 7", + "On 2 / Off 7", + "On 3 / Off 7", + "On 4 / Off 7", + "On 5 / Off 7", + "On 6 / Off 7", + "On 7 / Off 7", + "On 8 / Off 7", + "On 9 / Off 7", + "On 10 / Off 7", + "On 11 / Off 7", + "On 12 / Off 7", + "On 13 / Off 7", + "On 14 / Off 7", + "On 15 / Off 7", +] diff --git a/pyisy/nodes/node.py b/pyisy/nodes/node.py index 4af75aa..5c99dd1 100755 --- a/pyisy/nodes/node.py +++ b/pyisy/nodes/node.py @@ -4,6 +4,7 @@ from xml.dom import minidom from ..constants import ( + BACKLIGHT_SUPPORT, CLIMATE_SETPOINT_MIN_GAP, CMD_CLIMATE_FAN_SETTING, CMD_CLIMATE_MODE, @@ -156,7 +157,16 @@ def is_battery_node(self): return self._is_battery_node @property - def is_dimmable(self): + def is_backlight_supported(self) -> bool: + """Confirm if this node supports setting backlight.""" + return ( + (self.protocol == PROTO_INSTEON) + and self.node_def_id is not None + and (self.node_def_id in BACKLIGHT_SUPPORT) + ) + + @property + def is_dimmable(self) -> bool: """ Return the best guess if this is a dimmable node.