tschamm / boschshc-hass

Home Assistant component for accessing Bosch Smart Home Controller using boschshcpy python library.
Other
171 stars 25 forks source link

micromodule_relay devices no longer available #113

Open hkohls opened 1 year ago

hkohls commented 1 year ago

Since appr. 5 days my devices of type micromodule_relay are disconnected. After deleting and reconfiguring the bosch integration no micromodule_relay devices are found anymore. The devices are still visible and working fine with Bosch app

tschamm commented 1 year ago

Are they configured as impulse switches or as normal switches? The implementation for impulse switches is not fully done.

hkohls commented 1 year ago

As regular switch, and they worked before with your integration.

tschamm commented 1 year ago

Can you check the logs when restarting HA, if there are error messages from either boschshc_hass or boschshcpy popping up? I guess I screwed it up when implementing the Impulse switch.

COLT9001 commented 1 year ago

2023-10-03 16:15:18.160 ERROR (MainThread) [homeassistant.components.switch] Error while setting up bosch_shc platform for switch Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 359, in _async_setup_platform await asyncio.shield(task) File "/config/custom_components/bosch_shc/switch.py", line 223, in async_setup_entry for switch in session.device_helper.micromodule_relays: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.11/site-packages/boschshcpy/device_helper.py", line 121, in micromodule_relays devices.extend(relay) TypeError: 'SHCMicromoduleRelay' object is not iterable

hkohls commented 1 year ago

Since I restored my last Backup, I lost all trace. Hope the above log from colt9001 is good enough! Thanks for investigating on this!

tschamm commented 1 year ago

Thanks, I fixed it with b7cdcea

hkohls commented 1 year ago

Can we please open this issue again? I still run into the same problem of deactivated switches, using you latest releases. I wonder if this here might be the cause. You validate the profile for "GENERIC" and set the type of relay. But the device scanner shows this setting in both configurations. The indicators are "PowerSwitch" or " "ImpulseSwitch""

Your code in models_impl.py return ( self.RelayType.BUTTON if self.profile == "GENERIC" else self.RelayType.SWITCH )

Extract from scan: "id": "hdm:ZigBee:287681fffe7083c5", "deviceServiceIds": [ "CommunicationQuality", "PowerSwitch", "ChildProtection", "PowerSwitchProgram", "ElectricalFaults", "SwitchConfiguration" ], "manufacturer": "BOSCH", "roomId": "hz_1", "deviceModel": "MICROMODULE_RELAY", "serial": "287681FFFE7083C5",

tschamm commented 1 year ago

For sure. Checking the service would be ok also, but at least I assumed the profile type is giving hint enough. Maybe at some point I have to buy a relay to test.

tschamm commented 9 months ago

Problem is still existing?

hkohls commented 9 months ago

I updated to your latest version which fixed the impulse switch. But I see this problem again. In October I just reverted to an older version to get rid of it.

tschamm commented 9 months ago

Ok, do you see an error message in the logs? Related to one of the Platforms?

hkohls commented 9 months ago

Please advice: where do I find the log?

hkohls commented 9 months ago

I managed to get access to the logs, changed the loglevel for custom_components.bosch_shc to debug and reloaded the integration: no erros! Any other procedures to follow that might give you hints?

hkohls commented 9 months ago

I reinstalled everything. Same error, but now with log: 2024-02-04 16:47:03.546 ERROR (MainThread) [homeassistant.components.websocket_api.http.connection] [547969557824] 'NoneType' object has no attribute 'put_state_element' Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/components/websocket_api/commands.py", line 238, in handle_call_service response = await hass.services.async_call( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/core.py", line 2149, in async_call response_data = await coro ^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/core.py", line 2186, in _execute_service return await target(service_call) ^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/helpers/entity_component.py", line 272, in handle_service return await service.entity_service_call( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 882, in entity_service_call single_response = await _handle_entity_call( ^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 952, in _handle_entity_call result = await task ^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/components/button/init.py", line 132, in _async_press_action await self.async_press() File "/usr/src/homeassistant/homeassistant/components/button/init.py", line 147, in async_press await self.hass.async_add_executor_job(self.press) File "/usr/local/lib/python3.11/concurrent/futures/thread.py", line 58, in run result = self.fn(*self.args, **self.kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/config/custom_components/bosch_shc/button.py", line 82, in press self._device.trigger_impulse_state() File "/usr/local/lib/python3.11/site-packages/boschshcpy/models_impl.py", line 271, in trigger_impulse_state self._impulseswitch_service.put_state_element("impulseState", True) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ AttributeError: 'NoneType' object has no attribute 'put_state_element'

hkohls commented 9 months ago

Seems the switches are identified as impulse: image

hkohls commented 9 months ago

Please have a look at the output from the device scan I did last year. All share the profile GENERIC, but they differ in this setting: image image

tt-pete commented 9 months ago

With the new version 0.4.85 it still doesn't work for me as a switch. The last version that works for me is 0.4.57. Error messages similar to above:

2024-02-11 21:47:26.822 ERROR (MainThread) [homeassistant.components.websocket_api.http.connection] [140208032504256] 'NoneType' object has no attribute 'put_state_element' Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/components/websocket_api/commands.py", line 240, in handle_call_service response = await hass.services.async_call( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/core.py", line 2279, in async_call response_data = await coro ^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/core.py", line 2316, in _execute_service return await target(service_call) ^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 892, in entity_service_call single_response = await _handle_entity_call( ^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 962, in _handle_entity_call result = await task ^^^^^^^^^^ File "/usr/src/homeassistant/homeassistant/components/button/init.py", line 139, in _async_press_action await self.async_press() File "/usr/src/homeassistant/homeassistant/components/button/init.py", line 154, in async_press await self.hass.async_add_executor_job(self.press) File "/usr/local/lib/python3.12/concurrent/futures/thread.py", line 58, in run result = self.fn(*self.args, **self.kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/config/custom_components/bosch_shc/button.py", line 82, in press self._device.trigger_impulse_state() File "/usr/local/lib/python3.12/site-packages/boschshcpy/models_impl.py", line 271, in trigger_impulse_state self._impulseswitch_service.put_state_element("impulseState", True) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ AttributeError: 'NoneType' object has no attribute 'put_state_element'

MarkusHaag commented 9 months ago

I experience the same issue. In the past I configured them as switches to expose them in Homekit (setup without HomeAssistant) and to mimik Button I had automatization to switch them off once switched on. If I got it right, they would be functional in HomeAssistant when configured as button. As I am anyhow changing my setup to HomeAssistant this could be my solution to simple reconfigure them correctly or do I miss something?

Update: Deleted the Switch in Bosch app and readded as Buttons. Now it is working as expected. Learning of this excercise. Always have the codes available that you don't need to take the relays out of wall again.

tt-pete commented 9 months ago

I have now removed and re-added the relay several times in the Bosch app, but I still get the above error.

In the Bosch app, the relay is displayed as follows:

Screenshot_2024-02-17-10-22-15-792_com bosch sh ui android

I get always the error "NoneType' object has no attribute 'put_state_element" when I press the button in Home Assistant.

DrPain911 commented 1 month ago

I have this Problem as well with the latest version. Will try readding it into the shc.

DrPain911 commented 1 month ago

Hallo back, I just tried removing and readding the devices. Still getting the same error mentioned above. Is there something I can do to help get this solved?

tschamm commented 1 month ago

Version 0.4.91 has checks if the services of the relays are NoneType. Should fix the error AttributeError: 'NoneType' object has no attribute 'put_state_element'. Can you please re-check.

DrPain911 commented 1 month ago

Thanks! So the error does not appear anymore, but unfortunately pressing the button does not change the state of the device.

tschamm commented 1 month ago

That was what I feared. Do you know from the API, what would be the command to trigger the device?

DrPain911 commented 1 month ago

Unfortunately not, as Iā€™m not too familiar with these kinds of things. My workaround involved connecting to the BSH with HA via HomeKit to get the functionality back. I would prefer your Integration though as it enables much more functionality šŸ‘šŸ»

tt-pete commented 1 month ago

I also see the button now. But pressing it, doesn't cause any switching.

I don't have any knowledge of the API either. However, I already wrote in my post from February 13, 2024 that it worked until version 0.4.57. A subsequent change resulted in the error. Maybe this information will help to find a solution.

webfal commented 1 week ago

That was what I feared. Do you know from the API, what would be the command to trigger the device?

The MICROMODULE_RELAY be switch on/off like a PowerSwitch. It's the PUT request {{shc_api}}/devices/{{device_id}}/services/PowerSwitch/state with the body {"@type": "powerSwitchState","switchState": "[OFF or ON]"}