def test_full_flush_shutter(fake_home: Home): with no_ssl_verification(): d = FullFlushShutter(fake_home._connection) d = fake_home.search_device_by_id("3014F711ACBCDABCADCA66") assert d.bottomToTopReferenceTime == 30.080000000000002 assert d.changeOverDelay == 0.5 assert d.delayCompensationValue == 12.7 assert d.endpositionAutoDetectionEnabled == True assert d.previousShutterLevel == None assert d.processing == False assert d.profileMode == "AUTOMATIC" assert d.selfCalibrationInProgress == None assert d.shutterLevel == 1.0 assert d.supportingDelayCompensation == True assert d.supportingEndpositionAutoDetection == True assert d.supportingSelfCalibration == True assert d.topToBottomReferenceTime == 24.68 assert d.userDesiredProfileMode == "AUTOMATIC" assert str(d) == ( "HmIP-BROLL BROLL_1 lowbat(None) unreach(False) rssiDeviceValue(-78) rssiPeerValue(-77) configPending(False)" " dutyCycle(False) shutterLevel(1.0) topToBottom(24.68) bottomToTop(30.080000000000002)" ) d.set_shutter_level(0.4) d.set_shutter_stop() # this will not do anything in the test run fake_home.get_current_state() d = fake_home.search_device_by_id("3014F711ACBCDABCADCA66") assert d.shutterLevel == 0.4
def test_rules(fake_home: Home): with no_ssl_verification(): rule = fake_home.search_rule_by_id("00000000-0000-0000-0000-000000000065") assert rule.active == True assert rule.label == "Alarmanlage" assert isinstance(rule, SimpleRule) assert rule.ruleErrorCategories == [] assert rule.errorRuleTriggerItems == [] assert rule.errorRuleConditionItems == [] assert rule.errorRuleActionItems == [] assert str(rule) == "SIMPLE Alarmanlage active(True)" # disable test rule.disable() rule.set_label("DISABLED_RULE") fake_home.get_current_state() rule = fake_home.search_rule_by_id("00000000-0000-0000-0000-000000000065") assert rule.active == False assert rule.label == "DISABLED_RULE" # endable test rule.enable() rule.set_label("ENABLED_RULE") fake_home.get_current_state() rule = fake_home.search_rule_by_id("00000000-0000-0000-0000-000000000065") assert rule.active == True assert rule.label == "ENABLED_RULE" rule.id = "INVALID_ID" result = rule.disable() assert result["errorCode"] == "INVALID_RULE" result = rule.set_label("NEW LABEL") assert result["errorCode"] == "INVALID_RULE"
def test_websocket_error(fake_home: Home, home_data): global ws_error_called def on_error(err): global ws_error_called ws_error_called = True fake_home.onWsError += on_error fake_home.enable_events() with no_ssl_verification(): fake_home._connection._restCallRequestCounter = 1 fake_home._restCall("ws/sleep", json.dumps({"seconds": 5})) assert ws_error_called # testing automatic reconnection time.sleep(5) # give the reconnection routine time to reconnect client_base_id = "00000000-0000-0000-0000-000000000000" client_changed = home_data["clients"][client_base_id].copy() client_changed["label"] = "CHANGED" send_event(fake_home, EventType.CLIENT_CHANGED, "client", client_changed) time.sleep(1) d = fake_home.search_client_by_id(client_base_id) assert d.label == "CHANGED" assert isinstance(d, Client) fake_home.disable_events()
def test_heating_dehumidifier_group(fake_home: Home): with no_ssl_verification(): g = fake_home.search_group_by_id( "00000000-0000-0000-0000-000000000055") assert isinstance(g, HeatingDehumidifierGroup) assert g.on is None assert str(g) == "HEATING_DEHUMIDIFIER HEATING_DEHUMIDIFIER on(None)"
def test_extended_linked_shutter_group(fake_home: Home): with no_ssl_verification(): g = fake_home.search_group_by_id("00000000-0000-0000-0000-000000000050") assert g.groupVisibility == GroupVisibility.VISIBLE assert g.dutyCycle is False assert g.label == "Rollos" assert g.primaryShadingLevel == 1.0 assert g.primaryShadingStateType == ShadingStateType.POSITION_USED assert g.secondaryShadingLevel is None assert g.secondaryShadingStateType == ShadingStateType.NOT_EXISTENT assert g.slatsLevel is None assert g.shutterLevel == 1.0 assert g.topShutterLevel == 0.0 assert g.topSlatsLevel == 0.0 assert g.bottomShutterLevel == 1.0 assert g.bottomSlatsLevel == 1.0 assert ( str(g) == "EXTENDED_LINKED_SHUTTER Rollos shutterLevel(1.0) slatsLevel(None)" ) g.set_slats_level(1.2, 10) fake_home.get_current_state() g = fake_home.search_group_by_id("00000000-0000-0000-0000-000000000050") assert g.slatsLevel == 1.2 assert g.shutterLevel == 10 g.set_shutter_stop() g.set_shutter_level(30) fake_home.get_current_state() g = fake_home.search_group_by_id("00000000-0000-0000-0000-000000000050") assert g.shutterLevel == 30
def test_home_getOAuthOTK(fake_home: Home): with no_ssl_verification(): token = fake_home.get_OAuth_OTK() assert token.authToken == "C001ED" assert token.expirationTimestamp == datetime( 2018, 12, 23, 11, 38, 21, 680000 ) + timedelta(0, utc_offset)
def test_full_flush_blind(fake_home: Home): with no_ssl_verification(): d = FullFlushBlind(fake_home._connection) d = fake_home.search_device_by_id("3014F711BADCAFE000000001") assert d.shutterLevel == 1.0 assert d.slatsLevel == 1.0 assert d.blindModeActive == True assert d.slatsReferenceTime == 2.0 d.set_slats_level(0.4) fake_home.get_current_state() d = fake_home.search_device_by_id("3014F711BADCAFE000000001") assert d.shutterLevel == 1.0 assert d.slatsLevel == 0.4 d.set_slats_level(0.8, 0.3) fake_home.get_current_state() d = fake_home.search_device_by_id("3014F711BADCAFE000000001") assert d.shutterLevel == 0.3 assert d.slatsLevel == 0.8 assert str(d) == ( "HmIP-FBL Sofa links lowbat(None) unreach(False) rssiDeviceValue(-73) " "rssiPeerValue(-78) configPending(False) dutyCycle(False) " "shutterLevel(0.3) topToBottom(41.0) bottomToTop(41.0) " "slatsLevel(0.8) blindModeActive(True)")
def test_set_powermeter_unit_price(fake_home: Home): with no_ssl_verification(): fake_home.set_powermeter_unit_price(12.0) fake_home.get_current_state() assert fake_home.powerMeterUnitPrice == 12.0 fake_home.set_powermeter_unit_price(8.5) fake_home.get_current_state() assert fake_home.powerMeterUnitPrice == 8.5
def test_alarm_siren_indoor(fake_home: Home): with no_ssl_verification(): d = AlarmSirenIndoor(fake_home._connection) d = fake_home.search_device_by_id("3014F7110000000000BBBBB8") assert ( str(d) == "HmIP-ASIR Alarmsirene lowbat(False) unreach(False) rssiDeviceValue(-59) rssiPeerValue(None) configPending(False) dutyCycle(False) sabotage(False)" )
def test_heating_failure_alert_group(fake_home: Home): with no_ssl_verification(): g = fake_home.search_group_by_id( "00000000-BBBB-0000-0000-000000000052") assert str(g) == ( "HEATING_FAILURE_ALERT_RULE_GROUP HEATING_FAILURE_ALERT_RULE_GROUP" " enabled(True) heatingFailureValidationResult(NO_HEATING_FAILURE)" " checkInterval(600) validationTimeout(86400000)" " lastExecutionTimestamp(2019-02-21 19:30:00.084000)")
def send_event(fake_home: Home, pushEventType: EventType, type: str, data): if type: event_data = { "events": {"0": {"pushEventType": str(pushEventType), type: data}} } else: event_data = {"events": {"0": {"pushEventType": str(pushEventType)}}} with no_ssl_verification(): fake_home._restCall("ws/send", json.dumps(event_data))
def test_home_set_location(fake_home: Home): with no_ssl_verification(): fake_home.set_location("Berlin, Germany", "52.530644", "13.383068") fake_home.get_current_state() assert fake_home.location.city == "Berlin, Germany" assert fake_home.location.latitude == "52.530644" assert fake_home.location.longitude == "13.383068" assert (str( fake_home.location ) == "city(Berlin, Germany) latitude(52.530644) longitude(13.383068)")
def test_set_timezone(fake_home: Home): with no_ssl_verification(): assert fake_home.timeZoneId == "Europe/Vienna" fake_home.set_timezone("Europe/Berlin") fake_home.get_current_state() assert fake_home.timeZoneId == "Europe/Berlin" fake_home.set_timezone("Europe/Vienna") fake_home.get_current_state() assert fake_home.timeZoneId == "Europe/Vienna"
def test_water_sensor(fake_home: Home): with no_ssl_verification(): d = WaterSensor(fake_home._connection) # just needed for intellisense d = fake_home.search_device_by_id("3014F7110000000000000050") assert d.label == "Wassersensor" assert d.routerModuleEnabled == False assert d.routerModuleSupported == False assert d.incorrectPositioned == True assert d.acousticAlarmSignal == AcousticAlarmSignal.FREQUENCY_RISING assert d.acousticAlarmTiming == AcousticAlarmTiming.ONCE_PER_MINUTE assert d.acousticWaterAlarmTrigger == WaterAlarmTrigger.WATER_DETECTION assert d.inAppWaterAlarmTrigger == WaterAlarmTrigger.WATER_MOISTURE_DETECTION assert d.moistureDetected == False assert d.sirenWaterAlarmTrigger == WaterAlarmTrigger.WATER_MOISTURE_DETECTION assert d.waterlevelDetected == False d.set_acoustic_alarm_timing(AcousticAlarmTiming.SIX_MINUTES) d.set_acoustic_alarm_signal( AcousticAlarmSignal.FREQUENCY_ALTERNATING_LOW_HIGH) d.set_inapp_water_alarm_trigger(WaterAlarmTrigger.MOISTURE_DETECTION) d.set_acoustic_water_alarm_trigger(WaterAlarmTrigger.NO_ALARM) d.set_siren_water_alarm_trigger(WaterAlarmTrigger.NO_ALARM) assert str(d) == ( "HmIP-SWD Wassersensor lowbat(False) unreach(False) rssiDeviceValue(-65) rssiPeerValue(None) configPending(False) " "dutyCycle(False) incorrectPositioned(True) acousticAlarmSignal(FREQUENCY_RISING) acousticAlarmTiming(ONCE_PER_MINUTE) " "acousticWaterAlarmTrigger(WATER_DETECTION) inAppWaterAlarmTrigger(WATER_MOISTURE_DETECTION) moistureDetected(False) " "sirenWaterAlarmTrigger(WATER_MOISTURE_DETECTION) waterlevelDetected(False)" ) fake_home.get_current_state() d = fake_home.search_device_by_id("3014F7110000000000000050") assert d.acousticAlarmTiming == AcousticAlarmTiming.SIX_MINUTES assert (d.acousticAlarmSignal == AcousticAlarmSignal.FREQUENCY_ALTERNATING_LOW_HIGH) assert d.acousticWaterAlarmTrigger == WaterAlarmTrigger.NO_ALARM assert d.inAppWaterAlarmTrigger == WaterAlarmTrigger.MOISTURE_DETECTION assert d.sirenWaterAlarmTrigger == WaterAlarmTrigger.NO_ALARM d.id = "INVALID_ID" result = d.set_acoustic_alarm_timing(AcousticAlarmTiming.SIX_MINUTES) assert result["errorCode"] == "INVALID_DEVICE" result = d.set_acoustic_alarm_signal( AcousticAlarmSignal.FREQUENCY_ALTERNATING_LOW_HIGH) assert result["errorCode"] == "INVALID_DEVICE" result = d.set_inapp_water_alarm_trigger( WaterAlarmTrigger.MOISTURE_DETECTION) assert result["errorCode"] == "INVALID_DEVICE" result = d.set_acoustic_water_alarm_trigger(WaterAlarmTrigger.NO_ALARM) assert result["errorCode"] == "INVALID_DEVICE" result = d.set_siren_water_alarm_trigger(WaterAlarmTrigger.NO_ALARM) assert result["errorCode"] == "INVALID_DEVICE"
def test_brand_blind(fake_home: Home): with no_ssl_verification(): d = BrandBlind(fake_home._connection) d = fake_home.search_device_by_id("3014F71100000000000BBL24") assert isinstance(d, BrandBlind) assert str(d) == ( "HmIP-BBL Jalousie Schiebetür lowbat(None) unreach(False) " "rssiDeviceValue(-64) rssiPeerValue(-76) configPending(False) " "dutyCycle(False) shutterLevel(0.885) topToBottom(53.68) bottomToTop(54.88) " "slatsLevel(1.0) blindModeActive(True)")
def test_home_getSecurityJournal(fake_home: Home): with no_ssl_verification(): journal = fake_home.get_security_journal() # todo make more advanced tests assert isinstance(journal[0], ActivationChangedEvent) assert isinstance(journal[1], ActivationChangedEvent) assert isinstance(journal[2], AccessPointDisconnectedEvent) assert isinstance(journal[3], AccessPointConnectedEvent) assert isinstance(journal[4], SensorEvent) assert isinstance(journal[5], SabotageEvent) assert isinstance(journal[6], MoistureDetectionEvent) assert isinstance(journal[7], SecurityEvent)
def test_security_zones_activation(fake_home: Home): with no_ssl_verification(): internal, external = fake_home.get_security_zones_activation() assert internal is False assert external is False fake_home.set_security_zones_activation(True, True) fake_home.get_current_state() internal, external = fake_home.get_security_zones_activation() assert internal is True assert external is True
def test_heating_cooling_demand_pump_group(fake_home: Home): with no_ssl_verification(): g = fake_home.search_group_by_id("00000000-0000-0000-0000-000000000057") assert isinstance(g, HeatingCoolingDemandPumpGroup) assert g.on is None assert g.pumpFollowUpTime == 2 assert g.pumpLeadTime == 2 assert g.pumpProtectionDuration == 1 assert g.pumpProtectionSwitchingInterval == 14 assert str(g) == ( "HEATING_COOLING_DEMAND_PUMP HEATING_COOLING_DEMAND_PUMP on(None) pumpProtectionDuration(1)" " pumpProtectionSwitchingInterval(14) pumpFollowUpTime(2) pumpLeadTime(2)" )
def test_pluggable_switch_measuring(fake_home: Home): d = fake_home.search_device_by_id("3014F7110000000000000009") assert isinstance(d, PlugableSwitchMeasuring) assert d.label == "Brunnen" assert d.lastStatusUpdate == (datetime(2018, 4, 23, 20, 36, 26, 303000) + timedelta(0, utc_offset)) assert d.manufacturerCode == 1 assert d.modelId == 262 assert d.modelType == "HMIP-PSM" assert d.oem == "eQ-3" assert d.serializedGlobalTradeItemNumber == "3014F7110000000000000009" assert d.updateState == DeviceUpdateState.UP_TO_DATE assert d.on == False assert d.profileMode == "AUTOMATIC" assert d.userDesiredProfileMode == "AUTOMATIC" assert d.currentPowerConsumption == 0.0 assert d.energyCounter == 0.4754 assert d.lowBat == None assert d.routerModuleEnabled == True assert d.routerModuleSupported == True assert d.rssiDeviceValue == -60 assert d.rssiPeerValue == -66 assert d.unreach == False assert d.availableFirmwareVersion == "0.0.0" assert d.firmwareVersion == "2.6.2" a, b, c = [int(i) for i in d.firmwareVersion.split(".")] assert d.firmwareVersionInteger == (a << 16) | (b << 8) | c assert d.dutyCycle == False assert d.configPending == False assert str(d) == ( "HMIP-PSM Brunnen lowbat(None) unreach(False) rssiDeviceValue(-60) rssiPeerValue(-66) configPending(False) dutyCycle(False) on(False) profileMode(AUTOMATIC)" " userDesiredProfileMode(AUTOMATIC) energyCounter(0.4754) currentPowerConsumption(0.0W)" ) assert (d._rawJSONData == fake_home_download_configuration()["devices"] ["3014F7110000000000000009"]) with no_ssl_verification(): d.turn_on() fake_home.get_current_state() d = fake_home.search_device_by_id("3014F7110000000000000009") assert d.on == True d.turn_off() fake_home.get_current_state() d = fake_home.search_device_by_id("3014F7110000000000000009") assert d.on == False d.id = "INVALID_ID" result = d.turn_off() assert result["errorCode"] == "INVALID_DEVICE"
def test_hot_water(fake_home: Home): with no_ssl_verification(): g = fake_home.search_group_by_id("00000000-0000-0000-0000-000000000067") assert g.profileMode is None g.set_profile_mode(ProfileMode.AUTOMATIC) fake_home.get_current_state() g = fake_home.search_group_by_id("00000000-0000-0000-0000-000000000067") assert g.profileMode == ProfileMode.AUTOMATIC assert ( str(g) == "HOT_WATER HOT_WATER on(None) onTime(900.0) profileMode(AUTOMATIC)" )
def test_security_setZoneActivationDelay(fake_home: Home): with no_ssl_verification(): securityAlarmHome = fake_home.get_functionalHome(SecurityAndAlarmHome) assert securityAlarmHome.zoneActivationDelay == 0.0 fake_home.set_zone_activation_delay(5.0) fake_home.get_current_state() securityAlarmHome = fake_home.get_functionalHome(SecurityAndAlarmHome) assert securityAlarmHome.zoneActivationDelay == 5.0 fake_home.set_zone_activation_delay(0.0) fake_home.get_current_state() securityAlarmHome = fake_home.get_functionalHome(SecurityAndAlarmHome) assert securityAlarmHome.zoneActivationDelay == 0.0
def test_security_setIntrusionAlertThroughSmokeDetectors(fake_home: Home): with no_ssl_verification(): securityAlarmHome = fake_home.get_functionalHome(SecurityAndAlarmHome) assert securityAlarmHome.intrusionAlertThroughSmokeDetectors is False fake_home.set_intrusion_alert_through_smoke_detectors(True) fake_home.get_current_state() securityAlarmHome = fake_home.get_functionalHome(SecurityAndAlarmHome) assert securityAlarmHome.intrusionAlertThroughSmokeDetectors is True fake_home.set_intrusion_alert_through_smoke_detectors(False) fake_home.get_current_state() securityAlarmHome = fake_home.get_functionalHome(SecurityAndAlarmHome) assert securityAlarmHome.intrusionAlertThroughSmokeDetectors is False
def test_humidity_warning_rule_group(fake_home: Home): with no_ssl_verification(): g = fake_home.search_group_by_id("00000000-0000-0000-AAAA-000000000029") assert str(g) == ( "HUMIDITY_WARNING_RULE_GROUP Büro enabled(True) " "humidityValidationResult(LESSER_LOWER_THRESHOLD) " "humidityLowerThreshold(40) humidityUpperThreshold(60) " "triggered(False) lastExecutionTimestamp(2019-02-28 22:05:05.665000) " "lastStatusUpdate(2019-02-28 22:08:24.260000) ventilationRecommended(True)" ) assert g.outdoorClimateSensor is None g = fake_home.search_group_by_id("00000000-0000-0000-0000-000000000049") d = fake_home.search_device_by_id("3014F7110000000000000038") assert g.outdoorClimateSensor == d
def test_light_sensor(fake_home: Home): with no_ssl_verification(): d = LightSensor(fake_home._connection) d = fake_home.search_device_by_id("3014F711SLO0000000000026") assert d.averageIllumination == 807.3 assert d.currentIllumination == 785.2 assert d.highestIllumination == 837.1 assert d.lowestIllumination == 785.2 assert str(d) == ( "HmIP-SLO Lichtsensor Nord lowbat(False) unreach(False) rssiDeviceValue(-60) " "rssiPeerValue(None) configPending(False) dutyCycle(False) " "averageIllumination(807.3) currentIllumination(785.2) " "highestIllumination(837.1) lowestIllumination(785.2)")
def test_environment_group(fake_home: Home): with no_ssl_verification(): g = fake_home.search_group_by_id("00000000-AAAA-0000-0000-000000000001") assert isinstance(g, EnvironmentGroup) assert g.actualTemperature == 15.4 assert g.illumination == 4703.0 assert g.raining is False assert g.humidity == 65 assert g.windSpeed == 29.1 assert ( str(g) == "ENVIRONMENT Terrasse actualTemperature(15.4) illumination(4703.0) raining(False) windSpeed(29.1) humidity(65)" )
def test_acceleration_sensor(fake_home: Home): d = fake_home.search_device_by_id("3014F7110000000000000031") assert isinstance(d, AccelerationSensor) assert d.accelerationSensorEventFilterPeriod == 3.0 assert d.accelerationSensorMode == AccelerationSensorMode.FLAT_DECT assert (d.accelerationSensorNeutralPosition == AccelerationSensorNeutralPosition.VERTICAL) assert (d.accelerationSensorSensitivity == AccelerationSensorSensitivity.SENSOR_RANGE_4G) assert d.accelerationSensorTriggerAngle == 45 assert d.accelerationSensorTriggered == True assert d.notificationSoundTypeHighToLow == NotificationSoundType.SOUND_LONG assert d.notificationSoundTypeLowToHigh == NotificationSoundType.SOUND_LONG assert str(d) == ( "HmIP-SAM Garagentor lowbat(False) unreach(False) " "rssiDeviceValue(-88) rssiPeerValue(None) configPending(False)" " dutyCycle(False) accelerationSensorEventFilterPeriod(3.0)" " accelerationSensorMode(FLAT_DECT) accelerationSensorNeutralPosition(VERTICAL)" " accelerationSensorSensitivity(SENSOR_RANGE_4G) accelerationSensorTriggerAngle(45)" " accelerationSensorTriggered(True) notificationSoundTypeHighToLow(SOUND_LONG)" " notificationSoundTypeLowToHigh(SOUND_LONG)") with no_ssl_verification(): d.set_acceleration_sensor_event_filter_period(10.0) d.set_acceleration_sensor_mode(AccelerationSensorMode.ANY_MOTION) d.set_acceleration_sensor_neutral_position( AccelerationSensorNeutralPosition.HORIZONTAL) d.set_acceleration_sensor_sensitivity( AccelerationSensorSensitivity.SENSOR_RANGE_2G) d.set_acceleration_sensor_trigger_angle(30) d.set_notification_sound_type(NotificationSoundType.SOUND_SHORT, True) d.set_notification_sound_type(NotificationSoundType.SOUND_SHORT_SHORT, False) fake_home.get_current_state() d = fake_home.search_device_by_id("3014F7110000000000000031") assert d.accelerationSensorEventFilterPeriod == 10.0 assert d.accelerationSensorMode == AccelerationSensorMode.ANY_MOTION assert (d.accelerationSensorNeutralPosition == AccelerationSensorNeutralPosition.HORIZONTAL) assert (d.accelerationSensorSensitivity == AccelerationSensorSensitivity.SENSOR_RANGE_2G) assert d.accelerationSensorTriggerAngle == 30 assert d.notificationSoundTypeHighToLow == NotificationSoundType.SOUND_SHORT assert (d.notificationSoundTypeLowToHigh == NotificationSoundType.SOUND_SHORT_SHORT)
def test_home_unknown_types(fake_home: Home): with no_ssl_verification(): fake_home._restCall("fake/loadConfig", json.dumps({"file": "unknown_types.json"})) fake_home.get_current_state(clearConfig=True) group = fake_home.groups[0] assert type(group) == Group assert group.groupType == "DUMMY_GROUP" device = fake_home.devices[0] assert type(device) == Device assert device.deviceType == "DUMMY_DEVICE" funcHome = fake_home.functionalHomes[0] assert type(funcHome) == FunctionalHome assert funcHome.solution == "DUMMY_FUNCTIONAL_HOME"
def test_passage_detector(fake_home: Home): with no_ssl_verification(): d = PassageDetector(fake_home._connection) d = fake_home.search_device_by_id("3014F7110000000000000054") assert d.leftCounter == 966 assert d.leftRightCounterDelta == 164 assert d.passageBlindtime == 1.5 assert d.passageDirection == PassageDirection.LEFT assert d.passageSensorSensitivity == 50.0 assert d.passageTimeout == 0.5 assert d.rightCounter == 802 assert str(d) == ( "HmIP-SPDR SPDR_1 lowbat(False) unreach(False) rssiDeviceValue(-76) rssiPeerValue(None) configPending(False) dutyCycle(False)" " sabotage(False) leftCounter(966) leftRightCounterDelta(164) passageBlindtime(1.5) passageDirection(LEFT) passageSensorSensitivity(50.0)" " passageTimeout(0.5) rightCounter(802)")
def test_wall_mounted_thermostat_pro(fake_home: Home): d = fake_home.search_device_by_id("3014F7110000000000000022") assert isinstance(d, WallMountedThermostatPro) assert d.id == "3014F7110000000000000022" assert d.label == "Wandthermostat" assert d.lastStatusUpdate == datetime(2018, 4, 23, 20, 48, 54, 382000) + timedelta(0, utc_offset) assert d.manufacturerCode == 1 assert d.modelId == 297 assert d.modelType == "HmIP-WTH-2" assert d.oem == "eQ-3" assert d.serializedGlobalTradeItemNumber == "3014F7110000000000000022" assert d.updateState == DeviceUpdateState.UP_TO_DATE assert d.humidity == 43 assert d.vaporAmount == 6.177718198711658 assert d.setPointTemperature == 5.0 assert d.display == ClimateControlDisplay.ACTUAL_HUMIDITY assert d.temperatureOffset == 0.0 assert d.lowBat == False assert d.operationLockActive == False assert d.routerModuleEnabled == False assert d.routerModuleSupported == False assert d.rssiDeviceValue == -76 assert d.rssiPeerValue == -63 assert d.unreach == False assert d.dutyCycle == False assert d.availableFirmwareVersion == "0.0.0" assert d.firmwareVersion == "1.8.0" a, b, c = [int(i) for i in d.firmwareVersion.split(".")] assert d.firmwareVersionInteger == (a << 16) | (b << 8) | c assert str(d) == ( "HmIP-WTH-2 Wandthermostat lowbat(False) unreach(False) rssiDeviceValue(-76) rssiPeerValue(-63)" " configPending(False) dutyCycle(False) operationLockActive(False)" " actualTemperature(24.7) humidity(43) vaporAmount(6.177718198711658) setPointTemperature(5.0)" ) assert (d._rawJSONData == fake_home_download_configuration()["devices"] ["3014F7110000000000000022"]) with no_ssl_verification(): d.set_display(ClimateControlDisplay.ACTUAL) fake_home.get_current_state() d = fake_home.search_device_by_id("3014F7110000000000000022") assert d.display == ClimateControlDisplay.ACTUAL d.id = "INVALID_ID" result = d.set_display(ClimateControlDisplay.ACTUAL) assert result["errorCode"] == "INVALID_DEVICE"
def test_indoor_climate_home(fake_home: Home): with no_ssl_verification(): for fh in fake_home.functionalHomes: if not isinstance(fh, IndoorClimateHome): continue assert fh.active is True assert fh.absenceType == AbsenceType.NOT_ABSENT assert fh.coolingEnabled is False assert fh.ecoDuration == EcoDuration.PERMANENT assert fh.ecoTemperature == 17.0 assert fh.optimumStartStopEnabled is False minutes = 20 fake_home.activate_absence_with_duration(minutes) absence_end = datetime.now() + timedelta(minutes=minutes) absence_end = absence_end.replace(second=0, microsecond=0) fake_home.get_current_state() assert fh.absenceType == AbsenceType.PERIOD assert fh.absenceEndTime == absence_end absence_end = datetime.strptime("2100_01_01 22:22", "%Y_%m_%d %H:%M") fake_home.activate_absence_with_period(absence_end) fake_home.get_current_state() assert fh.absenceType == AbsenceType.PERIOD assert fh.absenceEndTime == absence_end fake_home.activate_absence_permanent() fake_home.get_current_state() assert fh.absenceType == AbsenceType.PERMANENT assert fh.absenceEndTime == datetime.strptime( "2100_12_31 23:59", "%Y_%m_%d %H:%M") assert fh.ecoDuration == EcoDuration.PERMANENT fake_home.deactivate_absence() fake_home.get_current_state() assert fh.absenceType == AbsenceType.NOT_ABSENT assert fh.absenceEndTime is None