tschamm/boschshcpy

Bosch SHC version 0.4.38 throws error when changing power switch state of Light II micromodule

basslet opened this issue · 23 comments

Thanks for the latest merge with the support for the new Bosch Micromodules for Light and Shutter.
I'm on Bosch SHC version 0.4.38

A quick test here, and the new micromodules show up correctly and display the correct data (power/energy, current state).

There is an issue when trying to control the micromodule. HA throws this error:

Failed to call service switch/turn_on. SHC Error (message: API call returned non-OK result (code 400)!: b'{"@type":"JsonRestExceptionResponseEntity","errorCode":"INVALID_REQUEST_OBJECT","statusCode":400}')

Log file:
boschshcpy.exceptions.SHCSessionError: SHC Error (message: API call returned non-OK result (code 400)!: b'{"@type":"JsonRestExceptionResponseEntity","errorCode":"INVALID_REQUEST_OBJECT","statusCode":400}')
2023-01-22 01:06:10.785 ERROR (SyncWorker_3) [root] Body: {"@type": "powerSwitchState", "switchState": "OFF"}
2023-01-22 01:06:10.790 ERROR (SyncWorker_3) [root] Headers: {'User-Agent': 'python-requests/2.28.1', 'Accept-Encoding': 'gzip, deflate, br', 'Accept': '/', 'Connection': 'keep-alive', 'api-version': '2.1', 'Content-Type': 'application/json', 'Content-Length': '51'}
2023-01-22 01:06:10.795 ERROR (SyncWorker_3) [root] URL: https://192.168.1.55:8444/smarthome/devices/hdm:ZigBee:dc8e95fffef9577f#2/services/PowerSwitch/state
2023-01-22 01:06:10.801 ERROR (MainThread) [homeassistant.components.websocket_api.http.connection] [548208497312] SHC Error (message: API call returned non-OK result (code 400)!: b'{"@type":"JsonRestExceptionResponseEntity","errorCode":"INVALID_REQUEST_OBJECT","statusCode":400}')
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/components/websocket_api/commands.py", line 200, in handle_call_service
await hass.services.async_call(
File "/usr/src/homeassistant/homeassistant/core.py", line 1755, in async_call
task.result()
File "/usr/src/homeassistant/homeassistant/core.py", line 1792, in _execute_service
await cast(Callable[[ServiceCall], Awaitable[None]], handler.job.target)(
File "/usr/src/homeassistant/homeassistant/helpers/entity_component.py", line 213, in handle_service
await service.entity_service_call(
File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 678, in entity_service_call
future.result() # pop exception if have
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 958, in async_request_call
await coro
File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 715, in _handle_entity_call
await result
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1020, in async_turn_off
await self.hass.async_add_executor_job(ft.partial(self.turn_off, **kwargs))
File "/usr/local/lib/python3.10/concurrent/futures/thread.py", line 58, in run
result = self.fn(*self.args, **self.kwargs)
File "/config/custom_components/bosch_shc/switch.py", line 286, in turn_off
setattr(self._device, self.entity_description.on_key, False)
File "/usr/local/lib/python3.10/site-packages/boschshcpy/models_impl.py", line 201, in state
self._powerswitch_service.put_state_element(
File "/usr/local/lib/python3.10/site-packages/boschshcpy/device_service.py", line 49, in put_state_element
self.put_state({key: value})
File "/usr/local/lib/python3.10/site-packages/boschshcpy/device_service.py", line 44, in put_state
self._api.put_device_service_state(
File "/usr/local/lib/python3.10/site-packages/boschshcpy/api.py", line 170, in put_device_service_state
self._put_api_or_fail(api_url, state_update)
File "/usr/local/lib/python3.10/site-packages/boschshcpy/api.py", line 102, in _put_api_or_fail
self._process_nok_result(result)
File "/usr/local/lib/python3.10/site-packages/boschshcpy/api.py", line 123, in _process_nok_result
raise SHCSessionError(
boschshcpy.exceptions.SHCSessionError: SHC Error (message: API call returned non-OK result (code 400)!: b'{"@type":"JsonRestExceptionResponseEntity","errorCode":"INVALID_REQUEST_OBJECT","statusCode":400}')

When changing the power state of the light II module in the Bosch SH app, it updates correctly in the HA dashboard. Only the control from HA raises this error.

Same result as above from @basslet. Whenever the state changes of the light switch when triggered by Bosch SHC II, the current state, energy, power show up correctly. Triggering the switch to ON, OFF result in the following errors on HA

Power Switch Off

2023-01-22 08:03:58.377 ERROR (SyncWorker_0) [root] Body: {"@type": "powerSwitchState", "switchState": "OFF"}
2023-01-22 08:03:58.379 ERROR (SyncWorker_0) [root] Headers: {'User-Agent': 'python-requests/2.28.1', 'Accept-Encoding': 'gzip, deflate, br', 'Accept': '*/*', 'Connection': 'keep-alive', 'api-version': '2.1', 'Content-Type': 'application/json', 'Content-Length': '51'}
2023-01-22 08:03:58.380 ERROR (SyncWorker_0) [root] URL: https://xxx.xxx.xxx.xxx:8444/smarthome/devices/hdm:ZigBee:f4b3b1fffe0bd5f6#2/services/PowerSwitch/state
2023-01-22 08:03:58.381 ERROR (MainThread) [homeassistant.components.websocket_api.http.connection] [139759655849072] SHC Error (message: API call returned non-OK result (code 400)!: b'{"@type":"JsonRestExceptionResponseEntity","errorCode":"INVALID_REQUEST_OBJECT","statusCode":400}')
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/websocket_api/commands.py", line 200, in handle_call_service
    await hass.services.async_call(
  File "/usr/src/homeassistant/homeassistant/core.py", line 1755, in async_call
    task.result()
  File "/usr/src/homeassistant/homeassistant/core.py", line 1792, in _execute_service
    await cast(Callable[[ServiceCall], Awaitable[None]], handler.job.target)(
  File "/usr/src/homeassistant/homeassistant/helpers/entity_component.py", line 213, in handle_service
    await service.entity_service_call(
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 678, in entity_service_call
    future.result()  # pop exception if have
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 958, in async_request_call
    await coro
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 715, in _handle_entity_call
    await result
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1020, in async_turn_off
    await self.hass.async_add_executor_job(ft.partial(self.turn_off, **kwargs))
  File "/usr/local/lib/python3.10/concurrent/futures/thread.py", line 58, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/config/custom_components/bosch_shc/switch.py", line 286, in turn_off
    setattr(self._device, self.entity_description.on_key, False)
  File "/usr/local/lib/python3.10/site-packages/boschshcpy/models_impl.py", line 201, in state
    self._powerswitch_service.put_state_element(
  File "/usr/local/lib/python3.10/site-packages/boschshcpy/device_service.py", line 49, in put_state_element
    self.put_state({key: value})
  File "/usr/local/lib/python3.10/site-packages/boschshcpy/device_service.py", line 44, in put_state
    self._api.put_device_service_state(
  File "/usr/local/lib/python3.10/site-packages/boschshcpy/api.py", line 170, in put_device_service_state
    self._put_api_or_fail(api_url, state_update)
  File "/usr/local/lib/python3.10/site-packages/boschshcpy/api.py", line 102, in _put_api_or_fail
    self._process_nok_result(result)
  File "/usr/local/lib/python3.10/site-packages/boschshcpy/api.py", line 123, in _process_nok_result
    raise SHCSessionError(
boschshcpy.exceptions.SHCSessionError: SHC Error (message: API call returned non-OK result (code 400)!: b'{"@type":"JsonRestExceptionResponseEntity","errorCode":"INVALID_REQUEST_OBJECT","statusCode":400}')

Power Switch On

2023-01-22 08:03:54.177 ERROR (SyncWorker_5) [root] Body: {"@type": "powerSwitchState", "switchState": "ON"}
2023-01-22 08:03:54.178 ERROR (SyncWorker_5) [root] Headers: {'User-Agent': 'python-requests/2.28.1', 'Accept-Encoding': 'gzip, deflate, br', 'Accept': '*/*', 'Connection': 'keep-alive', 'api-version': '2.1', 'Content-Type': 'application/json', 'Content-Length': '50'}
2023-01-22 08:03:54.180 ERROR (SyncWorker_5) [root] URL: https://xxx.xxx.xxx.xxx:8444/smarthome/devices/hdm:ZigBee:f4b3b1fffe0bd5f6#2/services/PowerSwitch/state
2023-01-22 08:03:54.182 ERROR (MainThread) [homeassistant.components.websocket_api.http.connection] [139759655849072] SHC Error (message: API call returned non-OK result (code 400)!: b'{"@type":"JsonRestExceptionResponseEntity","errorCode":"INVALID_REQUEST_OBJECT","statusCode":400}')
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/websocket_api/commands.py", line 200, in handle_call_service
    await hass.services.async_call(
  File "/usr/src/homeassistant/homeassistant/core.py", line 1755, in async_call
    task.result()
  File "/usr/src/homeassistant/homeassistant/core.py", line 1792, in _execute_service
    await cast(Callable[[ServiceCall], Awaitable[None]], handler.job.target)(
  File "/usr/src/homeassistant/homeassistant/helpers/entity_component.py", line 213, in handle_service
    await service.entity_service_call(
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 678, in entity_service_call
    future.result()  # pop exception if have
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 958, in async_request_call
    await coro
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 715, in _handle_entity_call
    await result
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1012, in async_turn_on
    await self.hass.async_add_executor_job(ft.partial(self.turn_on, **kwargs))
  File "/usr/local/lib/python3.10/concurrent/futures/thread.py", line 58, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/config/custom_components/bosch_shc/switch.py", line 282, in turn_on
    setattr(self._device, self.entity_description.on_key, True)
  File "/usr/local/lib/python3.10/site-packages/boschshcpy/models_impl.py", line 201, in state
    self._powerswitch_service.put_state_element(
  File "/usr/local/lib/python3.10/site-packages/boschshcpy/device_service.py", line 49, in put_state_element
    self.put_state({key: value})
  File "/usr/local/lib/python3.10/site-packages/boschshcpy/device_service.py", line 44, in put_state
    self._api.put_device_service_state(
  File "/usr/local/lib/python3.10/site-packages/boschshcpy/api.py", line 170, in put_device_service_state
    self._put_api_or_fail(api_url, state_update)
  File "/usr/local/lib/python3.10/site-packages/boschshcpy/api.py", line 102, in _put_api_or_fail
    self._process_nok_result(result)
  File "/usr/local/lib/python3.10/site-packages/boschshcpy/api.py", line 123, in _process_nok_result
    raise SHCSessionError(
boschshcpy.exceptions.SHCSessionError: SHC Error (message: API call returned non-OK result (code 400)!: b'{"@type":"JsonRestExceptionResponseEntity","errorCode":"INVALID_REQUEST_OBJECT","statusCode":400}')

Now there is also a -PresenceSimulationService-

Maybe also interesting, but I am not sure its related to the integration

2023-01-22 08:02:42.838 ERROR (MainThread) [homeassistant.components.switch] Platform bosch_shc does not generate unique IDs. ID F4B3B1FFFE0BD5F6 already exists - ignoring switch.buro_led
2023-01-22 08:03:05.331 ERROR (MainThread) [homeassistant.components.switch] Platform bosch_shc does not generate unique IDs. ID F4B3B1FFFE0BD5F6 already exists - ignoring switch.buro_led

@melianor this is not related. The serial provided by MICROMODULE_LIGHT_ATTACHED for light 1 and light 2 are identical. I will see how to fix that.

Thanks for reporting. As I do not have a controller configured as light control currently, I cannot test the correct behavior. I need your help here: What is the state of the PowerSwitchService, when set to ON and OFF, reported in Postman? I assume the behavior is different from the BSM light switch.

@tschamm , I looked for PowerSwitchService, but only found powerSwitchState when looking for one of the Shutter/Light Control II units that I have installed. I added the output from

  • /services
  • /devices/{{deviceId}}
  • /devices/{{deviceId}}/services

I hope that helps :)

Excerpt from {{shc_api}}/services for both(!) possible switches/lights controlled with the Shutter/Light Control II unit

     {
        "@type": "DeviceServiceData",
        "id": "PowerSwitch",
        "deviceId": "hdm:ZigBee:f4b3b1fffe0bd5f6#2",
        "state": {
            "@type": "powerSwitchState",
            "switchState": "ON",
            "automaticPowerOffTime": 0
        },
        "path": "/devices/hdm:ZigBee:f4b3b1fffe0bd5f6#2/services/PowerSwitch"
    },
    {
        "@type": "DeviceServiceData",
        "id": "ChildProtection",
        "deviceId": "hdm:ZigBee:f4b3b1fffe0bd5f6#2",
        "state": {
            "@type": "ChildProtectionState",
            "childLockActive": false
        },
        "path": "/devices/hdm:ZigBee:f4b3b1fffe0bd5f6#2/services/ChildProtection"
    },
    {
        "@type": "DeviceServiceData",
        "id": "PowerSwitchProgram",
        "deviceId": "hdm:ZigBee:f4b3b1fffe0bd5f6#2",
        "state": {
            "@type": "powerSwitchProgramState",
            "operationMode": "MANUAL",
            "schedule": {
                "profiles": []
            }
        },
        "path": "/devices/hdm:ZigBee:f4b3b1fffe0bd5f6#2/services/PowerSwitchProgram"
    },
...
{
        "@type": "DeviceServiceData",
        "id": "PowerSwitch",
        "deviceId": "hdm:ZigBee:f4b3b1fffe0bd5f6#3",
        "state": {
            "@type": "powerSwitchState",
            "switchState": "ON",
            "automaticPowerOffTime": 0
        },
        "path": "/devices/hdm:ZigBee:f4b3b1fffe0bd5f6#3/services/PowerSwitch"
    },
    {
        "@type": "DeviceServiceData",
        "id": "ChildProtection",
        "deviceId": "hdm:ZigBee:f4b3b1fffe0bd5f6#3",
        "state": {
            "@type": "ChildProtectionState",
            "childLockActive": false
        },
        "path": "/devices/hdm:ZigBee:f4b3b1fffe0bd5f6#3/services/ChildProtection"
    },
    {
        "@type": "DeviceServiceData",
        "id": "PowerSwitchProgram",
        "deviceId": "hdm:ZigBee:f4b3b1fffe0bd5f6#3",
        "state": {
            "@type": "powerSwitchProgramState",
            "operationMode": "MANUAL",
            "schedule": {
                "profiles": []
            }
        },
        "path": "/devices/hdm:ZigBee:f4b3b1fffe0bd5f6#3/services/PowerSwitchProgram"
    },

Here is also the output for the Shutter/Light Control II unit itself

{
        "@type": "DeviceServiceData",
        "id": "CommunicationQuality",
        "deviceId": "hdm:ZigBee:f4b3b1fffe0bd5f6",
        "state": {
            "@type": "communicationQualityState",
            "quality": "UNKNOWN"
        },
        "path": "/devices/hdm:ZigBee:f4b3b1fffe0bd5f6/services/CommunicationQuality"
    },
    {
        "@type": "DeviceServiceData",
        "id": "ElectricalFaults",
        "deviceId": "hdm:ZigBee:f4b3b1fffe0bd5f6",
        "path": "/devices/hdm:ZigBee:f4b3b1fffe0bd5f6/services/ElectricalFaults"
    },
    {
        "@type": "DeviceServiceData",
        "id": "SwitchConfiguration",
        "deviceId": "hdm:ZigBee:f4b3b1fffe0bd5f6",
        "state": {
            "@type": "SwitchConfigurationState",
            "switchType": "SWITCH",
            "swapInputs": false
        },
        "path": "/devices/hdm:ZigBee:f4b3b1fffe0bd5f6/services/SwitchConfiguration"
    }

Device by id {{shc_api}}/devices/hdm:ZigBee:f4b3b1fffe0bd5f6

{
    "@type": "device",
    "rootDeviceId": "64-da-a0-40-0e-d9",
    "id": "hdm:ZigBee:f4b3b1fffe0bd5f6",
    "deviceServiceIds": [
        "PowerMeter",
        "CommunicationQuality",
        "ElectricalFaults",
        "SwitchConfiguration"
    ],
    "manufacturer": "BOSCH",
    "deviceModel": "MICROMODULE_LIGHT_CONTROL",
    "serial": "F4B3B1FFFE0BD5F6",
    "profile": "GENERIC",
    "name": "Light/shutter control II *",
    "status": "AVAILABLE",
    "childDeviceIds": [
        "hdm:ZigBee:f4b3b1fffe0bd5f6#2",
        "hdm:ZigBee:f4b3b1fffe0bd5f6#3"
    ]
}

Services of the device {{shc_api}}/devices/hdm:ZigBee:f4b3b1fffe0bd5f6/services

[
    {
        "@type": "DeviceServiceData",
        "id": "PowerMeter",
        "deviceId": "hdm:ZigBee:f4b3b1fffe0bd5f6",
        "state": {
            "@type": "powerMeterState",
            "powerConsumption": 41.0,
            "energyConsumption": 3780.0
        },
        "path": "/devices/hdm:ZigBee:f4b3b1fffe0bd5f6/services/PowerMeter"
    },
    {
        "@type": "DeviceServiceData",
        "id": "CommunicationQuality",
        "deviceId": "hdm:ZigBee:f4b3b1fffe0bd5f6",
        "state": {
            "@type": "communicationQualityState",
            "quality": "UNKNOWN"
        },
        "path": "/devices/hdm:ZigBee:f4b3b1fffe0bd5f6/services/CommunicationQuality"
    },
    {
        "@type": "DeviceServiceData",
        "id": "ElectricalFaults",
        "deviceId": "hdm:ZigBee:f4b3b1fffe0bd5f6",
        "path": "/devices/hdm:ZigBee:f4b3b1fffe0bd5f6/services/ElectricalFaults"
    },
    {
        "@type": "DeviceServiceData",
        "id": "SwitchConfiguration",
        "deviceId": "hdm:ZigBee:f4b3b1fffe0bd5f6",
        "state": {
            "@type": "SwitchConfigurationState",
            "switchType": "SWITCH",
            "swapInputs": false
        },
        "path": "/devices/hdm:ZigBee:f4b3b1fffe0bd5f6/services/SwitchConfiguration"
    }
]

Thank you, exactly what I was looking for!
Still I wonder, powerSwitchState is exactly the same for the BSM and the Micromodule controller. I will dig deeper on the semantics of the error message INVALID_REQUEST_OBJECT.

Bosch team released a postman collection for API v3.2 last month. In the States section, you can send a REST PUT command for PowerSwitch ON and OFF. Can you test if you obtain the same error response also there?

Hi @tschamm , looks like the API on the Smart Home Controller II is broken for those devices? That's the same error that HA got...
Noooo, I don't want to wait for a firmware update.
Looks like this is too much bleeding edge with those new devices and controller :)

To one of the lights on the control unit
{{shc_api}}/devices/hdm:ZigBee:f4b3b1fffe0bd5f6#3/services/PowerSwitch/state

{
    "@type": "powerSwitchState",
    "switchState": "ON"
}
{
    "@type": "JsonRestExceptionResponseEntity",
    "errorCode": "INVALID_REQUEST_OBJECT",
    "statusCode": 400
}
{
    "@type": "powerSwitchState",
    "switchState": "OFF"
}
{
    "@type": "JsonRestExceptionResponseEntity",
    "errorCode": "INVALID_REQUEST_OBJECT",
    "statusCode": 400
}

State of the powerswitch

{{shc_api}}/devices/hdm:ZigBee:f4b3b1fffe0bd5f6#3/services/PowerSwitch/state
{
    "@type": "device",
    "rootDeviceId": "xx-xx-xx-xx-xx-x",
    "id": "hdm:ZigBee:f4b3b1fffe0bd5f6",
    "deviceServiceIds": [
        "PowerMeter",
        "CommunicationQuality",
        "ElectricalFaults",
        "SwitchConfiguration"
    ],
    "manufacturer": "BOSCH",
    "deviceModel": "MICROMODULE_LIGHT_CONTROL",
    "serial": "F4B3B1FFFE0BD5F6",
    "profile": "GENERIC",
    "name": "Light/shutter control II *",
    "status": "AVAILABLE",
    "childDeviceIds": [
        "hdm:ZigBee:f4b3b1fffe0bd5f6#2",
        "hdm:ZigBee:f4b3b1fffe0bd5f6#3"
    ]
}

Is the "#" in the device ID in the URL correctly escaped as mentioned in the CHANGELOG?

Instead of "/devices/hdm:ZigBee:ff01000000000901#2/services/PowerSwitch", the URL must look like this: "/devices/hdm:ZigBee:ff01000000000901%232/services/PowerSwitch".

I just checked with Postman that the SHC replies exactly like it was mentioned with 400 INVALID_REQUEST_OBJECT in case the "#" is not escaped.

Is the "#" in the device ID in the URL correctly escaped as mentioned in the CHANGELOG?

Instead of "/devices/hdm:ZigBee:ff01000000000901#2/services/PowerSwitch", the URL must look like this: "/devices/hdm:ZigBee:ff01000000000901%232/services/PowerSwitch".

I just checked with Postman that the SHC replies exactly like it was mentioned with 400 INVALID_REQUEST_OBJECT in case the "#" is not escaped.

Oh, I'll try that when I am back home. I don't think postman did any escaping by itself.
Thanks for the hint @sebastianharder and for watching this repo in official capacity ;)
@tschamm , would that be something that you can correct?

@tschamm ,
Sending # escaped as %23
{{shc_api}}/devices/hdm:ZigBee:f4b3b1fffe0bd5f6%233/services/PowerSwitch/state
instead of
{{shc_api}}/devices/hdm:ZigBee:f4b3b1fffe0bd5f6#3/services/PowerSwitch/state

works for my turning on and off of the light control units, just like @sebastianharder wrote today.
Looking forward to a new version to test!

Cheers, Mel

Fixed by 4c90d03.

I compiled a pre-release 0.4.40, which contains the fix to the Light II PowerSwitch. Please report back if the error persists.

I compiled a pre-release 0.4.40, which contains the fix to the Light II PowerSwitch. Please report back if the error persists.

How can I get this pre-release version? I don't see an update on HACS in Home Assitant.
Thx, Mel

I compiled a pre-release 0.4.40, which contains the fix to the Light II PowerSwitch. Please report back if the error persists.

How can I get this pre-release version? I don't see an update on HACS in Home Assitant. Thx, Mel

Found it.

I installed 0.4.40, restarted HA and then reloaded the Bosch SHC integration.

Turning the light on/off for a shutter/light control II device now works.
But I only see one of the lights that is connected to the control unit. The 2nd is missing in HA.
See the device #2 is visible, #3 is not.

Shutter/Light Controll II

{
    "@type": "device",
    "rootDeviceId": "64-da-a0-40-0e-d9",
    "id": "hdm:ZigBee:f4b3b1fffe0bd5f6",
    "deviceServiceIds": [
        "PowerMeter",
        "CommunicationQuality",
        "ElectricalFaults",
        "SwitchConfiguration"
    ],
    "manufacturer": "BOSCH",
    "deviceModel": "MICROMODULE_LIGHT_CONTROL",
    "serial": "F4B3B1FFFE0BD5F6",
    "profile": "GENERIC",
    "name": "Light/shutter control II *",
    "status": "AVAILABLE",
    "childDeviceIds": [
        "hdm:ZigBee:f4b3b1fffe0bd5f6#2",
        "hdm:ZigBee:f4b3b1fffe0bd5f6#3"
    ]
}

Connected lights as child devices

{
        "@type": "DeviceServiceData",
        "id": "PowerSwitch",
        "deviceId": "hdm:ZigBee:f4b3b1fffe0bd5f6#2",
        "state": {
            "@type": "powerSwitchState",
            "switchState": "ON",
            "automaticPowerOffTime": 0
        },
        "path": "/devices/hdm:ZigBee:f4b3b1fffe0bd5f6#2/services/PowerSwitch"
    },
    {
        "@type": "DeviceServiceData",
        "id": "ChildProtection",
        "deviceId": "hdm:ZigBee:f4b3b1fffe0bd5f6#2",
        "state": {
            "@type": "ChildProtectionState",
            "childLockActive": false
        },
        "path": "/devices/hdm:ZigBee:f4b3b1fffe0bd5f6#2/services/ChildProtection"
    },
    {
        "@type": "DeviceServiceData",
        "id": "PowerSwitchProgram",
        "deviceId": "hdm:ZigBee:f4b3b1fffe0bd5f6#2",
        "state": {
            "@type": "powerSwitchProgramState",
            "operationMode": "MANUAL",
            "schedule": {
                "profiles": []
            }
        },
        "path": "/devices/hdm:ZigBee:f4b3b1fffe0bd5f6#2/services/PowerSwitchProgram"
    },
...
{
        "@type": "DeviceServiceData",
        "id": "PowerSwitch",
        "deviceId": "hdm:ZigBee:f4b3b1fffe0bd5f6#3",
        "state": {
            "@type": "powerSwitchState",
            "switchState": "ON",
            "automaticPowerOffTime": 0
        },
        "path": "/devices/hdm:ZigBee:f4b3b1fffe0bd5f6#3/services/PowerSwitch"
    },
    {
        "@type": "DeviceServiceData",
        "id": "ChildProtection",
        "deviceId": "hdm:ZigBee:f4b3b1fffe0bd5f6#3",
        "state": {
            "@type": "ChildProtectionState",
            "childLockActive": false
        },
        "path": "/devices/hdm:ZigBee:f4b3b1fffe0bd5f6#3/services/ChildProtection"
    },
    {
        "@type": "DeviceServiceData",
        "id": "PowerSwitchProgram",
        "deviceId": "hdm:ZigBee:f4b3b1fffe0bd5f6#3",
        "state": {
            "@type": "powerSwitchProgramState",
            "operationMode": "MANUAL",
            "schedule": {
                "profiles": []
            }
        },
        "path": "/devices/hdm:ZigBee:f4b3b1fffe0bd5f6#3/services/PowerSwitchProgram"
    },

I can confirm, the serial is the same for both attached lights, so the device is only created once.

Hi @melianor
I changed the policy how unique_ids are provided, which should fix your issue. You can test it via this branch https://github.com/tschamm/boschshc-hass/tree/update_unique_ids
The branch will rewrite all enties' unique ids. So maybe take a backup of your <ha-config>/.storage/core.entity_registry before testing.

@tschamm , So to test this, I

  • backup /.storage/core.entity_registry to keep the current entity ids
  • backup [ha-directory]/customer_components/bosch_shc/
  • replace [ha-directory]/customer_components/bosch_shc/ with the content from the branch https://github.com/tschamm/boschshc-hass/tree/update_unique_ids
  • Then reload the custom component to retrieve all the devices

Afterwards I just rollback my backups and should be fine.

Any additional thoughts?
Cheers, mel

Correct.

Hi @tschamm , I will get around to test this around the end of the week.
Does rewriting the device ids have an impact on the existing automations or scenes.
At least the way I understood this, the device ids would all change on HA side. Is that correct?

I published a release already which contains the rewriting of the unique ids. So no need to do a backup and specific test anymore.

The device ids are auto-created and will not change, only the unique ids will change. So no change of automations etc. is needed.

Oh great :)
I see both devices now that are controlled by the one light control II unit
Great update with all the other changes.
Thanks, mel