koenhendriks / ha-button-plus

Home Assistant integration platform for Button+
GNU General Public License v3.0
16 stars 7 forks source link

reinstall integration in HA failed #69

Open bartve66 opened 1 month ago

bartve66 commented 1 month ago

I want to reinstall the HACS integration for Button+ in Home Assistant. Downloading the integration in HACS works, but when I want to add the integration in HA it asks for login + password for Button+ (I assume the credentials are for the button.plus website?) OR the auth cookie after logging in to button.plus. When I enter login/password HA reports after hitting 'send' that the configuration failed. The log says the following:

Translated with DeepL.com (free version)

Logger: homeassistant.config_entries Bron: config_entries.py:604 Eerst voorgekomen: 21:04:41 (3 gebeurtenissen) Laatst gelogd: 21:20:32

Error setting up entry bplus_wk1 for button_plus Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/config_entries.py", line 604, in async_setup result = await component.async_setup_entry(hass, self) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/config/custom_components/button_plus/init.py", line 29, in async_setup_entry device_configuration: DeviceConfiguration = ModelDetection.model_for_json( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/config/custom_components/button_plus/button_plus_api/model_detection.py", line 9, in model_for_json data = json.loads(json_data) ^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/json/init.py", line 339, in loads raise TypeError(f'the JSON object must be str, bytes or bytearray, ' TypeError: the JSON object must be str, bytes or bytearray, not NoneType

Am I doing something wrong? Would it work with the auth cookie? I just don't know how to get that ...

koenhendriks commented 1 month ago

Hmm seems you are using the old login feature that I created when I didn't have a physical device.

It's deprecated and will be removed soon. Please try connecting using the local IP address of your button plus.

Screenshot_20240825-123207.png

bartve66 commented 1 month ago

Tried that, but also an error. From the logs:

Logger: custom_components.button_plus.config_flow Bron: custom_components/button_plus/config_flow.py:123 integratie: Button+ (documentatie, problemen) Eerst voorgekomen: 15:57:00 (2 gebeurtenissen) Laatst gelogd: 15:59:30

button_plus Exception in login : 2 is not a valid EventType - traceback: Traceback (most recent call last): File "/config/custom_components/button_plus/config_flow.py", line 98, in async_step_manual device_config: DeviceConfiguration = ModelDetection.model_for_json( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/config/custom_components/button_plus/button_plus_api/model_detection.py", line 15, in model_for_json return DeviceConfiguration.from_dict(data) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/config/custom_components/button_plus/button_plus_api/model_v1_12.py", line 185, in from_dict MqttButton.from_dict(button) for button in data["mqttbuttons"] ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/config/custom_components/button_plus/button_plus_api/model_v1_07.py", line 212, in from_dict topics=[Topic.from_dict(topic) for topic in data.get("topics", [])], ^^^^^^^^^^^^^^^^^^^^^^ File "/config/custom_components/button_plus/button_plus_api/model_v1_07.py", line 110, in from_dict event_type=EventType(data["eventtype"]), ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/enum.py", line 757, in call return cls.new(cls, value) ^^^^^^^^^^^^^^^^^^^^^^^ File "/usr/local/lib/python3.12/enum.py", line 1171, in new raise ve_exc ValueError: 2 is not a valid EventType

[...]

Logger: homeassistant.util.json Bron: helpers/deprecation.py:197 Eerst voorgekomen: 15:55:23 (19 gebeurtenissen) Laatst gelogd: 15:57:20

json_loads was called from hacs, this is a deprecated function which will be removed in HA Core 2025.8. Use homeassistant.util.json.json_loads instead, please create a bug report at https://github.com/hacs/integration/issues

koenhendriks commented 1 month ago

There is a bit more useful information in this error. There seems to be a Event Type registered in your existing Button+ config that is unknown to the Integration (number 2).

Can you show me a screenshot of your config from the web ui which events you have on the button plus?

bartve66 commented 1 month ago

Here is a screen shot with the configuration management sub menu open. I could not find an 'event' in the other sub menus? If you need info from one of the other sub menus I can post another screen shot? buttonplus config

koenhendriks commented 1 month ago

I just took a look into the virtual device configuration and it seems the event type that is causing the error is 'Click released'.

You should be able to find it under Button configuration -> MQTT topics

Screenshot_20240826_153258

It seems the integration is out of date with the current Event types that are in the web configuration.

For now you can fix this by removing the 'Click released' topics or resetting the configuration entirely.

bartve66 commented 1 month ago

That worked, with some hits and misses. I already noticed the click event in the MQTT topics sub menu, and removed it. Also removed the integration from HA and HACS, and started over. That did not solve the issue. Maybe somewhere in HA some configuration info is left? Resetting the button plus device to factory defaults worked in the end, but first attempt to install the integration in HA after filling in the button plus device URL and hitting send it was endlessly showing that window 'looping'? Some attempts later the integration was installed. Observation (also from the old setup): although I first renamed the device in de button plus setup (through the the URL of the device) to 'bplus_wk1', after installing the integration all button plus related devices are referred to in HA by the factory defined name of the device ('btn_45a400'), which is a bit confusing? Many thanks for your assistance!