Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[boschshc] Support for Light/Shutter Control II #14562

Closed
mike-bike opened this issue Mar 9, 2023 · 28 comments · Fixed by #16400
Closed

[boschshc] Support for Light/Shutter Control II #14562

mike-bike opened this issue Mar 9, 2023 · 28 comments · Fixed by #16400
Assignees
Labels
enhancement An enhancement or new feature for an existing add-on

Comments

@mike-bike
Copy link

Hi,

I just purchased 2 Bosch Light/Shutter Control II devices (https://www.bosch-smarthome.com/uk/en/products/devices/light-control/). Based on configuration they behave like a shutter control or 2 wall switches. I have tried to add them as switches to OpenHAB but unfortunately they don't work. Neither switch states nor power consumption are recognized. Looking at the log, they are reporting different services than switches:

Found device: name=Brunnen id=hdm:ZigBee:xyz
.... service: PowerSwitch
.... service: ChildProtection
.... service: PowerSwitchProgram

Are there any concrete plans enhancing the functionality of the binding?

Many thanks for your great effort and support.

Regards,
Michael

Your Environment

openhabian on RPi4, HUE, Bosch Smart Home Controller

@mike-bike mike-bike added the enhancement An enhancement or new feature for an existing add-on label Mar 9, 2023
@openhab-bot
Copy link
Collaborator

This issue has been mentioned on openHAB Community. There might be relevant details there:

https://community.openhab.org/t/problem-connection-bosch-smarthome-light-shutter-control-unit-ii/146281/2

@david-pace david-pace changed the title [boschshc] Support for new Shutter/Switch II [boschshc] Support for new Shutter/Light Control II Nov 26, 2023
@david-pace
Copy link
Member

david-pace commented Jan 7, 2024

This was also requested by @wwinandy in #16203.

I can implement support for the Light/Shutter Control II, but as I don't own this specific device myself I would need your help to test it. This would involve downloading JARs, installing JARs via the openHAB console, and testing the new thing and its channels. This can potentially make the binding unusable temporarily, but everything should be revertable to the original state. A backup would be in order anyway just in case. @mike-bike already offered to help us testing, which is great ❤️

If you guys need support for other devices, please create separate Github enhancement requests for each device. Thank you 👍

@david-pace david-pace changed the title [boschshc] Support for new Shutter/Light Control II [boschshc] Support for new Light/Shutter Control II Jan 7, 2024
@david-pace david-pace changed the title [boschshc] Support for new Light/Shutter Control II [boschshc] Support for Light/Shutter Control II Jan 7, 2024
@mike-bike
Copy link
Author

mike-bike commented Jan 8, 2024

Hi @david-pace, let me know where to download a test version of the JAR and I am happy to test. I could offer:

  • Door Contact II (installed) - dev in progress
  • Light/Shutter Control II configured as double Light Switch (installed)
  • Light/Shutter Control II configured as Roller Shutter (need to grab screw driver to install device)
  • Dimmer (sitting in the box waiting for screw driver) - request #16241 raised

Cheers

@mike-bike
Copy link
Author

Hi @david-pace, let me know where to download a test version of the JAR and I am happy to test. I could offer:

  • Door Contact II (installed)
  • Light/Shutter Control II configured as double Light Switch (installed)
  • Light/Shutter Control II configured as Roller Shutter (need to grab screw driver to install device)
  • Dimmer (sitting in the box waiting for screw driver)

Cheers

1 similar comment
@mike-bike
Copy link
Author

Hi @david-pace, let me know where to download a test version of the JAR and I am happy to test. I could offer:

  • Door Contact II (installed)
  • Light/Shutter Control II configured as double Light Switch (installed)
  • Light/Shutter Control II configured as Roller Shutter (need to grab screw driver to install device)
  • Dimmer (sitting in the box waiting for screw driver)

Cheers

@wwinandy
Copy link

wwinandy commented Jan 8, 2024

Hi @david-pace, where can i get the test JARs for testing?
Is there any instruction for installing the JARs?

I also use a smoke alarm II - request ( #16243)
and a Universal Switch II - request (#16244)

Regards

@david-pace
Copy link
Member

Hi, I first have to implement the necessary services and devices before I can provide JARs. Once I have a first version I will also provide instructions how to install the JARs. I hope I will find some free time soon and that it won't be too long but I can't promise anything.

Thank you in advance for volunteering to help with the testing, this already motivates me to start coding because without your help this would not be possible 👍

@david-pace david-pace self-assigned this Jan 12, 2024
@david-pace
Copy link
Member

Hi @mike-bike, I need some information regarding the device IDs. The Light/Shutter Control II works with so called child devices. I think there should be one main device and two child devices. The child device IDs should contain # or %23.

Could you please check whether you see the main device and the child device IDs in the listing when openHAB is started? If so, can you please post them here or send them via email? I need the main device ID, both child device IDs and the associated services. Thank you 🙂

@mike-bike
Copy link
Author

mike-bike commented Jan 13, 2024 via email

@mike-bike
Copy link
Author

mike-bike commented Jan 13, 2024

Some long poll responses from the version II devices. Might help identifying the appropriate channels.

Response from Shutter Control II

2024-01-13 19:58:23.696 [DEBUG] [.internal.devices.bridge.LongPolling] - Long poll response: {"result":[{"path":"/devices/hdm:ZigBee:b43a31fffeffae5d/services/PowerMeter","@type":"DeviceServiceData","id":"PowerMeter","state":{"energyConsumption":0,"powerConsumption":93,"@type":"powerMeterState"},"deviceId":"hdm:ZigBee:b43a31fffeffae5d"}],"jsonrpc":"2.0"}
2024-01-13 19:58:23.904 [DEBUG] [.internal.devices.bridge.LongPolling] - Long poll response: {"result":[{"path":"/devices/hdm:ZigBee:b43a31fffeffae5d/services/ShutterControl","operations":["decrementOpenLevel","incrementOpenLevel"],"@type":"DeviceServiceData","id":"ShutterControl","state":{"delayCompensationTime":0.2,"referenceMovingTimes":{"movingTimeBottomToTopInMillis":17800,"movingTimeTopToBottomInMillis":17000},"endPositionAutoDetect":true,"delayCompensationSupported":true,"level":0.61,"@type":"shutterControlState","operationState":"STOPPED","endPositionSupported":true,"automaticDelayCompensation":true,"calibrated":true},"deviceId":"hdm:ZigBee:b43a31fffeffae5d"}],"jsonrpc":"2.0"}
2024-01-13 19:58:24.044 [DEBUG] [.internal.devices.bridge.LongPolling] - Long poll response: {"result":[{"path":"/devices/hdm:ZigBee:b43a31fffeffae5d/services/ShutterControl","operations":["decrementOpenLevel","incrementOpenLevel"],"@type":"DeviceServiceData","id":"ShutterControl","state":{"delayCompensationTime":0.2,"referenceMovingTimes":{"movingTimeBottomToTopInMillis":17800,"movingTimeTopToBottomInMillis":17000},"endPositionAutoDetect":true,"delayCompensationSupported":true,"level":0.61,"@type":"shutterControlState","operationState":"MOVING","endPositionSupported":true,"automaticDelayCompensation":true,"calibrated":true},"deviceId":"hdm:ZigBee:b43a31fffeffae5d"}],"jsonrpc":"2.0"}

Response from Dimmer

2024-01-13 20:00:39.104 [DEBUG] [.internal.devices.bridge.LongPolling] - Long poll response: {"result":[{"path":"/devices/hdm:ZigBee:60b647fffe14a1e1/services/MultiLevelSwitch","@type":"DeviceServiceData","id":"MultiLevelSwitch","state":{"level":50,"@type":"multiLevelSwitchState"},"deviceId":"hdm:ZigBee:60b647fffe14a1e1"}],"jsonrpc":"2.0"}
2024-01-13 20:00:51.514 [DEBUG] [.internal.devices.bridge.LongPolling] - Long poll response: {"result":[{"path":"/devices/hdm:ZigBee:60b647fffe14a1e1/services/MultiLevelSwitch","@type":"DeviceServiceData","id":"MultiLevelSwitch","state":{"level":30,"@type":"multiLevelSwitchState"},"deviceId":"hdm:ZigBee:60b647fffe14a1e1"}],"jsonrpc":"2.0"}
2024-01-13 20:01:50.724 [DEBUG] [.internal.devices.bridge.LongPolling] - Long poll response: {"result":[{"path":"/devices/hdm:ZigBee:60b647fffe14a1e1/services/PowerSwitch","@type":"DeviceServiceData","id":"PowerSwitch","state":{"@type":"powerSwitchState","automaticPowerOffTime":0,"switchState":"OFF"},"deviceId":"hdm:ZigBee:60b647fffe14a1e1"}],"jsonrpc":"2.0"}

Response from Light Control II

2024-01-13 20:03:12.414 [DEBUG] [.internal.devices.bridge.LongPolling] - Long poll response: {"result":[{"path":"/devices/hdm:ZigBee:70ac08fffefead2d#2/services/PowerSwitch","@type":"DeviceServiceData","id":"PowerSwitch","state":{"@type":"powerSwitchState","automaticPowerOffTime":0,"switchState":"OFF"},"deviceId":"hdm:ZigBee:70ac08fffefead2d#2"}],"jsonrpc":"2.0"}
2024-01-13 20:03:14.084 [DEBUG] [.internal.devices.bridge.LongPolling] - Long poll response: {"result":[{"path":"/devices/hdm:ZigBee:70ac08fffefead2d/services/PowerMeter","@type":"DeviceServiceData","id":"PowerMeter","state":{"energyConsumption":18600,"powerConsumption":0,"@type":"powerMeterState"},"deviceId":"hdm:ZigBee:70ac08fffefead2d"}],"jsonrpc":"2.0"}

@david-pace
Copy link
Member

david-pace commented Jan 31, 2024

Hi @mike-bike and @wwinandy,

I implemented support for Shutter Control II and uploaded a JAR that you can use for testing 👍 Note that this does not support Light Control II yet.

Here are step by step instructions how you can test:

  • if you have a dedicated second openHAB system just for testing it would be optimal just to be sure your productive system is not affected during testing
  • please make a backup of your system to be safe (I don't expect that exchanging the JAR can destroy the system but just in case...)
  • start an openHAB console with openhab-cli console
  • find out the bundle ID of the boschshc binding: la -s | grep boschshc
  • replace the JAR with bundle:update [bundle ID from previous step] /path/to/JAR.jar (sometimes openHAB needs to be restarted)
  • check if the discovery works
  • add a corresponding thing
  • add items to all channels
  • change states on the device and check if all channels are updated correctly
  • when you're finished with testing, delete & unlink all created items and delete the thing you created (in case there are updates/enhancements later, they would become incompatible)
  • finally, replace the bundle JAR with the original JAR of your release. JARs for all releases can be found here

Let me know if anything does not work. Once Shutter Control II works, I will continue with support for Light Control II.

@david-pace
Copy link
Member

I just fixed two issues:

  • child protection state was not settable
  • device was not registered properly in the factory

If you have already downloaded the JAR, please download again.

@mike-bike
Copy link
Author

mike-bike commented Jan 31, 2024 via email

@david-pace
Copy link
Member

I suppose it does not work because in the mean time there were some changes in the openHAB core discovery framework, so my JAR only works with the latest state.

Since you have a dedicated test system you could switch to the latest SNAPSHOT state by using the following apt repository:

deb https://openhab.jfrog.io/artifactory/openhab-linuxpkg unstable main

For milestone releases, you can use testing instead of unstable. See also https://community.openhab.org/t/guide-installing-and-testing-oh3-snapshots-milestones-using-apt-and-yum/104572

Once you have the latest snapshot version of openHAB, my JAR should be compatible.

@mike-bike
Copy link
Author

mike-bike commented Feb 2, 2024 via email

@david-pace
Copy link
Member

Wow this is great news 😎 I wouldn't have thought that everything works directly in the first test iteration 😉

About the signal strength mapping: interestingly the exact same question was asked in #16357 (comment). We use an openHAB system channel and translate the Bosch-specific communication quality to an openHAB-specific signal strength as discussed here: #16093 (comment)

The mapping is:

  • UNKNOWN -> 0
  • BAD -> 1
  • MEDIUM -> 2
  • NORMAL -> 3
  • GOOD -> 4

As you can see, GOOD is the best Bosch communication quality, so it is translated to the best openHAB signal strength 4 which is "excellent". In my opinion this is the best mapping but if you have a better idea feel free to propose a different mapping.

@mike-bike
Copy link
Author

mike-bike commented Feb 3, 2024 via email

@david-pace
Copy link
Member

Hi @mike-bike, I just implemented a first version that also supports the light switch configuration. Please download the JAR again from the same location I already provided.

The implementation for the light switches is a bit more complex because we see a parent device and two child devices for the two light switch circuits. I modeled it the same way in openHAB - one thing type for the parent device and another thing type for the light switch circuits.

Please test if this works in the first place. Then we can discuss whether we should stay with this model or change it. I thought about representing it only as one device in openHAB which would be more user-friendly, but this has significant drawbacks regarding the channel names and scalability for possible future Bosch devices that might have logical child devices. But we can discuss this later. Now let's first see whether it even works with the different thing types ;)

@mike-bike
Copy link
Author

mike-bike commented Feb 11, 2024 via email

@david-pace
Copy link
Member

david-pace commented Feb 12, 2024

Thanks for the report 👍 There is an issue because the child devices contain hash characters in their IDs (for example the second to last character in hdm_ZigBee_70ac08fffefead2d#3). This is translated 1:1 into a thing ID in which this character is not allowed. I have an idea for a fix that I will provide soon.

@david-pace
Copy link
Member

I uploaded a new JAR, please test again 👍

@mike-bike
Copy link
Author

Hi @david-pace, I have loaded the new JAR and done some quick tests:

  1. Device has been quickly discovered and the light-switch things placed in Inbox
  2. Things instantiated and items created
  3. Switch changes in Bosch App are immediately reflected in corresponding openHAB item state
  4. Switch (On/Off) in OpenHAB does not trigger any change to the device itself. Item state in openHAB flips On/Off but does not actually switch the device.

We are getting closer...

@mike-bike
Copy link
Author

mike-bike commented Feb 12, 2024

Quick follow up - I missed to create the "base device" with power consumption and signal strength

  1. Power consumption (W) and Energy (W/h) is showing same values as Bosch App
  2. I have tricked Bosch App to perform another signal test (by changing to Roller Shutter mode)--> Item state shows correct value

In short: Things/Items picks up correct status but cannot control the device from OpenHAB

Re multiple things: I personally would find 1 thing with two sets of channels for the switch and child-protection more intuitive. It is one physical devices with a power meter and two switches. They cannot be separated. Implementing them as 3 things does not make logical sense to me.
However, implementation model challenges or technical design thinking may lead to a different opinion.
I have placed all items of all 3 things into the same equipment in the model keeping them together. That works for me.

@david-pace
Copy link
Member

david-pace commented Feb 12, 2024

Thanks for testing the current development state @mike-bike 👍

Could you please check your logs and look for:

  • any errors that relate to an unsuccessful HTTP PUT request
  • look for a log entry that looks like create request for {some URL} and content {some JSON code}. The URL has to contain one of the child device IDs in the middle. This entry can only be seen on TRACE level.

I have an idea what could be the problem. The child device ID in the URL has to be escaped and I suspect that this does not happen correctly.

Example: https://host:port/devices/hdm:ZigBee:70ac08fffe5294ea#3/services/PowerSwitch/state
Here the hash tag before 3 would have to be escaped using %23.

@david-pace
Copy link
Member

I just uploaded a new JAR that addresses the URL escaping issue. Please try again 🙂

@mike-bike
Copy link
Author

While I was composing my response to your second last note, you came up with an update to the JAR...

2024-02-12 16:02:10.509 [TRACE] [ernal.devices.bridge.BoschHttpClient] - Create request for http client BoschHttpClient@4be2b7{STARTED}
2024-02-12 16:02:10.512 [TRACE] [ernal.devices.bridge.BoschHttpClient] - create request for https://192.168.2.61:8444/smarthome/devices/hdm:ZigBee:70ac08fffefead2d%232/services/PowerSwitch/state and content {"switchState":"ON","stateType":"powerSwitchState","@type ":"powerSwitchState"}

Escaping # has resolved the issue. Switching in openHAB now triggers the device.

@mike-bike
Copy link
Author

Hi @david-pace, I have checked on/off and child-protection switches and all seem to be working fine. As I do not have any physical switches attached to the device, I am relying on corresponding status changes in the Bosch app. Though I'd expect the physics will work as expected if the app shows the changes.

It works like a charm - well done! Many thanks!

@david-pace
Copy link
Member

Nice 😎

I will provide a PR soon, in which we can also discuss the thing/channel model 👍

david-pace added a commit to david-pace/openhab-addons that referenced this issue Feb 12, 2024
* add thing type for Shutter Control II
* add new channel type for child protection
* add child protection service and state
* implement handler for Shutter Control II
* register device in factory
* register device in discovery
* add unit test
* add README section

Signed-off-by: David Pace <dev@davidpace.de>
@david-pace david-pace linked a pull request Feb 13, 2024 that will close this issue
@david-pace david-pace added the PR pending There is a pull request for resolving the issue label Feb 13, 2024
david-pace added a commit to david-pace/openhab-addons that referenced this issue Feb 27, 2024
* add thing type for Shutter Control II
* add new channel type for child protection
* add child protection service and state
* implement handler for Shutter Control II
* register device in factory
* register device in discovery
* add unit test
* add README section

Signed-off-by: David Pace <dev@davidpace.de>
lsiepel pushed a commit that referenced this issue Mar 31, 2024
* [boschshc] Add support for Shutter Control II (#14562)
* add new channel type for child protection

Signed-off-by: David Pace <dev@davidpace.de>
@david-pace david-pace removed the PR pending There is a pull request for resolving the issue label Apr 1, 2024
lo92fr pushed a commit to lo92fr/openhab-addons that referenced this issue Apr 30, 2024
* [boschshc] Add support for Shutter Control II (openhab#14562)
* add new channel type for child protection

Signed-off-by: David Pace <dev@davidpace.de>
adr001db pushed a commit to adr001db/openhab-addons that referenced this issue May 12, 2024
* [boschshc] Add support for Shutter Control II (openhab#14562)
* add new channel type for child protection

Signed-off-by: David Pace <dev@davidpace.de>
Signed-off-by: Alexander Drent <Alex@Drent-ict.nl>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement An enhancement or new feature for an existing add-on
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants