Skip to content

Commit

Permalink
#523 Fix Hmip-BSL Version 2.0.2
Browse files Browse the repository at this point in the history
  • Loading branch information
hahn-th committed May 8, 2024
1 parent ee969db commit 1510892
Show file tree
Hide file tree
Showing 4 changed files with 254 additions and 1 deletion.
173 changes: 173 additions & 0 deletions homematicip_demo/json_data/home.json
Original file line number Diff line number Diff line change
Expand Up @@ -4261,6 +4261,179 @@
"type": "BRAND_SWITCH_NOTIFICATION_LIGHT",
"updateState": "UP_TO_DATE"
},
"3014F711000000000000BSL2": {
"availableFirmwareVersion": "2.0.2",
"connectionType": "HMIP_RF",
"deviceArchetype": "HMIP",
"firmwareVersion": "2.0.2",
"firmwareVersionInteger": 131074,
"functionalChannels": {
"0": {
"busConfigMismatch": null,
"coProFaulty": false,
"coProRestartNeeded": false,
"coProUpdateFailure": false,
"configPending": false,
"controlsMountingOrientation": null,
"daliBusState": null,
"defaultLinkedGroup": [],
"deviceCommunicationError": null,
"deviceDriveError": null,
"deviceDriveModeError": null,
"deviceId": "3014F711000000000000BSL2",
"deviceOperationMode": null,
"deviceOverheated": false,
"deviceOverloaded": false,
"devicePowerFailureDetected": false,
"deviceUndervoltage": false,
"displayContrast": null,
"dutyCycle": false,
"functionalChannelType": "DEVICE_BASE",
"groupIndex": 0,
"groups": [
"00000000-0000-0000-0000-000000000007"
],
"index": 0,
"label": "",
"lockJammed": null,
"lowBat": null,
"mountingOrientation": null,
"multicastRoutingEnabled": false,
"particulateMatterSensorCommunicationError": null,
"particulateMatterSensorError": null,
"powerShortCircuit": null,
"profilePeriodLimitReached": null,
"routerModuleEnabled": false,
"routerModuleSupported": false,
"rssiDeviceValue": -74,
"rssiPeerValue": -75,
"sensorCommunicationError": null,
"sensorError": null,
"shortCircuitDataLine": null,
"supportedOptionalFeatures": {
"IFeatureBusConfigMismatch": false,
"IFeatureDeviceCoProError": false,
"IFeatureDeviceCoProRestart": false,
"IFeatureDeviceCoProUpdate": false,
"IFeatureDeviceCommunicationError": false,
"IFeatureDeviceDaliBusError": false,
"IFeatureDeviceDriveError": false,
"IFeatureDeviceDriveModeError": false,
"IFeatureDeviceIdentify": true,
"IFeatureDeviceOverheated": true,
"IFeatureDeviceOverloaded": false,
"IFeatureDeviceParticulateMatterSensorCommunicationError": false,
"IFeatureDeviceParticulateMatterSensorError": false,
"IFeatureDevicePowerFailure": false,
"IFeatureDeviceSensorCommunicationError": false,
"IFeatureDeviceSensorError": false,
"IFeatureDeviceTemperatureHumiditySensorCommunicationError": false,
"IFeatureDeviceTemperatureHumiditySensorError": false,
"IFeatureDeviceTemperatureOutOfRange": false,
"IFeatureDeviceUndervoltage": false,
"IFeatureMulticastRouter": false,
"IFeaturePowerShortCircuit": false,
"IFeatureProfilePeriodLimit": true,
"IFeatureRssiValue": true,
"IFeatureShortCircuitDataLine": false,
"IOptionalFeatureDefaultLinkedGroup": false,
"IOptionalFeatureDeviceErrorLockJammed": false,
"IOptionalFeatureDeviceOperationMode": false,
"IOptionalFeatureDisplayContrast": false,
"IOptionalFeatureDutyCycle": true,
"IOptionalFeatureLowBat": false,
"IOptionalFeatureMountingOrientation": false
},
"temperatureHumiditySensorCommunicationError": null,
"temperatureHumiditySensorError": null,
"temperatureOutOfRange": false,
"unreach": false
},
"1": {
"channelRole": null,
"deviceId": "3014F711000000000000BSL2",
"functionalChannelType": "SWITCH_CHANNEL",
"groupIndex": 1,
"groups": [],
"index": 1,
"internalLinkConfiguration": {
"firstInputAction": "OFF",
"internalLinkConfigurationType": "DOUBLE_INPUT_SWITCH",
"longPressOnTimeEnabled": false,
"onTime": 111600.0,
"secondInputAction": "ON"
},
"label": "",
"on": false,
"powerUpSwitchState": "PERMANENT_OFF",
"profileMode": "AUTOMATIC",
"supportedOptionalFeatures": {
"IFeatureAccessAuthorizationActuatorChannel": false,
"IFeatureGarageGroupActuatorChannel": false,
"IFeatureLightGroupActuatorChannel": false,
"IFeatureLightProfileActuatorChannel": false,
"IOptionalFeatureInternalLinkConfiguration": true,
"IOptionalFeaturePowerUpSwitchState": true
},
"userDesiredProfileMode": "AUTOMATIC"
},
"2": {
"channelRole": "NOTIFICATION_LIGHT_DIMMING_ACTUATOR",
"deviceId": "3014F711000000000000BSL2",
"dimLevel": 0.0,
"functionalChannelType": "NOTIFICATION_LIGHT_CHANNEL",
"groupIndex": 2,
"groups": [
"00000000-0000-0000-0000-000000000021"
],
"index": 2,
"label": "Led Unten",
"on": false,
"opticalSignalBehaviour": "BLINKING_MIDDLE",
"profileMode": "AUTOMATIC",
"simpleRGBColorState": "TURQUOISE",
"supportedOptionalFeatures": {
"IFeatureOpticalSignalBehaviourState": true
},
"userDesiredProfileMode": "AUTOMATIC"
},
"3": {
"channelRole": "NOTIFICATION_LIGHT_DIMMING_ACTUATOR",
"deviceId": "3014F711000000000000BSL2",
"dimLevel": 0.25,
"functionalChannelType": "NOTIFICATION_LIGHT_CHANNEL",
"groupIndex": 3,
"groups": [
"00000000-0000-0000-0000-000000000021"
],
"index": 3,
"label": "Led Oben",
"on": true,
"opticalSignalBehaviour": "BLINKING_MIDDLE",
"profileMode": "AUTOMATIC",
"simpleRGBColorState": "GREEN",
"supportedOptionalFeatures": {
"IFeatureOpticalSignalBehaviourState": true
},
"userDesiredProfileMode": "AUTOMATIC"
}
},
"homeId": "00000000-0000-0000-0000-000000000001",
"id": "3014F711000000000000BSL2",
"label": "Signalleuchte",
"lastStatusUpdate": 1714910246419,
"liveUpdateState": "LIVE_UPDATE_NOT_SUPPORTED",
"manuallyUpdateForced": false,
"manufacturerCode": 1,
"measuredAttributes": {},
"modelId": 360,
"modelType": "HmIP-BSL",
"oem": "eQ-3",
"permanentlyReachable": true,
"serializedGlobalTradeItemNumber": "3014F711000000000000BSL2",
"type": "BRAND_SWITCH_NOTIFICATION_LIGHT",
"updateState": "UP_TO_DATE"
},
"3014F711SLO0000000000026": {
"availableFirmwareVersion": "0.0.0",
"connectionType": "HMIP_RF",
Expand Down
43 changes: 42 additions & 1 deletion src/homematicip/base/functionalChannels.py
Original file line number Diff line number Diff line change
Expand Up @@ -740,7 +740,7 @@ def from_json(self, js, groups: Iterable[Group]):
self.set_attr_from_dict("userDesiredProfileMode", js, ProfileMode)


class NotificationLightChannel(DimmerChannel):
class NotificationLightChannel(DimmerChannel, SwitchChannel):
"""this is the representative of the NOTIFICATION_LIGHT_CHANNEL channel"""

def __init__(self, device, connection):
Expand All @@ -750,11 +750,52 @@ def __init__(self, device, connection):
#:RGBColorState:the color of the light
self.simpleRGBColorState = RGBColorState.BLACK


def from_json(self, js, groups: Iterable[Group]):
super().from_json(js, groups)
self.on = js["on"]
self.simpleRGBColorState = RGBColorState.from_str(js["simpleRGBColorState"])

if "opticalSignalBehaviour" in js:
self.opticalSignalBehaviour = OpticalSignalBehaviour.from_str(js["opticalSignalBehaviour"])


def set_optical_signal(
self,
opticalSignalBehaviour: OpticalSignalBehaviour,
rgb: RGBColorState,
dimLevel=1.01,
):
"""sets the signal type for the leds
Args:
opticalSignalBehaviour(OpticalSignalBehaviour): LED signal behaviour
rgb(RGBColorState): Color
dimLevel(float): usally 1.01. Use set_dim_level instead
Returns:
Result of the _restCall
"""
data = {
"channelIndex": self.index,
"deviceId": self.device.id,
"dimLevel": dimLevel,
"opticalSignalBehaviour": opticalSignalBehaviour,
"simpleRGBColorState": rgb,
}
return self._rest_call("device/control/setOpticalSignal", body=json.dumps(data))

async def async_set_optical_signal(
self,
opticalSignalBehaviour: OpticalSignalBehaviour,
rgb: RGBColorState,
dimLevel=1.01,
):
return await self._connection.api_call(
*self.set_optical_signal(opticalSignalBehaviour, rgb, dimLevel)
)

def set_rgb_dim_level(self, rgb: RGBColorState, dimLevel: float):
"""sets the color and dimlevel of the lamp
Expand Down
11 changes: 11 additions & 0 deletions tests/aio_tests/test_async_functional_channels.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,17 @@ async def test_notification_light_channel(no_ssl_fake_async_home: AsyncHome):
assert ch.dimLevel == 0.5
assert ch.simpleRGBColorState == RGBColorState.BLACK

await no_ssl_fake_async_home.get_current_state()
ch = no_ssl_fake_async_home.search_channel("3014F711000000000000BSL2", 3)
await ch.async_set_optical_signal(OpticalSignalBehaviour.FLASH_MIDDLE, RGBColorState.WHITE, 0.6)
await no_ssl_fake_async_home.get_current_state()
ch = no_ssl_fake_async_home.search_channel("3014F711000000000000BSL2", 3)
assert ch.opticalSignalBehaviour == OpticalSignalBehaviour.FLASH_MIDDLE
assert ch.dimLevel == 0.6
assert ch.simpleRGBColorState == RGBColorState.WHITE




@pytest.mark.asyncio
async def test_shading_channel(no_ssl_fake_async_home: AsyncHome):
Expand Down
28 changes: 28 additions & 0 deletions tests/test_functional_channels.py
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,34 @@ def test_notification_light_channel(fake_home: Home):
assert ch.simpleRGBColorState == RGBColorState.BLACK


def test_notification_light_channel_v2(fake_home: Home):
with no_ssl_verification():
ch = fake_home.search_channel("3014F711000000000000BSL2", 3)
assert isinstance(ch, NotificationLightChannel)
assert ch.dimLevel == 0.25
assert ch.simpleRGBColorState == RGBColorState.GREEN
assert ch.opticalSignalBehaviour == OpticalSignalBehaviour.BLINKING_MIDDLE

ch.set_optical_signal(OpticalSignalBehaviour.FLASH_MIDDLE, RGBColorState.BLUE, 0.75)
fake_home.get_current_state()
ch = fake_home.search_channel("3014F711000000000000BSL2", 3)
assert ch.dimLevel == 0.75
assert ch.simpleRGBColorState == RGBColorState.BLUE
assert ch.opticalSignalBehaviour == OpticalSignalBehaviour.FLASH_MIDDLE


def test_notification_light_channel_v2_switch(fake_home: Home):
with no_ssl_verification():
ch = fake_home.search_channel("3014F711000000000000BSL2", 3)
assert isinstance(ch, NotificationLightChannel)
assert ch.on is True

ch.set_switch_state(False)
fake_home.get_current_state()
ch = fake_home.search_channel("3014F711000000000000BSL2", 3)
assert ch.on is False


def test_shading_channel(fake_home: Home):
with no_ssl_verification():
ch = fake_home.search_channel("3014F71100BLIND_MODULE00", 1)
Expand Down

0 comments on commit 1510892

Please sign in to comment.