def test_heating_thermostat(fake_home):
    d = fake_home.search_device_by_id('3014F7110000000000000015')
    assert isinstance(d, HeatingThermostat)
    assert d.label == "Wohnzimmer-Heizung"
    assert d.lastStatusUpdate == datetime(2018, 4, 23, 20, 5, 50, 325000) + timedelta(0,utc_offset)
    assert d.manufacturerCode == 1
    assert d.modelId == 269
    assert d.modelType == "HMIP-eTRV"
    assert d.oem == "eQ-3"
    assert d.serializedGlobalTradeItemNumber == "3014F7110000000000000015"
    assert d.updateState == "UP_TO_DATE"
    assert d.setPointTemperature == 5.0
    assert d.temperatureOffset == 0.0
    assert d.valvePosition == 0.0
    assert d.valveState == ValveState.ADAPTION_DONE
    assert d.lowBat == False
    assert d.operationLockActive == True
    assert d.routerModuleEnabled == False
    assert d.routerModuleSupported == False
    assert d.rssiDeviceValue == -65
    assert d.rssiPeerValue == -66
    assert d.unreach == False
    assert d.automaticValveAdaptionNeeded == False
    assert d.availableFirmwareVersion == "2.0.2"
    assert d.firmwareVersion == "2.0.2"

    assert str(d) == ('HMIP-eTRV Wohnzimmer-Heizung lowbat(False) unreach(False) rssiDeviceValue(-65) rssiPeerValue(-66) configPending(False) dutyCycle(False): operationLockActive(True)'
                    ' valvePosition(0.0) valveState(ADAPTION_DONE) temperatureOffset(0.0) setPointTemperature(5.0)')
    assert d._rawJSONData == fake_home_download_configuration()["devices"]["3014F7110000000000000015"]
示例#2
0
def test_temperature_humidity_sensor_outdoor(fake_home: Home):
    d = fake_home.search_device_by_id("3014F711AAAA000000000002")
    assert isinstance(d, TemperatureHumiditySensorOutdoor)
    assert d.label == "Temperatur- und Luftfeuchtigkeitssensor - außen"
    assert d.lastStatusUpdate == datetime(2018, 4, 23, 20, 5, 50,
                                          325000) + timedelta(0, utc_offset)
    assert d.manufacturerCode == 1
    assert d.modelId == 314
    assert d.modelType == "HmIP-STHO"
    assert d.oem == "eQ-3"
    assert d.serializedGlobalTradeItemNumber == "3014F711AAAA000000000002"
    assert d.updateState == DeviceUpdateState.UP_TO_DATE
    assert d.humidity == 70
    assert d.actualTemperature == 15.1
    assert d.lowBat == False
    assert d.routerModuleEnabled == False
    assert d.routerModuleSupported == False
    assert d.rssiDeviceValue == -55
    assert d.rssiPeerValue == None
    assert d.unreach == False
    assert d.configPending == False
    assert d.dutyCycle == False
    assert str(d) == (
        "HmIP-STHO Temperatur- und Luftfeuchtigkeitssensor - außen lowbat(False) unreach(False) rssiDeviceValue(-55) rssiPeerValue(None) configPending(False)"
        " dutyCycle(False) actualTemperature(15.1) humidity(70)")
    assert (d._rawJSONData == fake_home_download_configuration()["devices"]
            ["3014F711AAAA000000000002"])
示例#3
0
def test_smoke_detector(fake_home: Home):
    d = fake_home.search_device_by_id("3014F7110000000000000020")
    assert isinstance(d, SmokeDetector)
    assert d.label == "Rauchwarnmelder"
    assert d.lastStatusUpdate == datetime(2018, 4, 23, 4, 5, 24,
                                          824000) + timedelta(0, utc_offset)
    assert d.manufacturerCode == 1
    assert d.modelId == 296
    assert d.modelType == "HmIP-SWSD"
    assert d.oem == "eQ-3"
    assert d.serializedGlobalTradeItemNumber == "3014F7110000000000000020"
    assert d.updateState == DeviceUpdateState.UP_TO_DATE
    assert d.lowBat == False
    assert d.routerModuleEnabled == False
    assert d.routerModuleSupported == False
    assert d.rssiDeviceValue == -54
    assert d.rssiPeerValue == None
    assert d.unreach == False
    assert d.smokeDetectorAlarmType == SmokeDetectorAlarmType.IDLE_OFF
    assert d.availableFirmwareVersion == "0.0.0"
    assert d.firmwareVersion == "1.0.11"
    a, b, c = [int(i) for i in d.firmwareVersion.split(".")]
    assert d.firmwareVersionInteger == (a << 16) | (b << 8) | c
    assert d.configPending == False
    assert (
        str(d) ==
        "HmIP-SWSD Rauchwarnmelder lowbat(False) unreach(False) rssiDeviceValue(-54) rssiPeerValue(None) configPending(False) dutyCycle(False) smokeDetectorAlarmType(IDLE_OFF)"
    )
    assert (d._rawJSONData == fake_home_download_configuration()["devices"]
            ["3014F7110000000000000020"])
示例#4
0
def test_shutter_device(fake_home: Home):
    d = fake_home.search_device_by_id('3014F7110000000000000001')
    assert isinstance(d, ShutterContact)
    assert d.label == "Fenster"
    assert d.lastStatusUpdate == datetime(2018, 4, 23, 20, 37, 34,
                                          304000) + timedelta(0, utc_offset)
    assert d.manufacturerCode == 1
    assert d.modelId == 258
    assert d.modelType == "HMIP-SWDO"
    assert d.oem == "eQ-3"
    assert d.windowState == WindowState.CLOSED
    assert d.serializedGlobalTradeItemNumber == "3014F7110000000000000001"
    assert d.availableFirmwareVersion == "1.16.8"
    assert d.firmwareVersion == "1.16.8"
    a, b, c = [int(i) for i in d.firmwareVersion.split('.')]
    assert d.firmwareVersionInteger == (a << 16) | (b << 8) | c
    assert d.lowBat == False
    assert d.routerModuleEnabled == False
    assert d.routerModuleSupported == False
    assert d.rssiDeviceValue == -64
    assert d.rssiPeerValue == None
    assert d.dutyCycle == False
    assert d.configPending == False
    assert str(
        d
    ) == 'HMIP-SWDO Fenster lowbat(False) unreach(False) rssiDeviceValue(-64) rssiPeerValue(None) configPending(False) dutyCycle(False) sabotage(False) windowState(CLOSED)'
    assert d._rawJSONData == fake_home_download_configuration(
    )["devices"]["3014F7110000000000000001"]

    d = fake_home.search_device_by_id('3014F7110000000000000005')
    assert d.windowState == WindowState.OPEN
    assert d.lastStatusUpdate == None

    assert d.set_router_module_enabled(
        True) == False  # Shutter contact won't support this
示例#5
0
def test_weather_sensor_plus(fake_home: Home):
    d = fake_home.search_device_by_id("3014F7110000000000000038")
    assert isinstance(d, WeatherSensorPlus)
    assert d.humidity == 97
    assert d.illumination == 26.4
    assert d.illuminationThresholdSunshine == 3500.0
    assert d.raining == False
    assert d.storm == False
    assert d.sunshine == False
    assert d.todayRainCounter == 3.8999999999999773
    assert d.todaySunshineDuration == 0
    assert d.totalRainCounter == 544.0999999999999
    assert d.totalSunshineDuration == 132057
    assert d.windSpeed == 15.0
    assert d.windValueType == WindValueType.CURRENT_VALUE
    assert d.yesterdayRainCounter == 25.600000000000023
    assert d.yesterdaySunshineDuration == 0
    assert d.actualTemperature == 4.3
    assert d.lowBat == False
    assert d.routerModuleEnabled == False
    assert d.routerModuleSupported == False
    assert d.rssiDeviceValue == -55
    assert d.rssiPeerValue == None
    assert d.unreach == False
    assert d.configPending == False
    assert d.dutyCycle == False
    assert str(d) == (
        "HmIP-SWO-PL Weather Sensor \u2013 plus lowbat(False) unreach(False) rssiDeviceValue(-55) rssiPeerValue(None) configPending(False) dutyCycle(False) actualTemperature(4.3)"
        " humidity(97) illumination(26.4) illuminationThresholdSunshine(3500.0) raining(False) storm(False) sunshine(False) todayRainCounter(3.8999999999999773) todaySunshineDuration(0)"
        " totalRainCounter(544.0999999999999) totalSunshineDuration(132057) windSpeed(15.0)"
        " windValueType(CURRENT_VALUE) yesterdayRainCounter(25.600000000000023) yesterdaySunshineDuration(0)"
    )
    assert (d._rawJSONData == fake_home_download_configuration()["devices"]
            ["3014F7110000000000000038"])
示例#6
0
def test_rotary_handle_sensor(fake_home: Home):
    d = fake_home.search_device_by_id("3014F711AAAA000000000004")
    assert isinstance(d, RotaryHandleSensor)
    assert d.label == "Fenstergriffsensor"
    assert d.lastStatusUpdate == datetime(2018, 4, 27, 8, 6, 25,
                                          462000) + timedelta(0, utc_offset)
    assert d.manufacturerCode == 1
    assert d.modelId == 286
    assert d.modelType == "HmIP-SRH"
    assert d.oem == "eQ-3"
    assert d.windowState == WindowState.TILTED
    assert d.serializedGlobalTradeItemNumber == "3014F711AAAA000000000004"
    assert d.availableFirmwareVersion == "1.2.10"
    assert d.firmwareVersion == "1.2.10"
    a, b, c = [int(i) for i in d.firmwareVersion.split(".")]
    assert d.firmwareVersionInteger == (a << 16) | (b << 8) | c

    assert d.lowBat == False
    assert d.routerModuleEnabled == False
    assert d.routerModuleSupported == False
    assert d.rssiDeviceValue == -54
    assert d.rssiPeerValue == None
    assert d.dutyCycle == False
    assert d.configPending == False
    assert str(d) == (
        "HmIP-SRH Fenstergriffsensor lowbat(False) unreach(False) rssiDeviceValue(-54) rssiPeerValue(None) configPending(False) dutyCycle(False)"
        " sabotage(False) windowState(TILTED)")
    assert (d._rawJSONData == fake_home_download_configuration()["devices"]
            ["3014F711AAAA000000000004"])
示例#7
0
def test_meta_group(fake_home):
    g = fake_home.search_group_by_id('00000000-0000-0000-0000-000000000020')
    assert isinstance(g, MetaGroup)
    assert g.label == "Badezimmer"
    assert g.lastStatusUpdate == datetime(2018, 4, 23, 20, 49, 16,
                                          479000) + timedelta(0, utc_offset)
    assert g.lowBat == False
    assert g.metaGroup == None
    assert g.sabotage == None
    assert g.configPending == False
    assert g.unreach == False
    assert g.dutyCycle == False
    assert g.incorrectPositioned == None
    for d in g.devices:
        assert d.id in ['3014F7110000000000000025', '3014F7110000000000000016']
    for g_sub in g.groups:
        assert g_sub.id in [
            '00000000-0000-0000-0000-000000000021',
            '00000000-0000-0000-0000-000000000021'
        ]

    assert str(g) == "META Badezimmer"

    assert g._rawJSONData == fake_home_download_configuration(
    )["groups"]["00000000-0000-0000-0000-000000000020"]
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 == "UP_TO_DATE"
    assert d.humidity == 43
    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"
    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) 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
def test_pluggable_switch_measuring(fake_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 == "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"
    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"]
示例#10
0
def test_heating_group(fake_home):
    g = fake_home.search_group_by_id('00000000-0000-0000-0000-000000000012')
    assert isinstance(g, HeatingGroup)
    for d in g.devices:
        assert d.id in [
            '3014F7110000000000000004', '3014F7110000000000000022',
            '3014F7110000000000000011'
        ]

    assert g.activeProfile.index == "PROFILE_1"
    assert g.activeProfile.enabled == True
    assert g.activeProfile.name == ""
    assert g.activeProfile.visible == True
    assert g.activeProfile.id == "00000000-0000-0000-0000-000000000023"
    assert g.activeProfile.groupId == "00000000-0000-0000-0000-000000000012"

    profile3 = g.profiles[2]
    assert profile3.index == 'PROFILE_3'
    assert profile3.visible == False
    assert profile3.id == '00000000-0000-0000-0000-000000000025'

    assert g.actualTemperature == 24.7
    assert g.boostDuration == 15
    assert g.boostMode == False
    assert g.controlMode == "AUTOMATIC"
    assert g.controllable == True
    assert g.cooling == False
    assert g.coolingAllowed == False
    assert g.coolingIgnored == False
    assert g.dutyCycle == False
    assert g.ecoAllowed == True
    assert g.ecoIgnored == False
    assert g.externalClockCoolingTemperature == 23.0
    assert g.externalClockEnabled == False
    assert g.externalClockHeatingTemperature == 19.0
    assert g.floorHeatingMode == "FLOOR_HEATING_STANDARD"
    assert g.humidity == 43
    assert g.humidityLimitEnabled == True
    assert g.humidityLimitValue == 60
    assert g.label == "Schlafzimmer"
    assert g.lastStatusUpdate == datetime(2018, 4, 23, 20, 48, 54,
                                          382000) + timedelta(0, utc_offset)
    assert g.lowBat == False
    assert g.maxTemperature == 30.0
    assert g.metaGroup.id == "00000000-0000-0000-0000-000000000011"
    assert g.minTemperature == 5.0
    assert g.partyMode == False
    assert g.setPointTemperature == 5.0
    assert g.unreach == False
    assert g.valvePosition == 0.0
    assert g.windowOpenTemperature == 5.0
    assert g.windowState == "OPEN"

    assert str(g) == (
        'HEATING Schlafzimmer windowOpenTemperature(5.0) setPointTemperature(5.0) windowState(OPEN) motionDetected(30.0)'
        ' sabotage(5.0) cooling(False) partyMode(False) controlMode(AUTOMATIC) actualTemperature(24.7) valvePosition(0.0)'
    )

    assert g._rawJSONData == fake_home_download_configuration(
    )["groups"]["00000000-0000-0000-0000-000000000012"]
def test_weather_sensor_pro(fake_home: Home):
    d = fake_home.search_device_by_id("3014F711AAAA000000000001")
    assert isinstance(d, WeatherSensorPro)
    assert d.label == "Wettersensor - pro"
    assert d.lastStatusUpdate == datetime(2018, 4, 23, 20, 5, 50, 325000) + timedelta(
        0, utc_offset
    )
    assert d.manufacturerCode == 1
    assert d.modelId == 352
    assert d.modelType == "HmIP-SWO-PR"
    assert d.oem == "eQ-3"
    assert d.serializedGlobalTradeItemNumber == "3014F711AAAA000000000001"
    assert d.updateState == DeviceUpdateState.UP_TO_DATE
    assert d.availableFirmwareVersion == "0.0.0"
    assert d.firmwareVersion == "1.0.10"
    a, b, c = [int(i) for i in d.firmwareVersion.split(".")]
    assert d.firmwareVersionInteger == (a << 16) | (b << 8) | c
    assert d.humidity == 65
    assert d.vaporAmount == 6.177718198711658
    assert d.illumination == 4153.0
    assert d.illuminationThresholdSunshine == 10.0
    assert d.raining == False
    assert d.storm == False
    assert d.sunshine == True
    assert d.todayRainCounter == 6.5
    assert d.todaySunshineDuration == 100
    assert d.totalRainCounter == 6.5
    assert d.totalSunshineDuration == 100
    assert d.weathervaneAlignmentNeeded == False
    assert d.windDirection == 295.0
    assert d.windDirectionVariation == 56.25
    assert d.windSpeed == 2.6
    assert d.windValueType == WindValueType.AVERAGE_VALUE
    assert d.yesterdayRainCounter == 0.0
    assert d.yesterdaySunshineDuration == 0
    assert d.actualTemperature == 15.4
    assert d.lowBat == False
    assert d.routerModuleEnabled == False
    assert d.routerModuleSupported == False
    assert d.rssiDeviceValue == -68
    assert d.rssiPeerValue == None
    assert d.unreach == False
    assert d.configPending == False
    assert d.dutyCycle == False
    assert str(d) == (
        "HmIP-SWO-PR Wettersensor - pro lowbat(False) unreach(False) rssiDeviceValue(-68)"
        " rssiPeerValue(None) configPending(False) dutyCycle(False)"
        " actualTemperature(15.4) humidity(65) vaporAmount(6.177718198711658)"
        " illumination(4153.0) illuminationThresholdSunshine(10.0)"
        " raining(False) storm(False) sunshine(True) todayRainCounter(6.5) todaySunshineDuration(100)"
        " totalRainCounter(6.5) totalSunshineDuration(100)"
        " weathervaneAlignmentNeeded(False) windDirection(295.0)"
        " windDirectionVariation(56.25) windSpeed(2.6)"
        " windValueType(AVERAGE_VALUE) yesterdayRainCounter(0.0) yesterdaySunshineDuration(0)"
    )
    assert (
        d._rawJSONData
        == fake_home_download_configuration()["devices"]["3014F711AAAA000000000001"]
    )
def test_home_location(fake_home: Home):
    assert fake_home.location.city == "1010  Wien, Österreich"
    assert fake_home.location.latitude == "48.208088"
    assert fake_home.location.longitude == "16.358608"
    assert fake_home.location._rawJSONData == fake_home_download_configuration(
    )["home"]["location"]
    assert str(
        fake_home.location
    ) == "city(1010  Wien, Österreich) latitude(48.208088) longitude(16.358608)"
async def test_home_location(no_ssl_fake_async_home: AsyncHome):
    assert no_ssl_fake_async_home.location.city == "1010  Wien, Österreich"
    assert no_ssl_fake_async_home.location.latitude == "48.208088"
    assert no_ssl_fake_async_home.location.longitude == "16.358608"
    assert (no_ssl_fake_async_home.location._rawJSONData ==
            fake_home_download_configuration()["home"]["location"])
    assert (
        str(no_ssl_fake_async_home.location) ==
        "city(1010  Wien, Österreich) latitude(48.208088) longitude(16.358608)"
    )
示例#14
0
def test_clients(fake_home: Home):
    client = fake_home.search_client_by_id(
        "00000000-0000-0000-0000-000000000000")
    assert client.label == "TEST-Client"
    assert client.homeId == "00000000-0000-0000-0000-000000000001"
    assert client.id == "00000000-0000-0000-0000-000000000000"
    assert client.clientType == ClientType.APP

    assert (client._rawJSONData == fake_home_download_configuration()
            ["clients"]["00000000-0000-0000-0000-000000000000"])
    assert str(client) == "label(TEST-Client)"
def test_clients(fake_home: Home):
    client = fake_home.search_client_by_id(
        '00000000-0000-0000-0000-000000000000')
    assert client.label == 'TEST-Client'
    assert client.homeId == '00000000-0000-0000-0000-000000000001'
    assert client.id == '00000000-0000-0000-0000-000000000000'
    assert client.clientType == ClientType.APP

    assert client._rawJSONData == fake_home_download_configuration(
    )["clients"]['00000000-0000-0000-0000-000000000000']
    assert str(client) == "label(TEST-Client)"
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"
示例#17
0
def test_home_base(fake_home: Home):
    assert fake_home.connected == True
    assert fake_home.currentAPVersion == "1.2.4"
    assert fake_home.deviceUpdateStrategy == "AUTOMATICALLY_IF_POSSIBLE"
    assert fake_home.dutyCycle == 8.0
    assert fake_home.pinAssigned == False
    assert fake_home.powerMeterCurrency == "EUR"
    assert fake_home.powerMeterUnitPrice == 0.0
    assert fake_home.timeZoneId == "Europe/Vienna"
    assert fake_home.updateState == "UP_TO_DATE"

    assert fake_home._rawJSONData == fake_home_download_configuration()["home"]
def test_home_weather(fake_home: Home):
    assert fake_home.weather.humidity == 54
    assert fake_home.weather.maxTemperature == 16.6
    assert fake_home.weather.minTemperature == 16.6
    assert fake_home.weather.temperature == 16.6
    assert fake_home.weather.weatherCondition == WeatherCondition.LIGHT_CLOUDY
    assert fake_home.weather.weatherDayTime == WeatherDayTime.NIGHT
    assert fake_home.weather.windDirection == 294
    assert fake_home.weather.windSpeed == 8.568
    assert fake_home.weather._rawJSONData == fake_home_download_configuration(
    )["home"]["weather"]
    assert str(
        fake_home.weather
    ) == "temperature(16.6) weatherCondition(LIGHT_CLOUDY) weatherDayTime(NIGHT) minTemperature(16.6) maxTemperature(16.6) humidity(54) windSpeed(8.568) windDirection(294)"
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_heating_thermostat(fake_home: Home):
    d = fake_home.search_device_by_id("3014F7110000000000000015")
    assert isinstance(d, HeatingThermostat)
    assert d.label == "Wohnzimmer-Heizung"
    assert d.lastStatusUpdate == datetime(2018, 4, 23, 20, 5, 50, 325000) + timedelta(
        0, utc_offset
    )
    assert d.manufacturerCode == 1
    assert d.modelId == 269
    assert d.modelType == "HMIP-eTRV"
    assert d.oem == "eQ-3"
    assert d.serializedGlobalTradeItemNumber == "3014F7110000000000000015"
    assert d.updateState == DeviceUpdateState.UP_TO_DATE
    assert d.setPointTemperature == 5.0
    assert d.temperatureOffset == 0.0
    assert d.valvePosition == 0.0
    assert d.valveState == ValveState.ADAPTION_DONE
    assert d.lowBat == False
    assert d.operationLockActive == True
    assert d.routerModuleEnabled == False
    assert d.routerModuleSupported == False
    assert d.rssiDeviceValue == -65
    assert d.rssiPeerValue == -66
    assert d.unreach == False
    assert d.automaticValveAdaptionNeeded == False
    assert d.availableFirmwareVersion == "2.0.2"
    assert d.firmwareVersion == "2.0.2"
    a, b, c = [int(i) for i in d.firmwareVersion.split(".")]
    assert d.firmwareVersionInteger == (a << 16) | (b << 8) | c
    assert d.valveActualTemperature == 20.0

    assert str(d) == (
        "HMIP-eTRV Wohnzimmer-Heizung lowbat(False) unreach(False) rssiDeviceValue(-65) rssiPeerValue(-66) configPending(False) dutyCycle(False) operationLockActive(True)"
        " valvePosition(0.0) valveState(ADAPTION_DONE) temperatureOffset(0.0) setPointTemperature(5.0) valveActualTemperature(20.0)"
    )
    assert (
        d._rawJSONData
        == fake_home_download_configuration()["devices"]["3014F7110000000000000015"]
    )

    with no_ssl_verification():
        d.set_operation_lock(False)
        fake_home.get_current_state()
        d = fake_home.search_device_by_id("3014F7110000000000000015")
        assert d.operationLockActive == False

        d.id = "INVALID_ID"
        result = d.set_operation_lock(True)
        assert result["errorCode"] == "INVALID_DEVICE"
def test_weather_sensor(fake_home: Home):
    d = fake_home.search_device_by_id("3014F711AAAA000000000003")
    assert isinstance(d, WeatherSensor)
    assert d.lastStatusUpdate == datetime(2018, 4, 23, 20, 5, 50, 325000) + timedelta(
        0, utc_offset
    )
    assert d.lowBat == False
    assert d.routerModuleEnabled == False
    assert d.routerModuleSupported == False
    assert d.rssiDeviceValue == -77
    assert d.rssiPeerValue == None
    assert d.unreach == False
    assert d.configPending == False
    assert d.dutyCycle == False
    assert d.availableFirmwareVersion == "0.0.0"
    assert d.firmwareVersion == "1.0.10"
    a, b, c = [int(i) for i in d.firmwareVersion.split(".")]
    assert d.firmwareVersionInteger == (a << 16) | (b << 8) | c
    assert d.humidity == 42
    assert d.vaporAmount == 6.177718198711658
    assert d.illumination == 4890.0
    assert d.illuminationThresholdSunshine == 3500.0
    assert d.storm == False
    assert d.sunshine == True
    assert d.todaySunshineDuration == 51
    assert d.totalSunshineDuration == 54
    assert d.windSpeed == 6.6
    assert d.windValueType == WindValueType.MAX_VALUE
    assert d.yesterdaySunshineDuration == 3
    assert d.actualTemperature == 15.2
    assert d.label == "Wettersensor"
    assert d.manufacturerCode == 1
    assert d.modelId == 350
    assert d.modelType == "HmIP-SWO-B"
    assert d.oem == "eQ-3"
    assert d.serializedGlobalTradeItemNumber == "3014F711AAAA000000000003"
    assert d.updateState == DeviceUpdateState.UP_TO_DATE
    assert str(d) == (
        "HmIP-SWO-B Wettersensor lowbat(False) unreach(False) rssiDeviceValue(-77)"
        " rssiPeerValue(None) configPending(False) dutyCycle(False)"
        " actualTemperature(15.2) humidity(42) vaporAmount(6.177718198711658)"
        " illumination(4890.0) illuminationThresholdSunshine(3500.0) storm(False) sunshine(True)"
        " todaySunshineDuration(51) totalSunshineDuration(54) windSpeed(6.6)"
        " windValueType(MAX_VALUE) yesterdaySunshineDuration(3)"
    )
    assert (
        d._rawJSONData
        == fake_home_download_configuration()["devices"]["3014F711AAAA000000000003"]
    )
def test_heating_group(fake_home: Home):
    g = fake_home.search_group_by_id("00000000-0000-0000-0000-000000000012")
    assert isinstance(g, HeatingGroup)
    for d in g.devices:
        assert d.id in [
            "3014F7110000000000000004",
            "3014F7110000000000000022",
            "3014F7110000000000000011",
        ]

    assert g.activeProfile.index == "PROFILE_1"
    assert g.activeProfile.enabled == True
    assert g.activeProfile.name == ""
    assert g.activeProfile.visible == True
    assert g.activeProfile.id == "00000000-0000-0000-0000-000000000023"
    assert g.activeProfile.groupId == "00000000-0000-0000-0000-000000000012"

    profile3 = g.profiles[2]
    assert profile3.index == "PROFILE_3"
    assert profile3.visible == False
    assert profile3.id == "00000000-0000-0000-0000-000000000025"

    assert g.actualTemperature == 24.7
    assert g.boostDuration == 15
    assert g.boostMode == False
    assert g.controlMode == ClimateControlMode.AUTOMATIC
    assert g.controllable == True
    assert g.cooling == False
    assert g.coolingAllowed == False
    assert g.coolingIgnored == False
    assert g.dutyCycle == False
    assert g.ecoAllowed == True
    assert g.ecoIgnored == False
    assert g.externalClockCoolingTemperature == 23.0
    assert g.externalClockEnabled == False
    assert g.externalClockHeatingTemperature == 19.0
    assert g.floorHeatingMode == "FLOOR_HEATING_STANDARD"
    assert g.humidity == 43
    assert g.humidityLimitEnabled == True
    assert g.humidityLimitValue == 60
    assert g.label == "Schlafzimmer"
    assert g.lastStatusUpdate == datetime(2018, 4, 23, 20, 48, 54,
                                          382000) + timedelta(0, utc_offset)
    assert g.lowBat == False
    assert g.maxTemperature == 30.0
    assert g.metaGroup.id == "00000000-0000-0000-0000-000000000011"
    assert g.minTemperature == 5.0
    assert g.partyMode == False
    assert g.setPointTemperature == 5.0
    assert g.unreach == False
    assert g.valvePosition == 0.0
    assert g.windowOpenTemperature == 5.0
    assert g.windowState == "OPEN"

    assert str(g) == (
        "HEATING Schlafzimmer windowOpenTemperature(5.0) setPointTemperature(5.0) windowState(OPEN) motionDetected(30.0)"
        " sabotage(5.0) cooling(False) partyMode(False) controlMode(AUTOMATIC) actualTemperature(24.7) valvePosition(0.0)"
    )

    assert (g._rawJSONData == fake_home_download_configuration()["groups"]
            ["00000000-0000-0000-0000-000000000012"])

    with no_ssl_verification():
        g.set_boost_duration(20)
        g.set_boost(True)
        g.set_active_profile(3)
        g.set_point_temperature(10.5)
        g.set_control_mode(ClimateControlMode.MANUAL)

        fake_home.get_current_state()
        g = fake_home.search_group_by_id(
            "00000000-0000-0000-0000-000000000012")
        assert g.boostDuration == 20
        assert g.boostMode == True
        assert g.activeProfile.index == "PROFILE_4"
        assert g.setPointTemperature == 10.5
        assert g.controlMode == ClimateControlMode.MANUAL

        fake_home.delete_group(g)
        fake_home.get_current_state()
        gNotFound = fake_home.search_group_by_id(
            "00000000-0000-0000-0000-000000000012")
        assert gNotFound == None

        result = g.set_boost_duration(20)
        assert result["errorCode"] == "INVALID_GROUP"

        result = g.set_boost(True)
        assert result["errorCode"] == "INVALID_GROUP"

        result = g.set_active_profile(1)
        assert result["errorCode"] == "INVALID_GROUP"

        result = g.set_point_temperature(10.5)
        assert result["errorCode"] == "INVALID_GROUP"

        result = g.set_control_mode(ClimateControlMode.MANUAL)
        assert result["errorCode"] == "INVALID_GROUP"