koenhendriks / ha-button-plus

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

I can't connect the integration to my B+ #64

Closed PalmManiac closed 2 months ago

PalmManiac commented 3 months ago

Describe the bug Hello,

I've been trying to integrate my B+ into HA using the Button+ integration for a while now, but I just can't get it to work. As soon as I enter the IP address of my B+ in the config, I get an error message and the log always says this:

`Dieser Fehler wurde von einer benutzerdefinierten Integration verursacht

Logger: custom_components.button_plus.config_flow Quelle: custom_components/button_plus/config_flow.py:123 Integration: Button+ (Dokumentation, Probleme) Erstmals aufgetreten: 11:47:17 (6 Vorkommnisse) Zuletzt protokolliert: 12:53:20

button_plus Exception in login : 'brightnesslargedisplay' - traceback: Traceback (most recent call last): File "/config/custom_components/button_plus/config_flow.py", line 100, in async_step_manual device_config: DeviceConfiguration = DeviceConfiguration.from_json(json_config) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/config/custom_components/button_plus/button_plus_api/model.py", line 212, in from_json core=Core.from_dict(data['core']), ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/config/custom_components/button_plus/button_plus_api/model.py", line 98, in from_dict brightness_large_display=data['brightnesslargedisplay'], ~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^ KeyError: 'brightnesslargedisplay' button_plus Exception in login : 'brightnesslargedisplay' - traceback: Traceback (most recent call last): File "/config/custom_components/button_plus/config_flow.py", line 100, in async_step_manual device_config: DeviceConfiguration = DeviceConfiguration.from_json(json_config) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/config/custom_components/button_plus/button_plus_api/model.py", line 212, in from_json core=Core.from_dict(data['core']), ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/config/custom_components/button_plus/button_plus_api/model.py", line 98, in from_dict #brightness_large_display=data['brightnesslargedisplay'], ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ KeyError: 'brightnesslargedisplay'`

The firmware on my B+ is currently V1.13beta, but it doesn't work with firmware version V1.12.x either. What am I doing wrong, because there's not much that can go wrong when setting up the integration?

koenhendriks commented 3 months ago

Hey Palm,

I think there might be some difference in the config model in this repo and the one used in the latest few versions of Button+.

I haven't been to active on this project at the moment, some other stuff came up.

@wimjanse can you replicate this bug with the latest firmware?

wimjanse commented 3 months ago

Hi Coen,

I’ve recently upgraded the firmware of my two B+’s to v1.12.2. I’m running HA 2024.6.4 and latest version of the B+ integration. No issues at all, all running flawlessly. Note that I upgrade from older versions, I have not (re-)setup a new device like Palm tries to do. But again, no issues with the latest firmware.

PalmManiac commented 3 months ago

These are existing devices. Right at the beginning, I think under firmware V1.081, it worked once, but I wasn't ready for it yet. Now one is running V1.12.3 and the second is running V1.13Beta and neither of them connect anymore with this error message.

I have to say one more thing, I don't know if that's right. I have the current version V0.0.14 installed. If I let the account search automatically when setting it up, the adapter is created but with an error and the version shown is V0.0.1.

wimjanse commented 3 months ago

One suggestion I have: completely remove the buttonplus integration from hacs, and do a full reinstall (you were forced to do this with the older versions of the buttonplus integration).

With the two devices I have, I don’t let the integration search automatically, I manually setup the ip-address.

Two B+’s I own are working stable for months.

PalmManiac commented 3 months ago

I have done this several times without any improvement, the error remains. With the MQTT broker in HA the connection is established perfectly, but the service does not connect to the B+.

PalmManiac commented 3 months ago

I have experimented a bit with older firmware versions. The B+ connects to the integration up to V1.11. Anything >= V1.12 causes the error. BUT once the B+ is successfully connected, you can update the firmware and it will continue to work.

However, a lot is still missing, including the control of the LEDs.

I hope the integration will be further developed, because I am surprised at how reliably the recognition of a keystroke works. When I see how complicated it was to fiddle around with the same function in iobroker using Blockly and various adapters... I would really like to switch. :)

IBlackI commented 2 months ago

When trying to use it with version 1.11 the intergration seems to connect, but the entities do not show up in HASS anymore. I can't downgrade the button to version 1.081 anymore for testing.

scspijker commented 2 months ago

The problem is in model.py.

The following lines (model.py:110)

        return Core(
            name=data["name"],
            location=data["location"],
            auto_backup=data["autobackup"],
            brightness_large_display=data["brightnesslargedisplay"],
            brightness_mini_display=data["brightnessminidisplay"],
            led_color_front=data["ledcolorfront"],
            led_color_wall=data["ledcolorwall"],
            color=data["color"],
            topics=[Topic.from_dict(topic) for topic in data.get("topics", [])],
        )

They do not correspond with the actual config being sent:

"core": {
        "name": "btn_4584b8",
        "location": "Room 1",
        "autobackup": true,
        "brightness": 80,
        "color": 16765791,
        "statusbar": 2,
        "topics": []
    },

So it seems like the internal API's had some breaking changes. Staying on V1.11 for setting up the integration is the work around. It seems you can upgrade the Button+ after setup though, without breaking this integration.

scspijker commented 2 months ago

Fixed in this PR: https://github.com/koenhendriks/ha-button-plus/pull/66

Too bad firmware version 1.13 just came out, and broke AGAIN 😂 With my pull request it will be way easier to add v1.13 though. Maybe I'll include it when Button+ responds why the /configsave endpoint has broken.

koenhendriks commented 2 months ago

Closed with #66 merged! Please re-open for new firmware versions.