From 346e3c56466a4fdc878526d4abfb3cc5523195e7 Mon Sep 17 00:00:00 2001 From: Raman Gupta <7243222+raman325@users.noreply.github.com> Date: Wed, 6 Dec 2023 23:39:38 -0500 Subject: [PATCH 1/2] Improve the generation scripts --- pyproject.toml | 1 + .../generate_multilevel_sensor_constants.py | 16 +- scripts/generate_notification_constants.py | 23 +- .../const/command_class/multilevel_sensor.py | 435 ++++++++++++++++++ .../const/command_class/notification.py | 6 + 5 files changed, 466 insertions(+), 15 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index fd7ef8660..669f37392 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -66,6 +66,7 @@ disable = [ "locally-disabled", "too-few-public-methods", "too-many-public-methods", + "too-many-lines", ] enable = ["useless-suppression", "use-symbolic-message-instead"] extension-pkg-allow-list = "pydantic" diff --git a/scripts/generate_multilevel_sensor_constants.py b/scripts/generate_multilevel_sensor_constants.py index 4fabb9fa9..85e16df11 100755 --- a/scripts/generate_multilevel_sensor_constants.py +++ b/scripts/generate_multilevel_sensor_constants.py @@ -100,7 +100,7 @@ def normalize_scale_definition(scale_definitions: dict[str, dict]) -> dict[str, if sensor_id in (87, 88): remove_parenthesis_ = False sensor_name = enum_name_format(sensor_props["label"], remove_parenthesis_) - sensors[sensor_name] = {"id": sensor_id} + sensors[sensor_name] = {"id": sensor_id, "label": sensor_props["label"]} if isinstance(scale_def, str): sensors[sensor_name]["scale"] = normalize_name( scale_def.replace("$SCALES:", "") @@ -132,10 +132,19 @@ def generate_int_enum_class_definition( class_def.append(f" {docstring}") if enum_ref_url: class_def.append(f" # {enum_ref_url}") + class_def.append(" UNKNOWN = -1") for enum_name, enum_id in enum_map.items(): if get_id_func: enum_id = get_id_func(enum_id) class_def.append(f" {enum_name} = {enum_id}") + class_def.extend( + [ + " @classmethod", + f" def _missing_(cls: type, value: object) -> {class_name}: # noqa: ARG003", + ' """Set default enum member if an unknown value is provided."""', + f" return {class_name}.UNKNOWN", + ] + ) return class_def @@ -164,8 +173,13 @@ def generate_int_enum_base_class(class_name: str, docstring: str) -> list[str]: "from enum import IntEnum", 'CC_SPECIFIC_SCALE = "scale"', 'CC_SPECIFIC_SENSOR_TYPE = "sensorType"', + "", ] +lines.extend( + [f"{sensor}_PROPERTY = \"{data['label']}\"" for sensor, data in sensors.items()] +) + lines.extend( generate_int_enum_class_definition( "MultilevelSensorType", diff --git a/scripts/generate_notification_constants.py b/scripts/generate_notification_constants.py index 6d058283a..193415ca5 100755 --- a/scripts/generate_notification_constants.py +++ b/scripts/generate_notification_constants.py @@ -110,7 +110,6 @@ def generate_int_enum_class_definition( get_id_func: Callable | None = None, docstring_info: str = "", base_class: str = "IntEnum", - include_missing: bool = False, ) -> list[str]: """Generate an IntEnum class definition as an array of lines of string.""" class_def: list[str] = [] @@ -119,21 +118,19 @@ def generate_int_enum_class_definition( class_def.append(f" {docstring}") if enum_ref_url: class_def.append(f" # {enum_ref_url}") - if include_missing: - class_def.append(" UNKNOWN = -1") + class_def.append(" UNKNOWN = -1") for _enum_name, _enum_id in sorted(enum_map.items(), key=lambda x: x[0]): if get_id_func: _enum_id = get_id_func(_enum_id) class_def.append(f" {enum_name_format(_enum_name, False)} = {_enum_id}") - if include_missing: - class_def.extend( - [ - " @classmethod", - f" def _missing_(cls: type, value: object) -> {class_name}: # noqa: ARG003", - ' """Set default enum member if an unknown value is provided."""', - f" return {class_name}.UNKNOWN", - ] - ) + class_def.extend( + [ + " @classmethod", + f" def _missing_(cls: type, value: object) -> {class_name}: # noqa: ARG003", + ' """Set default enum member if an unknown value is provided."""', + f" return {class_name}.UNKNOWN", + ] + ) return class_def @@ -201,7 +198,6 @@ def generate_int_enum_base_class(class_name: str, docstring: str) -> list[str]: NOTIFICATIONS_URL, docstring_info=notification_event_name.lower(), base_class="NotificationEvent", - include_missing=True, ) ) _notification_type_to_notification_event_map[ @@ -217,7 +213,6 @@ def generate_int_enum_base_class(class_name: str, docstring: str) -> list[str]: NOTIFICATIONS_URL, docstring_info=notification_event_value_name.lower(), base_class="NotificationEventValue", - include_missing=True, ) ) _notification_event_to_event_value_map[ diff --git a/zwave_js_server/const/command_class/multilevel_sensor.py b/zwave_js_server/const/command_class/multilevel_sensor.py index 22c228b0a..2f3615945 100644 --- a/zwave_js_server/const/command_class/multilevel_sensor.py +++ b/zwave_js_server/const/command_class/multilevel_sensor.py @@ -12,11 +12,101 @@ CC_SPECIFIC_SCALE = "scale" CC_SPECIFIC_SENSOR_TYPE = "sensorType" +ACCELERATION_X_AXIS_PROPERTY = "Acceleration X-axis" +ACCELERATION_Y_AXIS_PROPERTY = "Acceleration Y-axis" +ACCELERATION_Z_AXIS_PROPERTY = "Acceleration Z-axis" +AIR_FLOW_PROPERTY = "Air flow" +AIR_TEMPERATURE_PROPERTY = "Air temperature" +AMMONIA_PROPERTY = "Ammonia" +ANGLE_POSITION_PROPERTY = "Angle position" +APPLIED_FORCE_ON_THE_SENSOR_PROPERTY = "Applied force on the sensor" +ATMOSPHERIC_PRESSURE_PROPERTY = "Atmospheric pressure" +BAROMETRIC_PRESSURE_PROPERTY = "Barometric pressure" +BASIS_METABOLIC_RATE_PROPERTY = "Basis metabolic rate (BMR)" +BLOOD_PRESSURE_PROPERTY = "Blood pressure" +BODY_MASS_INDEX_PROPERTY = "Body Mass Index (BMI)" +BOILER_WATER_TEMPERATURE_PROPERTY = "Boiler water temperature" +BONE_MASS_PROPERTY = "Bone mass" +CARBON_DIOXIDE_LEVEL_PROPERTY = "Carbon dioxide (CO₂) level" +CARBON_MONOXIDE_LEVEL_PROPERTY = "Carbon monoxide (CO) level" +CONDENSER_COIL_TEMPERATURE_PROPERTY = "Condenser Coil temperature" +CURRENT_PROPERTY = "Current" +DEFROST_TEMPERATURE_PROPERTY = "Defrost temperature" +DEW_POINT_PROPERTY = "Dew point" +DIRECTION_PROPERTY = "Direction" +DISCHARGE_LINE_TEMPERATURE_PROPERTY = "Discharge Line temperature" +DISCHARGE_PRESSURE_PROPERTY = "Discharge Pressure" +DISTANCE_PROPERTY = "Distance" +DOMESTIC_HOT_WATER_TEMPERATURE_PROPERTY = "Domestic Hot Water (DHW) temperature" +ELECTRICAL_CONDUCTIVITY_PROPERTY = "Electrical conductivity" +ELECTRICAL_RESISTIVITY_PROPERTY = "Electrical resistivity" +EVAPORATOR_COIL_TEMPERATURE_PROPERTY = "Evaporator Coil temperature" +EXHAUST_TEMPERATURE_PROPERTY = "Exhaust temperature" +FAT_MASS_PROPERTY = "Fat mass" +FORMALDEHYDE_LEVEL_PROPERTY = "Formaldehyde (CH₂O) level" +FREQUENCY_PROPERTY = "Frequency" +GENERAL_PURPOSE_PROPERTY = "General purpose" +HEART_RATE_PROPERTY = "Heart rate" +HEART_RATE_LF_HF_RATIO_PROPERTY = "Heart Rate LF/HF ratio" +HUMIDITY_PROPERTY = "Humidity" +ILLUMINANCE_PROPERTY = "Illuminance" +LEAD_PROPERTY = "Lead" +LIQUID_LINE_TEMPERATURE_PROPERTY = "Liquid Line temperature" +LOUDNESS_PROPERTY = "Loudness" +METHANE_DENSITY_PROPERTY = "Methane (CH₄) density" +MOISTURE_PROPERTY = "Moisture" +MOTION_DIRECTION_PROPERTY = "Motion Direction" +MUSCLE_MASS_PROPERTY = "Muscle mass" +NITROGEN_DIOXIDE_PROPERTY = "Nitrogen dioxide" +OUTSIDE_TEMPERATURE_PROPERTY = "Outside temperature" +OZONE_PROPERTY = "Ozone" +PARTICULATE_MATTER_1_PROPERTY = "Particulate Matter 1" +PARTICULATE_MATTER_10_PROPERTY = "Particulate Matter 10" +PARTICULATE_MATTER_2_5_PROPERTY = "Particulate Matter 2.5" +PERSON_COUNTER_ENTERING_PROPERTY = "Person counter (entering)" +PERSON_COUNTER_EXITING_PROPERTY = "Person counter (exiting)" +POWER_PROPERTY = "Power" +RADON_CONCENTRATION_PROPERTY = "Radon concentration" +RAIN_RATE_PROPERTY = "Rain rate" +RELATIVE_MODULATION_LEVEL_PROPERTY = "Relative Modulation level" +RESPIRATORY_RATE_PROPERTY = "Respiratory rate" +RETURN_AIR_TEMPERATURE_PROPERTY = "Return Air temperature" +RF_SIGNAL_STRENGTH_PROPERTY = "RF signal strength" +ROTATION_PROPERTY = "Rotation" +SEISMIC_INTENSITY_PROPERTY = "Seismic Intensity" +SEISMIC_MAGNITUDE_PROPERTY = "Seismic magnitude" +SMOKE_DENSITY_PROPERTY = "Smoke density" +SOIL_HUMIDITY_PROPERTY = "Soil humidity" +SOIL_REACTIVITY_PROPERTY = "Soil reactivity" +SOIL_SALINITY_PROPERTY = "Soil salinity" +SOIL_TEMPERATURE_PROPERTY = "Soil temperature" +SOLAR_RADIATION_PROPERTY = "Solar radiation" +SUCTION_PRESSURE_PROPERTY = "Suction Pressure" +SULFUR_DIOXIDE_PROPERTY = "Sulfur dioxide" +SUPPLY_AIR_TEMPERATURE_PROPERTY = "Supply Air temperature" +TANK_CAPACITY_PROPERTY = "Tank capacity" +TARGET_TEMPERATURE_PROPERTY = "Target temperature" +TIDE_LEVEL_PROPERTY = "Tide level" +TIME_PROPERTY = "Time" +TOTAL_BODY_WATER_PROPERTY = "Total body water (TBW)" +ULTRAVIOLET_PROPERTY = "Ultraviolet" +VELOCITY_PROPERTY = "Velocity" +VOLATILE_ORGANIC_COMPOUND_LEVEL_PROPERTY = "Volatile Organic Compound level" +VOLTAGE_PROPERTY = "Voltage" +WATER_ACIDITY_PROPERTY = "Water acidity" +WATER_CHLORINE_LEVEL_PROPERTY = "Water Chlorine level" +WATER_FLOW_PROPERTY = "Water flow" +WATER_OXIDATION_REDUCTION_POTENTIAL_PROPERTY = "Water Oxidation reduction potential" +WATER_PRESSURE_PROPERTY = "Water pressure" +WATER_TEMPERATURE_PROPERTY = "Water temperature" +WEIGHT_PROPERTY = "Weight" + class MultilevelSensorType(IntEnum): """Enum for known multilevel sensor types.""" # https://github.com/zwave-js/node-zwave-js/blob/master/packages/config/config/sensorTypes.json + UNKNOWN = -1 ACCELERATION_X_AXIS = 52 ACCELERATION_Y_AXIS = 53 ACCELERATION_Z_AXIS = 54 @@ -106,6 +196,11 @@ class MultilevelSensorType(IntEnum): WATER_TEMPERATURE = 23 WEIGHT = 14 + @classmethod + def _missing_(cls: type, value: object) -> MultilevelSensorType: # noqa: ARG003 + """Set default enum member if an unknown value is provided.""" + return MultilevelSensorType.UNKNOWN + class MultilevelSensorScaleType(IntEnum): """Common base class for multilevel sensor scale enums.""" @@ -115,425 +210,765 @@ class AirFlowScale(MultilevelSensorScaleType): """Enum for known scales for AIR_FLOW multilevel sensor types.""" # https://github.com/zwave-js/node-zwave-js/blob/master/packages/config/config/sensorTypes.json + UNKNOWN = -1 CUBIC_FEET_PER_MINUTE = 1 CUBIC_METER_PER_HOUR = 0 + @classmethod + def _missing_(cls: type, value: object) -> AirFlowScale: # noqa: ARG003 + """Set default enum member if an unknown value is provided.""" + return AirFlowScale.UNKNOWN + class AnglePositionScale(MultilevelSensorScaleType): """Enum for known scales for ANGLE_POSITION multilevel sensor types.""" # https://github.com/zwave-js/node-zwave-js/blob/master/packages/config/config/sensorTypes.json + UNKNOWN = -1 DEGREES_RELATIVE_TO_NORTH_POLE_OF_STANDING_EYE_VIEW = 1 DEGREES_RELATIVE_TO_SOUTH_POLE_OF_STANDING_EYE_VIEW = 2 PERCENTAGE_VALUE = 0 + @classmethod + def _missing_(cls: type, value: object) -> AnglePositionScale: # noqa: ARG003 + """Set default enum member if an unknown value is provided.""" + return AnglePositionScale.UNKNOWN + class AppliedForceOnTheSensorScale(MultilevelSensorScaleType): """Enum for known scales for APPLIED_FORCE_ON_THE_SENSOR multilevel sensor types.""" # https://github.com/zwave-js/node-zwave-js/blob/master/packages/config/config/sensorTypes.json + UNKNOWN = -1 NEWTON = 0 + @classmethod + def _missing_( + cls: type, value: object + ) -> AppliedForceOnTheSensorScale: # noqa: ARG003 + """Set default enum member if an unknown value is provided.""" + return AppliedForceOnTheSensorScale.UNKNOWN + class AccelerationScale(MultilevelSensorScaleType): """Enum for known scales for Acceleration multilevel sensor types.""" # https://github.com/zwave-js/node-zwave-js/blob/master/packages/config/config/sensorTypes.json + UNKNOWN = -1 METER_PER_SQUARE_SECOND = 0 + @classmethod + def _missing_(cls: type, value: object) -> AccelerationScale: # noqa: ARG003 + """Set default enum member if an unknown value is provided.""" + return AccelerationScale.UNKNOWN + class AcidityScale(MultilevelSensorScaleType): """Enum for known scales for Acidity multilevel sensor types.""" # https://github.com/zwave-js/node-zwave-js/blob/master/packages/config/config/sensorTypes.json + UNKNOWN = -1 ACIDITY = 0 + @classmethod + def _missing_(cls: type, value: object) -> AcidityScale: # noqa: ARG003 + """Set default enum member if an unknown value is provided.""" + return AcidityScale.UNKNOWN + class AirPressureScale(MultilevelSensorScaleType): """Enum for known scales for Air Pressure multilevel sensor types.""" # https://github.com/zwave-js/node-zwave-js/blob/master/packages/config/config/sensorTypes.json + UNKNOWN = -1 INCHES_OF_MERCURY = 1 KILOPASCAL = 0 + @classmethod + def _missing_(cls: type, value: object) -> AirPressureScale: # noqa: ARG003 + """Set default enum member if an unknown value is provided.""" + return AirPressureScale.UNKNOWN + class BasisMetabolicRateScale(MultilevelSensorScaleType): """Enum for known scales for BASIS_METABOLIC_RATE multilevel sensor types.""" # https://github.com/zwave-js/node-zwave-js/blob/master/packages/config/config/sensorTypes.json + UNKNOWN = -1 JOULE = 0 + @classmethod + def _missing_(cls: type, value: object) -> BasisMetabolicRateScale: # noqa: ARG003 + """Set default enum member if an unknown value is provided.""" + return BasisMetabolicRateScale.UNKNOWN + class BloodPressureScale(MultilevelSensorScaleType): """Enum for known scales for BLOOD_PRESSURE multilevel sensor types.""" # https://github.com/zwave-js/node-zwave-js/blob/master/packages/config/config/sensorTypes.json + UNKNOWN = -1 DIASTOLIC = 1 SYSTOLIC = 0 + @classmethod + def _missing_(cls: type, value: object) -> BloodPressureScale: # noqa: ARG003 + """Set default enum member if an unknown value is provided.""" + return BloodPressureScale.UNKNOWN + class BodyMassIndexScale(MultilevelSensorScaleType): """Enum for known scales for BODY_MASS_INDEX multilevel sensor types.""" # https://github.com/zwave-js/node-zwave-js/blob/master/packages/config/config/sensorTypes.json + UNKNOWN = -1 BODY_MASS_INDEX = 0 + @classmethod + def _missing_(cls: type, value: object) -> BodyMassIndexScale: # noqa: ARG003 + """Set default enum member if an unknown value is provided.""" + return BodyMassIndexScale.UNKNOWN + class CarbonDioxideLevelScale(MultilevelSensorScaleType): """Enum for known scales for CARBON_DIOXIDE_LEVEL multilevel sensor types.""" # https://github.com/zwave-js/node-zwave-js/blob/master/packages/config/config/sensorTypes.json + UNKNOWN = -1 PARTS_MILLION = 0 + @classmethod + def _missing_(cls: type, value: object) -> CarbonDioxideLevelScale: # noqa: ARG003 + """Set default enum member if an unknown value is provided.""" + return CarbonDioxideLevelScale.UNKNOWN + class CarbonMonoxideLevelScale(MultilevelSensorScaleType): """Enum for known scales for CARBON_MONOXIDE_LEVEL multilevel sensor types.""" # https://github.com/zwave-js/node-zwave-js/blob/master/packages/config/config/sensorTypes.json + UNKNOWN = -1 MOLE_PER_CUBIC_METER = 0 PARTS_MILLION = 1 + @classmethod + def _missing_(cls: type, value: object) -> CarbonMonoxideLevelScale: # noqa: ARG003 + """Set default enum member if an unknown value is provided.""" + return CarbonMonoxideLevelScale.UNKNOWN + class CurrentScale(MultilevelSensorScaleType): """Enum for known scales for CURRENT multilevel sensor types.""" # https://github.com/zwave-js/node-zwave-js/blob/master/packages/config/config/sensorTypes.json + UNKNOWN = -1 AMPERE = 0 MILLIAMPERE = 1 + @classmethod + def _missing_(cls: type, value: object) -> CurrentScale: # noqa: ARG003 + """Set default enum member if an unknown value is provided.""" + return CurrentScale.UNKNOWN + class DistanceScale(MultilevelSensorScaleType): """Enum for known scales for DISTANCE multilevel sensor types.""" # https://github.com/zwave-js/node-zwave-js/blob/master/packages/config/config/sensorTypes.json + UNKNOWN = -1 CENTIMETER = 1 FEET = 2 METER = 0 + @classmethod + def _missing_(cls: type, value: object) -> DistanceScale: # noqa: ARG003 + """Set default enum member if an unknown value is provided.""" + return DistanceScale.UNKNOWN + class DensityScale(MultilevelSensorScaleType): """Enum for known scales for Density multilevel sensor types.""" # https://github.com/zwave-js/node-zwave-js/blob/master/packages/config/config/sensorTypes.json + UNKNOWN = -1 DENSITY = 0 + @classmethod + def _missing_(cls: type, value: object) -> DensityScale: # noqa: ARG003 + """Set default enum member if an unknown value is provided.""" + return DensityScale.UNKNOWN + class DirectionScale(MultilevelSensorScaleType): """Enum for known scales for Direction multilevel sensor types.""" # https://github.com/zwave-js/node-zwave-js/blob/master/packages/config/config/sensorTypes.json + UNKNOWN = -1 DEGREES = 0 + @classmethod + def _missing_(cls: type, value: object) -> DirectionScale: # noqa: ARG003 + """Set default enum member if an unknown value is provided.""" + return DirectionScale.UNKNOWN + class ElectricalConductivityScale(MultilevelSensorScaleType): """Enum for known scales for ELECTRICAL_CONDUCTIVITY multilevel sensor types.""" # https://github.com/zwave-js/node-zwave-js/blob/master/packages/config/config/sensorTypes.json + UNKNOWN = -1 SIEMENS_PER_METER = 0 + @classmethod + def _missing_( + cls: type, value: object + ) -> ElectricalConductivityScale: # noqa: ARG003 + """Set default enum member if an unknown value is provided.""" + return ElectricalConductivityScale.UNKNOWN + class ElectricalResistivityScale(MultilevelSensorScaleType): """Enum for known scales for ELECTRICAL_RESISTIVITY multilevel sensor types.""" # https://github.com/zwave-js/node-zwave-js/blob/master/packages/config/config/sensorTypes.json + UNKNOWN = -1 OHM_METER = 0 + @classmethod + def _missing_( + cls: type, value: object + ) -> ElectricalResistivityScale: # noqa: ARG003 + """Set default enum member if an unknown value is provided.""" + return ElectricalResistivityScale.UNKNOWN + class FormaldehydeLevelScale(MultilevelSensorScaleType): """Enum for known scales for FORMALDEHYDE_LEVEL multilevel sensor types.""" # https://github.com/zwave-js/node-zwave-js/blob/master/packages/config/config/sensorTypes.json + UNKNOWN = -1 MOLE_PER_CUBIC_METER = 0 + @classmethod + def _missing_(cls: type, value: object) -> FormaldehydeLevelScale: # noqa: ARG003 + """Set default enum member if an unknown value is provided.""" + return FormaldehydeLevelScale.UNKNOWN + class FrequencyScale(MultilevelSensorScaleType): """Enum for known scales for FREQUENCY multilevel sensor types.""" # https://github.com/zwave-js/node-zwave-js/blob/master/packages/config/config/sensorTypes.json + UNKNOWN = -1 HERTZ = 0 KILOHERTZ = 1 + @classmethod + def _missing_(cls: type, value: object) -> FrequencyScale: # noqa: ARG003 + """Set default enum member if an unknown value is provided.""" + return FrequencyScale.UNKNOWN + class GeneralPurposeScale(MultilevelSensorScaleType): """Enum for known scales for GENERAL_PURPOSE multilevel sensor types.""" # https://github.com/zwave-js/node-zwave-js/blob/master/packages/config/config/sensorTypes.json + UNKNOWN = -1 DIMENSIONLESS_VALUE = 1 PERCENTAGE_VALUE = 0 + @classmethod + def _missing_(cls: type, value: object) -> GeneralPurposeScale: # noqa: ARG003 + """Set default enum member if an unknown value is provided.""" + return GeneralPurposeScale.UNKNOWN + class HeartRateScale(MultilevelSensorScaleType): """Enum for known scales for HEART_RATE multilevel sensor types.""" # https://github.com/zwave-js/node-zwave-js/blob/master/packages/config/config/sensorTypes.json + UNKNOWN = -1 BEATS_PER_MINUTE = 0 + @classmethod + def _missing_(cls: type, value: object) -> HeartRateScale: # noqa: ARG003 + """Set default enum member if an unknown value is provided.""" + return HeartRateScale.UNKNOWN + class HumidityScale(MultilevelSensorScaleType): """Enum for known scales for Humidity multilevel sensor types.""" # https://github.com/zwave-js/node-zwave-js/blob/master/packages/config/config/sensorTypes.json + UNKNOWN = -1 ABSOLUTE_HUMIDITY = 1 PERCENTAGE_VALUE = 0 + @classmethod + def _missing_(cls: type, value: object) -> HumidityScale: # noqa: ARG003 + """Set default enum member if an unknown value is provided.""" + return HumidityScale.UNKNOWN + class IlluminanceScale(MultilevelSensorScaleType): """Enum for known scales for ILLUMINANCE multilevel sensor types.""" # https://github.com/zwave-js/node-zwave-js/blob/master/packages/config/config/sensorTypes.json + UNKNOWN = -1 LUX = 1 PERCENTAGE_VALUE = 0 + @classmethod + def _missing_(cls: type, value: object) -> IlluminanceScale: # noqa: ARG003 + """Set default enum member if an unknown value is provided.""" + return IlluminanceScale.UNKNOWN + class LoudnessScale(MultilevelSensorScaleType): """Enum for known scales for LOUDNESS multilevel sensor types.""" # https://github.com/zwave-js/node-zwave-js/blob/master/packages/config/config/sensorTypes.json + UNKNOWN = -1 A_WEIGHTED_DECIBELS = 1 DECIBEL = 0 + @classmethod + def _missing_(cls: type, value: object) -> LoudnessScale: # noqa: ARG003 + """Set default enum member if an unknown value is provided.""" + return LoudnessScale.UNKNOWN + class MethaneDensityScale(MultilevelSensorScaleType): """Enum for known scales for METHANE_DENSITY multilevel sensor types.""" # https://github.com/zwave-js/node-zwave-js/blob/master/packages/config/config/sensorTypes.json + UNKNOWN = -1 MOLE_PER_CUBIC_METER = 0 + @classmethod + def _missing_(cls: type, value: object) -> MethaneDensityScale: # noqa: ARG003 + """Set default enum member if an unknown value is provided.""" + return MethaneDensityScale.UNKNOWN + class MoistureScale(MultilevelSensorScaleType): """Enum for known scales for MOISTURE multilevel sensor types.""" # https://github.com/zwave-js/node-zwave-js/blob/master/packages/config/config/sensorTypes.json + UNKNOWN = -1 IMPEDANCE = 2 PERCENTAGE_VALUE = 0 VOLUME_WATER_CONTENT = 1 WATER_ACTIVITY = 3 + @classmethod + def _missing_(cls: type, value: object) -> MoistureScale: # noqa: ARG003 + """Set default enum member if an unknown value is provided.""" + return MoistureScale.UNKNOWN + class MassScale(MultilevelSensorScaleType): """Enum for known scales for Mass multilevel sensor types.""" # https://github.com/zwave-js/node-zwave-js/blob/master/packages/config/config/sensorTypes.json + UNKNOWN = -1 KILOGRAM = 0 + @classmethod + def _missing_(cls: type, value: object) -> MassScale: # noqa: ARG003 + """Set default enum member if an unknown value is provided.""" + return MassScale.UNKNOWN + class ParticulateMatter10Scale(MultilevelSensorScaleType): """Enum for known scales for PARTICULATE_MATTER_10 multilevel sensor types.""" # https://github.com/zwave-js/node-zwave-js/blob/master/packages/config/config/sensorTypes.json + UNKNOWN = -1 MICROGRAM_PER_CUBIC_METER = 1 MOLE_PER_CUBIC_METER = 0 + @classmethod + def _missing_(cls: type, value: object) -> ParticulateMatter10Scale: # noqa: ARG003 + """Set default enum member if an unknown value is provided.""" + return ParticulateMatter10Scale.UNKNOWN + class ParticulateMatter25Scale(MultilevelSensorScaleType): """Enum for known scales for PARTICULATE_MATTER_2_5 multilevel sensor types.""" # https://github.com/zwave-js/node-zwave-js/blob/master/packages/config/config/sensorTypes.json + UNKNOWN = -1 MICROGRAM_PER_CUBIC_METER = 1 MOLE_PER_CUBIC_METER = 0 + @classmethod + def _missing_(cls: type, value: object) -> ParticulateMatter25Scale: # noqa: ARG003 + """Set default enum member if an unknown value is provided.""" + return ParticulateMatter25Scale.UNKNOWN + class PowerScale(MultilevelSensorScaleType): """Enum for known scales for POWER multilevel sensor types.""" # https://github.com/zwave-js/node-zwave-js/blob/master/packages/config/config/sensorTypes.json + UNKNOWN = -1 BTU_H = 1 WATT = 0 + @classmethod + def _missing_(cls: type, value: object) -> PowerScale: # noqa: ARG003 + """Set default enum member if an unknown value is provided.""" + return PowerScale.UNKNOWN + class PercentageScale(MultilevelSensorScaleType): """Enum for known scales for Percentage multilevel sensor types.""" # https://github.com/zwave-js/node-zwave-js/blob/master/packages/config/config/sensorTypes.json + UNKNOWN = -1 PERCENTAGE_VALUE = 0 + @classmethod + def _missing_(cls: type, value: object) -> PercentageScale: # noqa: ARG003 + """Set default enum member if an unknown value is provided.""" + return PercentageScale.UNKNOWN + class PressureScale(MultilevelSensorScaleType): """Enum for known scales for Pressure multilevel sensor types.""" # https://github.com/zwave-js/node-zwave-js/blob/master/packages/config/config/sensorTypes.json + UNKNOWN = -1 KILOPASCAL = 0 POUND_PER_SQUARE_INCH = 1 + @classmethod + def _missing_(cls: type, value: object) -> PressureScale: # noqa: ARG003 + """Set default enum member if an unknown value is provided.""" + return PressureScale.UNKNOWN + class RadonConcentrationScale(MultilevelSensorScaleType): """Enum for known scales for RADON_CONCENTRATION multilevel sensor types.""" # https://github.com/zwave-js/node-zwave-js/blob/master/packages/config/config/sensorTypes.json + UNKNOWN = -1 BECQUEREL_PER_CUBIC_METER = 0 PICOCURIES_PER_LITER = 1 + @classmethod + def _missing_(cls: type, value: object) -> RadonConcentrationScale: # noqa: ARG003 + """Set default enum member if an unknown value is provided.""" + return RadonConcentrationScale.UNKNOWN + class RainRateScale(MultilevelSensorScaleType): """Enum for known scales for RAIN_RATE multilevel sensor types.""" # https://github.com/zwave-js/node-zwave-js/blob/master/packages/config/config/sensorTypes.json + UNKNOWN = -1 INCHES_PER_HOUR = 1 MILLIMETER_HOUR = 0 + @classmethod + def _missing_(cls: type, value: object) -> RainRateScale: # noqa: ARG003 + """Set default enum member if an unknown value is provided.""" + return RainRateScale.UNKNOWN + class RespiratoryRateScale(MultilevelSensorScaleType): """Enum for known scales for RESPIRATORY_RATE multilevel sensor types.""" # https://github.com/zwave-js/node-zwave-js/blob/master/packages/config/config/sensorTypes.json + UNKNOWN = -1 BREATHS_PER_MINUTE = 0 + @classmethod + def _missing_(cls: type, value: object) -> RespiratoryRateScale: # noqa: ARG003 + """Set default enum member if an unknown value is provided.""" + return RespiratoryRateScale.UNKNOWN + class RfSignalStrengthScale(MultilevelSensorScaleType): """Enum for known scales for RF_SIGNAL_STRENGTH multilevel sensor types.""" # https://github.com/zwave-js/node-zwave-js/blob/master/packages/config/config/sensorTypes.json + UNKNOWN = -1 POWER_LEVEL = 1 RSSI = 0 + @classmethod + def _missing_(cls: type, value: object) -> RfSignalStrengthScale: # noqa: ARG003 + """Set default enum member if an unknown value is provided.""" + return RfSignalStrengthScale.UNKNOWN + class RotationScale(MultilevelSensorScaleType): """Enum for known scales for ROTATION multilevel sensor types.""" # https://github.com/zwave-js/node-zwave-js/blob/master/packages/config/config/sensorTypes.json + UNKNOWN = -1 HERTZ = 1 REVOLUTIONS_PER_MINUTE = 0 + @classmethod + def _missing_(cls: type, value: object) -> RotationScale: # noqa: ARG003 + """Set default enum member if an unknown value is provided.""" + return RotationScale.UNKNOWN + class SeismicIntensityScale(MultilevelSensorScaleType): """Enum for known scales for SEISMIC_INTENSITY multilevel sensor types.""" # https://github.com/zwave-js/node-zwave-js/blob/master/packages/config/config/sensorTypes.json + UNKNOWN = -1 EUROPEAN_MACROSEISMIC = 1 LIEDU = 2 MERCALLI = 0 SHINDO = 3 + @classmethod + def _missing_(cls: type, value: object) -> SeismicIntensityScale: # noqa: ARG003 + """Set default enum member if an unknown value is provided.""" + return SeismicIntensityScale.UNKNOWN + class SeismicMagnitudeScale(MultilevelSensorScaleType): """Enum for known scales for SEISMIC_MAGNITUDE multilevel sensor types.""" # https://github.com/zwave-js/node-zwave-js/blob/master/packages/config/config/sensorTypes.json + UNKNOWN = -1 BODY_WAVE = 3 LOCAL = 0 MOMENT = 1 SURFACE_WAVE = 2 + @classmethod + def _missing_(cls: type, value: object) -> SeismicMagnitudeScale: # noqa: ARG003 + """Set default enum member if an unknown value is provided.""" + return SeismicMagnitudeScale.UNKNOWN + class SoilSalinityScale(MultilevelSensorScaleType): """Enum for known scales for SOIL_SALINITY multilevel sensor types.""" # https://github.com/zwave-js/node-zwave-js/blob/master/packages/config/config/sensorTypes.json + UNKNOWN = -1 MOLE_PER_CUBIC_METER = 0 + @classmethod + def _missing_(cls: type, value: object) -> SoilSalinityScale: # noqa: ARG003 + """Set default enum member if an unknown value is provided.""" + return SoilSalinityScale.UNKNOWN + class SolarRadiationScale(MultilevelSensorScaleType): """Enum for known scales for SOLAR_RADIATION multilevel sensor types.""" # https://github.com/zwave-js/node-zwave-js/blob/master/packages/config/config/sensorTypes.json + UNKNOWN = -1 WATT_PER_SQUARE_METER = 0 + @classmethod + def _missing_(cls: type, value: object) -> SolarRadiationScale: # noqa: ARG003 + """Set default enum member if an unknown value is provided.""" + return SolarRadiationScale.UNKNOWN + class TankCapacityScale(MultilevelSensorScaleType): """Enum for known scales for TANK_CAPACITY multilevel sensor types.""" # https://github.com/zwave-js/node-zwave-js/blob/master/packages/config/config/sensorTypes.json + UNKNOWN = -1 CUBIC_METER = 1 GALLONS = 2 LITER = 0 + @classmethod + def _missing_(cls: type, value: object) -> TankCapacityScale: # noqa: ARG003 + """Set default enum member if an unknown value is provided.""" + return TankCapacityScale.UNKNOWN + class TideLevelScale(MultilevelSensorScaleType): """Enum for known scales for TIDE_LEVEL multilevel sensor types.""" # https://github.com/zwave-js/node-zwave-js/blob/master/packages/config/config/sensorTypes.json + UNKNOWN = -1 FEET = 1 METER = 0 + @classmethod + def _missing_(cls: type, value: object) -> TideLevelScale: # noqa: ARG003 + """Set default enum member if an unknown value is provided.""" + return TideLevelScale.UNKNOWN + class TimeScale(MultilevelSensorScaleType): """Enum for known scales for TIME multilevel sensor types.""" # https://github.com/zwave-js/node-zwave-js/blob/master/packages/config/config/sensorTypes.json + UNKNOWN = -1 SECOND = 0 + @classmethod + def _missing_(cls: type, value: object) -> TimeScale: # noqa: ARG003 + """Set default enum member if an unknown value is provided.""" + return TimeScale.UNKNOWN + class TemperatureScale(MultilevelSensorScaleType): """Enum for known scales for Temperature multilevel sensor types.""" # https://github.com/zwave-js/node-zwave-js/blob/master/packages/config/config/sensorTypes.json + UNKNOWN = -1 CELSIUS = 0 FAHRENHEIT = 1 + @classmethod + def _missing_(cls: type, value: object) -> TemperatureScale: # noqa: ARG003 + """Set default enum member if an unknown value is provided.""" + return TemperatureScale.UNKNOWN + class UltravioletScale(MultilevelSensorScaleType): """Enum for known scales for ULTRAVIOLET multilevel sensor types.""" # https://github.com/zwave-js/node-zwave-js/blob/master/packages/config/config/sensorTypes.json + UNKNOWN = -1 UV_INDEX = 0 + @classmethod + def _missing_(cls: type, value: object) -> UltravioletScale: # noqa: ARG003 + """Set default enum member if an unknown value is provided.""" + return UltravioletScale.UNKNOWN + class UnitlessScale(MultilevelSensorScaleType): """Enum for known scales for Unitless multilevel sensor types.""" # https://github.com/zwave-js/node-zwave-js/blob/master/packages/config/config/sensorTypes.json + UNKNOWN = -1 UNITLESS = 0 + @classmethod + def _missing_(cls: type, value: object) -> UnitlessScale: # noqa: ARG003 + """Set default enum member if an unknown value is provided.""" + return UnitlessScale.UNKNOWN + class VelocityScale(MultilevelSensorScaleType): """Enum for known scales for VELOCITY multilevel sensor types.""" # https://github.com/zwave-js/node-zwave-js/blob/master/packages/config/config/sensorTypes.json + UNKNOWN = -1 MPH = 1 M_S = 0 + @classmethod + def _missing_(cls: type, value: object) -> VelocityScale: # noqa: ARG003 + """Set default enum member if an unknown value is provided.""" + return VelocityScale.UNKNOWN + class VolatileOrganicCompoundLevelScale(MultilevelSensorScaleType): """Enum for known scales for VOLATILE_ORGANIC_COMPOUND_LEVEL multilevel sensor types.""" # https://github.com/zwave-js/node-zwave-js/blob/master/packages/config/config/sensorTypes.json + UNKNOWN = -1 MOLE_PER_CUBIC_METER = 0 PARTS_MILLION = 1 + @classmethod + def _missing_( + cls: type, value: object + ) -> VolatileOrganicCompoundLevelScale: # noqa: ARG003 + """Set default enum member if an unknown value is provided.""" + return VolatileOrganicCompoundLevelScale.UNKNOWN + class VoltageScale(MultilevelSensorScaleType): """Enum for known scales for VOLTAGE multilevel sensor types.""" # https://github.com/zwave-js/node-zwave-js/blob/master/packages/config/config/sensorTypes.json + UNKNOWN = -1 MILLIVOLT = 1 VOLT = 0 + @classmethod + def _missing_(cls: type, value: object) -> VoltageScale: # noqa: ARG003 + """Set default enum member if an unknown value is provided.""" + return VoltageScale.UNKNOWN + class WaterChlorineLevelScale(MultilevelSensorScaleType): """Enum for known scales for WATER_CHLORINE_LEVEL multilevel sensor types.""" # https://github.com/zwave-js/node-zwave-js/blob/master/packages/config/config/sensorTypes.json + UNKNOWN = -1 MILLIGRAM_PER_LITER = 0 + @classmethod + def _missing_(cls: type, value: object) -> WaterChlorineLevelScale: # noqa: ARG003 + """Set default enum member if an unknown value is provided.""" + return WaterChlorineLevelScale.UNKNOWN + class WaterFlowScale(MultilevelSensorScaleType): """Enum for known scales for WATER_FLOW multilevel sensor types.""" # https://github.com/zwave-js/node-zwave-js/blob/master/packages/config/config/sensorTypes.json + UNKNOWN = -1 LITER_PER_HOUR = 0 + @classmethod + def _missing_(cls: type, value: object) -> WaterFlowScale: # noqa: ARG003 + """Set default enum member if an unknown value is provided.""" + return WaterFlowScale.UNKNOWN + class WaterOxidationReductionPotentialScale(MultilevelSensorScaleType): """Enum for known scales for WATER_OXIDATION_REDUCTION_POTENTIAL multilevel sensor types.""" # https://github.com/zwave-js/node-zwave-js/blob/master/packages/config/config/sensorTypes.json + UNKNOWN = -1 MILLIVOLT = 0 + @classmethod + def _missing_( + cls: type, value: object + ) -> WaterOxidationReductionPotentialScale: # noqa: ARG003 + """Set default enum member if an unknown value is provided.""" + return WaterOxidationReductionPotentialScale.UNKNOWN + class WaterPressureScale(MultilevelSensorScaleType): """Enum for known scales for WATER_PRESSURE multilevel sensor types.""" # https://github.com/zwave-js/node-zwave-js/blob/master/packages/config/config/sensorTypes.json + UNKNOWN = -1 KILOPASCAL = 0 + @classmethod + def _missing_(cls: type, value: object) -> WaterPressureScale: # noqa: ARG003 + """Set default enum member if an unknown value is provided.""" + return WaterPressureScale.UNKNOWN + class WeightScale(MultilevelSensorScaleType): """Enum for known scales for WEIGHT multilevel sensor types.""" # https://github.com/zwave-js/node-zwave-js/blob/master/packages/config/config/sensorTypes.json + UNKNOWN = -1 KILOGRAM = 0 POUNDS = 1 + @classmethod + def _missing_(cls: type, value: object) -> WeightScale: # noqa: ARG003 + """Set default enum member if an unknown value is provided.""" + return WeightScale.UNKNOWN + MULTILEVEL_SENSOR_TYPE_TO_SCALE_MAP: dict[ MultilevelSensorType, type[MultilevelSensorScaleType] diff --git a/zwave_js_server/const/command_class/notification.py b/zwave_js_server/const/command_class/notification.py index 414ea4a99..b813ef18a 100644 --- a/zwave_js_server/const/command_class/notification.py +++ b/zwave_js_server/const/command_class/notification.py @@ -17,6 +17,7 @@ class NotificationType(IntEnum): """Enum for known notification types.""" # https://github.com/zwave-js/node-zwave-js/blob/master/packages/config/config/notifications.json + UNKNOWN = -1 ACCESS_CONTROL = 6 APPLIANCE = 12 CLOCK = 11 @@ -40,6 +41,11 @@ class NotificationType(IntEnum): WATER_VALVE = 15 WEATHER_ALARM = 16 + @classmethod + def _missing_(cls: type, value: object) -> NotificationType: # noqa: ARG003 + """Set default enum member if an unknown value is provided.""" + return NotificationType.UNKNOWN + class NotificationEvent(IntEnum): """Common base class for Notification CC states enums.""" From cfb78c07da411076055e9ccaa2e64e265b9b3480 Mon Sep 17 00:00:00 2001 From: Raman Gupta <7243222+raman325@users.noreply.github.com> Date: Wed, 6 Dec 2023 23:55:29 -0500 Subject: [PATCH 2/2] Revert change to add a fallback --- .../generate_multilevel_sensor_constants.py | 9 - .../const/command_class/multilevel_sensor.py | 346 ------------------ 2 files changed, 355 deletions(-) diff --git a/scripts/generate_multilevel_sensor_constants.py b/scripts/generate_multilevel_sensor_constants.py index 85e16df11..181036911 100755 --- a/scripts/generate_multilevel_sensor_constants.py +++ b/scripts/generate_multilevel_sensor_constants.py @@ -132,19 +132,10 @@ def generate_int_enum_class_definition( class_def.append(f" {docstring}") if enum_ref_url: class_def.append(f" # {enum_ref_url}") - class_def.append(" UNKNOWN = -1") for enum_name, enum_id in enum_map.items(): if get_id_func: enum_id = get_id_func(enum_id) class_def.append(f" {enum_name} = {enum_id}") - class_def.extend( - [ - " @classmethod", - f" def _missing_(cls: type, value: object) -> {class_name}: # noqa: ARG003", - ' """Set default enum member if an unknown value is provided."""', - f" return {class_name}.UNKNOWN", - ] - ) return class_def diff --git a/zwave_js_server/const/command_class/multilevel_sensor.py b/zwave_js_server/const/command_class/multilevel_sensor.py index 2f3615945..c05330d25 100644 --- a/zwave_js_server/const/command_class/multilevel_sensor.py +++ b/zwave_js_server/const/command_class/multilevel_sensor.py @@ -106,7 +106,6 @@ class MultilevelSensorType(IntEnum): """Enum for known multilevel sensor types.""" # https://github.com/zwave-js/node-zwave-js/blob/master/packages/config/config/sensorTypes.json - UNKNOWN = -1 ACCELERATION_X_AXIS = 52 ACCELERATION_Y_AXIS = 53 ACCELERATION_Z_AXIS = 54 @@ -196,11 +195,6 @@ class MultilevelSensorType(IntEnum): WATER_TEMPERATURE = 23 WEIGHT = 14 - @classmethod - def _missing_(cls: type, value: object) -> MultilevelSensorType: # noqa: ARG003 - """Set default enum member if an unknown value is provided.""" - return MultilevelSensorType.UNKNOWN - class MultilevelSensorScaleType(IntEnum): """Common base class for multilevel sensor scale enums.""" @@ -210,765 +204,425 @@ class AirFlowScale(MultilevelSensorScaleType): """Enum for known scales for AIR_FLOW multilevel sensor types.""" # https://github.com/zwave-js/node-zwave-js/blob/master/packages/config/config/sensorTypes.json - UNKNOWN = -1 CUBIC_FEET_PER_MINUTE = 1 CUBIC_METER_PER_HOUR = 0 - @classmethod - def _missing_(cls: type, value: object) -> AirFlowScale: # noqa: ARG003 - """Set default enum member if an unknown value is provided.""" - return AirFlowScale.UNKNOWN - class AnglePositionScale(MultilevelSensorScaleType): """Enum for known scales for ANGLE_POSITION multilevel sensor types.""" # https://github.com/zwave-js/node-zwave-js/blob/master/packages/config/config/sensorTypes.json - UNKNOWN = -1 DEGREES_RELATIVE_TO_NORTH_POLE_OF_STANDING_EYE_VIEW = 1 DEGREES_RELATIVE_TO_SOUTH_POLE_OF_STANDING_EYE_VIEW = 2 PERCENTAGE_VALUE = 0 - @classmethod - def _missing_(cls: type, value: object) -> AnglePositionScale: # noqa: ARG003 - """Set default enum member if an unknown value is provided.""" - return AnglePositionScale.UNKNOWN - class AppliedForceOnTheSensorScale(MultilevelSensorScaleType): """Enum for known scales for APPLIED_FORCE_ON_THE_SENSOR multilevel sensor types.""" # https://github.com/zwave-js/node-zwave-js/blob/master/packages/config/config/sensorTypes.json - UNKNOWN = -1 NEWTON = 0 - @classmethod - def _missing_( - cls: type, value: object - ) -> AppliedForceOnTheSensorScale: # noqa: ARG003 - """Set default enum member if an unknown value is provided.""" - return AppliedForceOnTheSensorScale.UNKNOWN - class AccelerationScale(MultilevelSensorScaleType): """Enum for known scales for Acceleration multilevel sensor types.""" # https://github.com/zwave-js/node-zwave-js/blob/master/packages/config/config/sensorTypes.json - UNKNOWN = -1 METER_PER_SQUARE_SECOND = 0 - @classmethod - def _missing_(cls: type, value: object) -> AccelerationScale: # noqa: ARG003 - """Set default enum member if an unknown value is provided.""" - return AccelerationScale.UNKNOWN - class AcidityScale(MultilevelSensorScaleType): """Enum for known scales for Acidity multilevel sensor types.""" # https://github.com/zwave-js/node-zwave-js/blob/master/packages/config/config/sensorTypes.json - UNKNOWN = -1 ACIDITY = 0 - @classmethod - def _missing_(cls: type, value: object) -> AcidityScale: # noqa: ARG003 - """Set default enum member if an unknown value is provided.""" - return AcidityScale.UNKNOWN - class AirPressureScale(MultilevelSensorScaleType): """Enum for known scales for Air Pressure multilevel sensor types.""" # https://github.com/zwave-js/node-zwave-js/blob/master/packages/config/config/sensorTypes.json - UNKNOWN = -1 INCHES_OF_MERCURY = 1 KILOPASCAL = 0 - @classmethod - def _missing_(cls: type, value: object) -> AirPressureScale: # noqa: ARG003 - """Set default enum member if an unknown value is provided.""" - return AirPressureScale.UNKNOWN - class BasisMetabolicRateScale(MultilevelSensorScaleType): """Enum for known scales for BASIS_METABOLIC_RATE multilevel sensor types.""" # https://github.com/zwave-js/node-zwave-js/blob/master/packages/config/config/sensorTypes.json - UNKNOWN = -1 JOULE = 0 - @classmethod - def _missing_(cls: type, value: object) -> BasisMetabolicRateScale: # noqa: ARG003 - """Set default enum member if an unknown value is provided.""" - return BasisMetabolicRateScale.UNKNOWN - class BloodPressureScale(MultilevelSensorScaleType): """Enum for known scales for BLOOD_PRESSURE multilevel sensor types.""" # https://github.com/zwave-js/node-zwave-js/blob/master/packages/config/config/sensorTypes.json - UNKNOWN = -1 DIASTOLIC = 1 SYSTOLIC = 0 - @classmethod - def _missing_(cls: type, value: object) -> BloodPressureScale: # noqa: ARG003 - """Set default enum member if an unknown value is provided.""" - return BloodPressureScale.UNKNOWN - class BodyMassIndexScale(MultilevelSensorScaleType): """Enum for known scales for BODY_MASS_INDEX multilevel sensor types.""" # https://github.com/zwave-js/node-zwave-js/blob/master/packages/config/config/sensorTypes.json - UNKNOWN = -1 BODY_MASS_INDEX = 0 - @classmethod - def _missing_(cls: type, value: object) -> BodyMassIndexScale: # noqa: ARG003 - """Set default enum member if an unknown value is provided.""" - return BodyMassIndexScale.UNKNOWN - class CarbonDioxideLevelScale(MultilevelSensorScaleType): """Enum for known scales for CARBON_DIOXIDE_LEVEL multilevel sensor types.""" # https://github.com/zwave-js/node-zwave-js/blob/master/packages/config/config/sensorTypes.json - UNKNOWN = -1 PARTS_MILLION = 0 - @classmethod - def _missing_(cls: type, value: object) -> CarbonDioxideLevelScale: # noqa: ARG003 - """Set default enum member if an unknown value is provided.""" - return CarbonDioxideLevelScale.UNKNOWN - class CarbonMonoxideLevelScale(MultilevelSensorScaleType): """Enum for known scales for CARBON_MONOXIDE_LEVEL multilevel sensor types.""" # https://github.com/zwave-js/node-zwave-js/blob/master/packages/config/config/sensorTypes.json - UNKNOWN = -1 MOLE_PER_CUBIC_METER = 0 PARTS_MILLION = 1 - @classmethod - def _missing_(cls: type, value: object) -> CarbonMonoxideLevelScale: # noqa: ARG003 - """Set default enum member if an unknown value is provided.""" - return CarbonMonoxideLevelScale.UNKNOWN - class CurrentScale(MultilevelSensorScaleType): """Enum for known scales for CURRENT multilevel sensor types.""" # https://github.com/zwave-js/node-zwave-js/blob/master/packages/config/config/sensorTypes.json - UNKNOWN = -1 AMPERE = 0 MILLIAMPERE = 1 - @classmethod - def _missing_(cls: type, value: object) -> CurrentScale: # noqa: ARG003 - """Set default enum member if an unknown value is provided.""" - return CurrentScale.UNKNOWN - class DistanceScale(MultilevelSensorScaleType): """Enum for known scales for DISTANCE multilevel sensor types.""" # https://github.com/zwave-js/node-zwave-js/blob/master/packages/config/config/sensorTypes.json - UNKNOWN = -1 CENTIMETER = 1 FEET = 2 METER = 0 - @classmethod - def _missing_(cls: type, value: object) -> DistanceScale: # noqa: ARG003 - """Set default enum member if an unknown value is provided.""" - return DistanceScale.UNKNOWN - class DensityScale(MultilevelSensorScaleType): """Enum for known scales for Density multilevel sensor types.""" # https://github.com/zwave-js/node-zwave-js/blob/master/packages/config/config/sensorTypes.json - UNKNOWN = -1 DENSITY = 0 - @classmethod - def _missing_(cls: type, value: object) -> DensityScale: # noqa: ARG003 - """Set default enum member if an unknown value is provided.""" - return DensityScale.UNKNOWN - class DirectionScale(MultilevelSensorScaleType): """Enum for known scales for Direction multilevel sensor types.""" # https://github.com/zwave-js/node-zwave-js/blob/master/packages/config/config/sensorTypes.json - UNKNOWN = -1 DEGREES = 0 - @classmethod - def _missing_(cls: type, value: object) -> DirectionScale: # noqa: ARG003 - """Set default enum member if an unknown value is provided.""" - return DirectionScale.UNKNOWN - class ElectricalConductivityScale(MultilevelSensorScaleType): """Enum for known scales for ELECTRICAL_CONDUCTIVITY multilevel sensor types.""" # https://github.com/zwave-js/node-zwave-js/blob/master/packages/config/config/sensorTypes.json - UNKNOWN = -1 SIEMENS_PER_METER = 0 - @classmethod - def _missing_( - cls: type, value: object - ) -> ElectricalConductivityScale: # noqa: ARG003 - """Set default enum member if an unknown value is provided.""" - return ElectricalConductivityScale.UNKNOWN - class ElectricalResistivityScale(MultilevelSensorScaleType): """Enum for known scales for ELECTRICAL_RESISTIVITY multilevel sensor types.""" # https://github.com/zwave-js/node-zwave-js/blob/master/packages/config/config/sensorTypes.json - UNKNOWN = -1 OHM_METER = 0 - @classmethod - def _missing_( - cls: type, value: object - ) -> ElectricalResistivityScale: # noqa: ARG003 - """Set default enum member if an unknown value is provided.""" - return ElectricalResistivityScale.UNKNOWN - class FormaldehydeLevelScale(MultilevelSensorScaleType): """Enum for known scales for FORMALDEHYDE_LEVEL multilevel sensor types.""" # https://github.com/zwave-js/node-zwave-js/blob/master/packages/config/config/sensorTypes.json - UNKNOWN = -1 MOLE_PER_CUBIC_METER = 0 - @classmethod - def _missing_(cls: type, value: object) -> FormaldehydeLevelScale: # noqa: ARG003 - """Set default enum member if an unknown value is provided.""" - return FormaldehydeLevelScale.UNKNOWN - class FrequencyScale(MultilevelSensorScaleType): """Enum for known scales for FREQUENCY multilevel sensor types.""" # https://github.com/zwave-js/node-zwave-js/blob/master/packages/config/config/sensorTypes.json - UNKNOWN = -1 HERTZ = 0 KILOHERTZ = 1 - @classmethod - def _missing_(cls: type, value: object) -> FrequencyScale: # noqa: ARG003 - """Set default enum member if an unknown value is provided.""" - return FrequencyScale.UNKNOWN - class GeneralPurposeScale(MultilevelSensorScaleType): """Enum for known scales for GENERAL_PURPOSE multilevel sensor types.""" # https://github.com/zwave-js/node-zwave-js/blob/master/packages/config/config/sensorTypes.json - UNKNOWN = -1 DIMENSIONLESS_VALUE = 1 PERCENTAGE_VALUE = 0 - @classmethod - def _missing_(cls: type, value: object) -> GeneralPurposeScale: # noqa: ARG003 - """Set default enum member if an unknown value is provided.""" - return GeneralPurposeScale.UNKNOWN - class HeartRateScale(MultilevelSensorScaleType): """Enum for known scales for HEART_RATE multilevel sensor types.""" # https://github.com/zwave-js/node-zwave-js/blob/master/packages/config/config/sensorTypes.json - UNKNOWN = -1 BEATS_PER_MINUTE = 0 - @classmethod - def _missing_(cls: type, value: object) -> HeartRateScale: # noqa: ARG003 - """Set default enum member if an unknown value is provided.""" - return HeartRateScale.UNKNOWN - class HumidityScale(MultilevelSensorScaleType): """Enum for known scales for Humidity multilevel sensor types.""" # https://github.com/zwave-js/node-zwave-js/blob/master/packages/config/config/sensorTypes.json - UNKNOWN = -1 ABSOLUTE_HUMIDITY = 1 PERCENTAGE_VALUE = 0 - @classmethod - def _missing_(cls: type, value: object) -> HumidityScale: # noqa: ARG003 - """Set default enum member if an unknown value is provided.""" - return HumidityScale.UNKNOWN - class IlluminanceScale(MultilevelSensorScaleType): """Enum for known scales for ILLUMINANCE multilevel sensor types.""" # https://github.com/zwave-js/node-zwave-js/blob/master/packages/config/config/sensorTypes.json - UNKNOWN = -1 LUX = 1 PERCENTAGE_VALUE = 0 - @classmethod - def _missing_(cls: type, value: object) -> IlluminanceScale: # noqa: ARG003 - """Set default enum member if an unknown value is provided.""" - return IlluminanceScale.UNKNOWN - class LoudnessScale(MultilevelSensorScaleType): """Enum for known scales for LOUDNESS multilevel sensor types.""" # https://github.com/zwave-js/node-zwave-js/blob/master/packages/config/config/sensorTypes.json - UNKNOWN = -1 A_WEIGHTED_DECIBELS = 1 DECIBEL = 0 - @classmethod - def _missing_(cls: type, value: object) -> LoudnessScale: # noqa: ARG003 - """Set default enum member if an unknown value is provided.""" - return LoudnessScale.UNKNOWN - class MethaneDensityScale(MultilevelSensorScaleType): """Enum for known scales for METHANE_DENSITY multilevel sensor types.""" # https://github.com/zwave-js/node-zwave-js/blob/master/packages/config/config/sensorTypes.json - UNKNOWN = -1 MOLE_PER_CUBIC_METER = 0 - @classmethod - def _missing_(cls: type, value: object) -> MethaneDensityScale: # noqa: ARG003 - """Set default enum member if an unknown value is provided.""" - return MethaneDensityScale.UNKNOWN - class MoistureScale(MultilevelSensorScaleType): """Enum for known scales for MOISTURE multilevel sensor types.""" # https://github.com/zwave-js/node-zwave-js/blob/master/packages/config/config/sensorTypes.json - UNKNOWN = -1 IMPEDANCE = 2 PERCENTAGE_VALUE = 0 VOLUME_WATER_CONTENT = 1 WATER_ACTIVITY = 3 - @classmethod - def _missing_(cls: type, value: object) -> MoistureScale: # noqa: ARG003 - """Set default enum member if an unknown value is provided.""" - return MoistureScale.UNKNOWN - class MassScale(MultilevelSensorScaleType): """Enum for known scales for Mass multilevel sensor types.""" # https://github.com/zwave-js/node-zwave-js/blob/master/packages/config/config/sensorTypes.json - UNKNOWN = -1 KILOGRAM = 0 - @classmethod - def _missing_(cls: type, value: object) -> MassScale: # noqa: ARG003 - """Set default enum member if an unknown value is provided.""" - return MassScale.UNKNOWN - class ParticulateMatter10Scale(MultilevelSensorScaleType): """Enum for known scales for PARTICULATE_MATTER_10 multilevel sensor types.""" # https://github.com/zwave-js/node-zwave-js/blob/master/packages/config/config/sensorTypes.json - UNKNOWN = -1 MICROGRAM_PER_CUBIC_METER = 1 MOLE_PER_CUBIC_METER = 0 - @classmethod - def _missing_(cls: type, value: object) -> ParticulateMatter10Scale: # noqa: ARG003 - """Set default enum member if an unknown value is provided.""" - return ParticulateMatter10Scale.UNKNOWN - class ParticulateMatter25Scale(MultilevelSensorScaleType): """Enum for known scales for PARTICULATE_MATTER_2_5 multilevel sensor types.""" # https://github.com/zwave-js/node-zwave-js/blob/master/packages/config/config/sensorTypes.json - UNKNOWN = -1 MICROGRAM_PER_CUBIC_METER = 1 MOLE_PER_CUBIC_METER = 0 - @classmethod - def _missing_(cls: type, value: object) -> ParticulateMatter25Scale: # noqa: ARG003 - """Set default enum member if an unknown value is provided.""" - return ParticulateMatter25Scale.UNKNOWN - class PowerScale(MultilevelSensorScaleType): """Enum for known scales for POWER multilevel sensor types.""" # https://github.com/zwave-js/node-zwave-js/blob/master/packages/config/config/sensorTypes.json - UNKNOWN = -1 BTU_H = 1 WATT = 0 - @classmethod - def _missing_(cls: type, value: object) -> PowerScale: # noqa: ARG003 - """Set default enum member if an unknown value is provided.""" - return PowerScale.UNKNOWN - class PercentageScale(MultilevelSensorScaleType): """Enum for known scales for Percentage multilevel sensor types.""" # https://github.com/zwave-js/node-zwave-js/blob/master/packages/config/config/sensorTypes.json - UNKNOWN = -1 PERCENTAGE_VALUE = 0 - @classmethod - def _missing_(cls: type, value: object) -> PercentageScale: # noqa: ARG003 - """Set default enum member if an unknown value is provided.""" - return PercentageScale.UNKNOWN - class PressureScale(MultilevelSensorScaleType): """Enum for known scales for Pressure multilevel sensor types.""" # https://github.com/zwave-js/node-zwave-js/blob/master/packages/config/config/sensorTypes.json - UNKNOWN = -1 KILOPASCAL = 0 POUND_PER_SQUARE_INCH = 1 - @classmethod - def _missing_(cls: type, value: object) -> PressureScale: # noqa: ARG003 - """Set default enum member if an unknown value is provided.""" - return PressureScale.UNKNOWN - class RadonConcentrationScale(MultilevelSensorScaleType): """Enum for known scales for RADON_CONCENTRATION multilevel sensor types.""" # https://github.com/zwave-js/node-zwave-js/blob/master/packages/config/config/sensorTypes.json - UNKNOWN = -1 BECQUEREL_PER_CUBIC_METER = 0 PICOCURIES_PER_LITER = 1 - @classmethod - def _missing_(cls: type, value: object) -> RadonConcentrationScale: # noqa: ARG003 - """Set default enum member if an unknown value is provided.""" - return RadonConcentrationScale.UNKNOWN - class RainRateScale(MultilevelSensorScaleType): """Enum for known scales for RAIN_RATE multilevel sensor types.""" # https://github.com/zwave-js/node-zwave-js/blob/master/packages/config/config/sensorTypes.json - UNKNOWN = -1 INCHES_PER_HOUR = 1 MILLIMETER_HOUR = 0 - @classmethod - def _missing_(cls: type, value: object) -> RainRateScale: # noqa: ARG003 - """Set default enum member if an unknown value is provided.""" - return RainRateScale.UNKNOWN - class RespiratoryRateScale(MultilevelSensorScaleType): """Enum for known scales for RESPIRATORY_RATE multilevel sensor types.""" # https://github.com/zwave-js/node-zwave-js/blob/master/packages/config/config/sensorTypes.json - UNKNOWN = -1 BREATHS_PER_MINUTE = 0 - @classmethod - def _missing_(cls: type, value: object) -> RespiratoryRateScale: # noqa: ARG003 - """Set default enum member if an unknown value is provided.""" - return RespiratoryRateScale.UNKNOWN - class RfSignalStrengthScale(MultilevelSensorScaleType): """Enum for known scales for RF_SIGNAL_STRENGTH multilevel sensor types.""" # https://github.com/zwave-js/node-zwave-js/blob/master/packages/config/config/sensorTypes.json - UNKNOWN = -1 POWER_LEVEL = 1 RSSI = 0 - @classmethod - def _missing_(cls: type, value: object) -> RfSignalStrengthScale: # noqa: ARG003 - """Set default enum member if an unknown value is provided.""" - return RfSignalStrengthScale.UNKNOWN - class RotationScale(MultilevelSensorScaleType): """Enum for known scales for ROTATION multilevel sensor types.""" # https://github.com/zwave-js/node-zwave-js/blob/master/packages/config/config/sensorTypes.json - UNKNOWN = -1 HERTZ = 1 REVOLUTIONS_PER_MINUTE = 0 - @classmethod - def _missing_(cls: type, value: object) -> RotationScale: # noqa: ARG003 - """Set default enum member if an unknown value is provided.""" - return RotationScale.UNKNOWN - class SeismicIntensityScale(MultilevelSensorScaleType): """Enum for known scales for SEISMIC_INTENSITY multilevel sensor types.""" # https://github.com/zwave-js/node-zwave-js/blob/master/packages/config/config/sensorTypes.json - UNKNOWN = -1 EUROPEAN_MACROSEISMIC = 1 LIEDU = 2 MERCALLI = 0 SHINDO = 3 - @classmethod - def _missing_(cls: type, value: object) -> SeismicIntensityScale: # noqa: ARG003 - """Set default enum member if an unknown value is provided.""" - return SeismicIntensityScale.UNKNOWN - class SeismicMagnitudeScale(MultilevelSensorScaleType): """Enum for known scales for SEISMIC_MAGNITUDE multilevel sensor types.""" # https://github.com/zwave-js/node-zwave-js/blob/master/packages/config/config/sensorTypes.json - UNKNOWN = -1 BODY_WAVE = 3 LOCAL = 0 MOMENT = 1 SURFACE_WAVE = 2 - @classmethod - def _missing_(cls: type, value: object) -> SeismicMagnitudeScale: # noqa: ARG003 - """Set default enum member if an unknown value is provided.""" - return SeismicMagnitudeScale.UNKNOWN - class SoilSalinityScale(MultilevelSensorScaleType): """Enum for known scales for SOIL_SALINITY multilevel sensor types.""" # https://github.com/zwave-js/node-zwave-js/blob/master/packages/config/config/sensorTypes.json - UNKNOWN = -1 MOLE_PER_CUBIC_METER = 0 - @classmethod - def _missing_(cls: type, value: object) -> SoilSalinityScale: # noqa: ARG003 - """Set default enum member if an unknown value is provided.""" - return SoilSalinityScale.UNKNOWN - class SolarRadiationScale(MultilevelSensorScaleType): """Enum for known scales for SOLAR_RADIATION multilevel sensor types.""" # https://github.com/zwave-js/node-zwave-js/blob/master/packages/config/config/sensorTypes.json - UNKNOWN = -1 WATT_PER_SQUARE_METER = 0 - @classmethod - def _missing_(cls: type, value: object) -> SolarRadiationScale: # noqa: ARG003 - """Set default enum member if an unknown value is provided.""" - return SolarRadiationScale.UNKNOWN - class TankCapacityScale(MultilevelSensorScaleType): """Enum for known scales for TANK_CAPACITY multilevel sensor types.""" # https://github.com/zwave-js/node-zwave-js/blob/master/packages/config/config/sensorTypes.json - UNKNOWN = -1 CUBIC_METER = 1 GALLONS = 2 LITER = 0 - @classmethod - def _missing_(cls: type, value: object) -> TankCapacityScale: # noqa: ARG003 - """Set default enum member if an unknown value is provided.""" - return TankCapacityScale.UNKNOWN - class TideLevelScale(MultilevelSensorScaleType): """Enum for known scales for TIDE_LEVEL multilevel sensor types.""" # https://github.com/zwave-js/node-zwave-js/blob/master/packages/config/config/sensorTypes.json - UNKNOWN = -1 FEET = 1 METER = 0 - @classmethod - def _missing_(cls: type, value: object) -> TideLevelScale: # noqa: ARG003 - """Set default enum member if an unknown value is provided.""" - return TideLevelScale.UNKNOWN - class TimeScale(MultilevelSensorScaleType): """Enum for known scales for TIME multilevel sensor types.""" # https://github.com/zwave-js/node-zwave-js/blob/master/packages/config/config/sensorTypes.json - UNKNOWN = -1 SECOND = 0 - @classmethod - def _missing_(cls: type, value: object) -> TimeScale: # noqa: ARG003 - """Set default enum member if an unknown value is provided.""" - return TimeScale.UNKNOWN - class TemperatureScale(MultilevelSensorScaleType): """Enum for known scales for Temperature multilevel sensor types.""" # https://github.com/zwave-js/node-zwave-js/blob/master/packages/config/config/sensorTypes.json - UNKNOWN = -1 CELSIUS = 0 FAHRENHEIT = 1 - @classmethod - def _missing_(cls: type, value: object) -> TemperatureScale: # noqa: ARG003 - """Set default enum member if an unknown value is provided.""" - return TemperatureScale.UNKNOWN - class UltravioletScale(MultilevelSensorScaleType): """Enum for known scales for ULTRAVIOLET multilevel sensor types.""" # https://github.com/zwave-js/node-zwave-js/blob/master/packages/config/config/sensorTypes.json - UNKNOWN = -1 UV_INDEX = 0 - @classmethod - def _missing_(cls: type, value: object) -> UltravioletScale: # noqa: ARG003 - """Set default enum member if an unknown value is provided.""" - return UltravioletScale.UNKNOWN - class UnitlessScale(MultilevelSensorScaleType): """Enum for known scales for Unitless multilevel sensor types.""" # https://github.com/zwave-js/node-zwave-js/blob/master/packages/config/config/sensorTypes.json - UNKNOWN = -1 UNITLESS = 0 - @classmethod - def _missing_(cls: type, value: object) -> UnitlessScale: # noqa: ARG003 - """Set default enum member if an unknown value is provided.""" - return UnitlessScale.UNKNOWN - class VelocityScale(MultilevelSensorScaleType): """Enum for known scales for VELOCITY multilevel sensor types.""" # https://github.com/zwave-js/node-zwave-js/blob/master/packages/config/config/sensorTypes.json - UNKNOWN = -1 MPH = 1 M_S = 0 - @classmethod - def _missing_(cls: type, value: object) -> VelocityScale: # noqa: ARG003 - """Set default enum member if an unknown value is provided.""" - return VelocityScale.UNKNOWN - class VolatileOrganicCompoundLevelScale(MultilevelSensorScaleType): """Enum for known scales for VOLATILE_ORGANIC_COMPOUND_LEVEL multilevel sensor types.""" # https://github.com/zwave-js/node-zwave-js/blob/master/packages/config/config/sensorTypes.json - UNKNOWN = -1 MOLE_PER_CUBIC_METER = 0 PARTS_MILLION = 1 - @classmethod - def _missing_( - cls: type, value: object - ) -> VolatileOrganicCompoundLevelScale: # noqa: ARG003 - """Set default enum member if an unknown value is provided.""" - return VolatileOrganicCompoundLevelScale.UNKNOWN - class VoltageScale(MultilevelSensorScaleType): """Enum for known scales for VOLTAGE multilevel sensor types.""" # https://github.com/zwave-js/node-zwave-js/blob/master/packages/config/config/sensorTypes.json - UNKNOWN = -1 MILLIVOLT = 1 VOLT = 0 - @classmethod - def _missing_(cls: type, value: object) -> VoltageScale: # noqa: ARG003 - """Set default enum member if an unknown value is provided.""" - return VoltageScale.UNKNOWN - class WaterChlorineLevelScale(MultilevelSensorScaleType): """Enum for known scales for WATER_CHLORINE_LEVEL multilevel sensor types.""" # https://github.com/zwave-js/node-zwave-js/blob/master/packages/config/config/sensorTypes.json - UNKNOWN = -1 MILLIGRAM_PER_LITER = 0 - @classmethod - def _missing_(cls: type, value: object) -> WaterChlorineLevelScale: # noqa: ARG003 - """Set default enum member if an unknown value is provided.""" - return WaterChlorineLevelScale.UNKNOWN - class WaterFlowScale(MultilevelSensorScaleType): """Enum for known scales for WATER_FLOW multilevel sensor types.""" # https://github.com/zwave-js/node-zwave-js/blob/master/packages/config/config/sensorTypes.json - UNKNOWN = -1 LITER_PER_HOUR = 0 - @classmethod - def _missing_(cls: type, value: object) -> WaterFlowScale: # noqa: ARG003 - """Set default enum member if an unknown value is provided.""" - return WaterFlowScale.UNKNOWN - class WaterOxidationReductionPotentialScale(MultilevelSensorScaleType): """Enum for known scales for WATER_OXIDATION_REDUCTION_POTENTIAL multilevel sensor types.""" # https://github.com/zwave-js/node-zwave-js/blob/master/packages/config/config/sensorTypes.json - UNKNOWN = -1 MILLIVOLT = 0 - @classmethod - def _missing_( - cls: type, value: object - ) -> WaterOxidationReductionPotentialScale: # noqa: ARG003 - """Set default enum member if an unknown value is provided.""" - return WaterOxidationReductionPotentialScale.UNKNOWN - class WaterPressureScale(MultilevelSensorScaleType): """Enum for known scales for WATER_PRESSURE multilevel sensor types.""" # https://github.com/zwave-js/node-zwave-js/blob/master/packages/config/config/sensorTypes.json - UNKNOWN = -1 KILOPASCAL = 0 - @classmethod - def _missing_(cls: type, value: object) -> WaterPressureScale: # noqa: ARG003 - """Set default enum member if an unknown value is provided.""" - return WaterPressureScale.UNKNOWN - class WeightScale(MultilevelSensorScaleType): """Enum for known scales for WEIGHT multilevel sensor types.""" # https://github.com/zwave-js/node-zwave-js/blob/master/packages/config/config/sensorTypes.json - UNKNOWN = -1 KILOGRAM = 0 POUNDS = 1 - @classmethod - def _missing_(cls: type, value: object) -> WeightScale: # noqa: ARG003 - """Set default enum member if an unknown value is provided.""" - return WeightScale.UNKNOWN - MULTILEVEL_SENSOR_TYPE_TO_SCALE_MAP: dict[ MultilevelSensorType, type[MultilevelSensorScaleType]