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

Integration does not work after upgrade to 0.9 #50

Closed
Al3xand3R360 opened this issue Mar 22, 2024 · 39 comments · Fixed by #54
Closed

Integration does not work after upgrade to 0.9 #50

Al3xand3R360 opened this issue Mar 22, 2024 · 39 comments · Fixed by #54
Assignees
Labels
bug Something isn't working

Comments

@Al3xand3R360
Copy link

After updating integration to version 0.9 Button+ integration stops working.

I use HA2024.4.2

Logger: homeassistant.config_entries
Source: config_entries.py:504
First occurred: 16:15:15 (1 occurrences)
Last logged: 16:15:15

Error setting up entry btn_462b80 for button_plus
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/config_entries.py", line 504, in async_setup
    result = await component.async_setup_entry(hass, self)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/button_plus/__init__.py", line 25, in async_setup_entry
    device_configuration: DeviceConfiguration = DeviceConfiguration.from_json(entry.data.get("config"))
                                                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/button_plus/button_plus_api/model.py", line 206, in from_json
    core=Core.from_dict(data['core']),
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/button_plus/button_plus_api/model.py", line 80, in from_dict
    topics=data['topics']
           ~~~~^^^^^^^^^^
KeyError: 'topics'
@Al3xand3R360 Al3xand3R360 added the bug Something isn't working label Mar 22, 2024
@Al3xand3R360
Copy link
Author

Scherm­afbeelding 2024-03-22 om 16 21 16 Scherm­afbeelding 2024-03-22 om 16 21 50

@koenhendriks
Copy link
Owner

Could you check if you're on the latest firmware of the Button+ device? You can check by going to the IP address.

@Al3xand3R360
Copy link
Author

Yes, I'm on firmware 1.11

@koenhendriks
Copy link
Owner

@P-Storm seems the configuration json doesn't always have a "topics" child key in the json?

@P-Storm
Copy link
Contributor

P-Storm commented Mar 22, 2024

On the mqttbuttons I see a empty array. All my config that I have is this at least populated. @Al3xand3R360 can you post your /config file, curious what it is trying to read in.

I think it is also a good case to check if key exist, if not create an empty list/array of it.

@Al3xand3R360
Copy link
Author

Al3xand3R360 commented Mar 23, 2024

Sure, here’s my config:

{
    "info": {
        "id": "btn_462b80",
        "mac": "F4:12:xx:xx:xx:xx",
        "ipaddress": "192.168.xxx.xxx",
        "firmware": "1.11",
        "largedisplay": 0,
        "connectors": [
            {
                "id": 0,
                "type": 2
            },
            {
                "id": 1,
                "type": 1
            },
            {
                "id": 2,
                "type": 1
            },
            {
                "id": 3,
                "type": 1
            }
        ],
        "sensors": [
            {
                "sensorid": 1,
                "description": "Sensirion STS35 Temperature Sensor"
            }
        ]
    },
    "core": {
        "name": "btn_462b80",
        "location": "Woonkamer",
        "autobackup": true,
        "brightnesslargedisplay": 60,
        "brightnessminidisplay": 60,
        "ledcolorfront": 0,
        "ledcolorwall": 0,
        "color": 6603878,
        "statusbar": 0,
        "topics": []
    },
    "mqttbuttons": [
        {
            "id": 0,
            "label": "Btn 0",
            "toplabel": "Label",
            "ledcolorfront": 0,
            "ledcolorwall": 0,
            "longdelay": 75,
            "longrepeat": 15,
            "topics": [
                {
                    "brokerid": "ha-button-plus",
                    "topic": "buttonplus/btn_462b80/button/0/click",
                    "payload": "press",
                    "eventtype": 0
                },
                {
                    "brokerid": "ha-button-plus",
                    "topic": "buttonplus/btn_462b80/button/0/label",
                    "payload": "",
                    "eventtype": 11
                },
                {
                    "brokerid": "ha-button-plus",
                    "topic": "buttonplus/btn_462b80/button/0/top_label",
                    "payload": "",
                    "eventtype": 12
                }
            ]
        },
        {
            "id": 1,
            "label": "Btn 1",
            "toplabel": "Label",
            "ledcolorfront": 0,
            "ledcolorwall": 0,
            "longdelay": 75,
            "longrepeat": 15,
            "topics": [
                {
                    "brokerid": "ha-button-plus",
                    "topic": "buttonplus/btn_462b80/button/1/click",
                    "payload": "press",
                    "eventtype": 0
                },
                {
                    "brokerid": "ha-button-plus",
                    "topic": "buttonplus/btn_462b80/button/1/label",
                    "payload": "",
                    "eventtype": 11
                },
                {
                    "brokerid": "ha-button-plus",
                    "topic": "buttonplus/btn_462b80/button/1/top_label",
                    "payload": "",
                    "eventtype": 12
                }
            ]
        },
        {
            "id": 2,
            "label": "Woonkamer",
            "toplabel": "Verlichting",
            "ledcolorfront": 0,
            "ledcolorwall": 0,
            "longdelay": 75,
            "longrepeat": 15,
            "topics": [
                {
                    "brokerid": "ha-button-plus",
                    "topic": "buttonplus/btn_462b80/button/2/click",
                    "payload": "press",
                    "eventtype": 0
                },
                {
                    "brokerid": "buttonha",
                    "topic": "button.plus/woonkamer/light/status",
                    "payload": "on",
                    "eventtype": 10
                },
                {
                    "brokerid": "ha-button-plus",
                    "topic": "buttonplus/btn_462b80/button/2/label",
                    "payload": "",
                    "eventtype": 11
                },
                {
                    "brokerid": "ha-button-plus",
                    "topic": "buttonplus/btn_462b80/button/2/top_label",
                    "payload": "",
                    "eventtype": 12
                }
            ]
        },
        {
            "id": 3,
            "label": "Eetkamer",
            "toplabel": "Verlichting",
            "ledcolorfront": 0,
            "ledcolorwall": 0,
            "longdelay": 75,
            "longrepeat": 15,
            "topics": [
                {
                    "brokerid": "ha-button-plus",
                    "topic": "buttonplus/btn_462b80/button/3/click",
                    "payload": "press",
                    "eventtype": 0
                },
                {
                    "brokerid": "buttonha",
                    "topic": "button.plus/eetkamer/light/status",
                    "payload": "on",
                    "eventtype": 10
                },
                {
                    "brokerid": "ha-button-plus",
                    "topic": "buttonplus/btn_462b80/button/3/label",
                    "payload": "",
                    "eventtype": 11
                },
                {
                    "brokerid": "ha-button-plus",
                    "topic": "buttonplus/btn_462b80/button/3/top_label",
                    "payload": "",
                    "eventtype": 12
                }
            ]
        },
        {
            "id": 4,
            "label": "Open",
            "toplabel": "Gordijn voor",
            "ledcolorfront": 0,
            "ledcolorwall": 0,
            "longdelay": 75,
            "longrepeat": 15,
            "topics": [
                {
                    "brokerid": "ha-button-plus",
                    "topic": "buttonplus/btn_462b80/button/4/click",
                    "payload": "press",
                    "eventtype": 0
                },
                {
                    "brokerid": "buttonha",
                    "topic": "button.plus/woonkamer/gordijn/status",
                    "payload": "on",
                    "eventtype": 10
                },
                {
                    "brokerid": "ha-button-plus",
                    "topic": "buttonplus/btn_462b80/button/4/label",
                    "payload": "",
                    "eventtype": 11
                },
                {
                    "brokerid": "ha-button-plus",
                    "topic": "buttonplus/btn_462b80/button/4/top_label",
                    "payload": "",
                    "eventtype": 12
                }
            ]
        },
        {
            "id": 5,
            "label": "Keuken",
            "toplabel": "Verlichting",
            "ledcolorfront": 0,
            "ledcolorwall": 0,
            "longdelay": 75,
            "longrepeat": 15,
            "topics": [
                {
                    "brokerid": "ha-button-plus",
                    "topic": "buttonplus/btn_462b80/button/5/click",
                    "payload": "press",
                    "eventtype": 0
                },
                {
                    "brokerid": "buttonha",
                    "topic": "button.plus/keuken/light/status",
                    "payload": "on",
                    "eventtype": 10
                },
                {
                    "brokerid": "ha-button-plus",
                    "topic": "buttonplus/btn_462b80/button/5/label",
                    "payload": "",
                    "eventtype": 11
                },
                {
                    "brokerid": "ha-button-plus",
                    "topic": "buttonplus/btn_462b80/button/5/top_label",
                    "payload": "",
                    "eventtype": 12
                }
            ]
        },
        {
            "id": 6,
            "label": "",
            "toplabel": "",
            "ledcolorfront": 0,
            "ledcolorwall": 0,
            "longdelay": 75,
            "longrepeat": 15,
            "topics": [
                {
                    "brokerid": "ha-button-plus",
                    "topic": "buttonplus/btn_462b80/button/6/click",
                    "payload": "press",
                    "eventtype": 0
                },
                {
                    "brokerid": "ha-button-plus",
                    "topic": "buttonplus/btn_462b80/button/6/label",
                    "payload": "",
                    "eventtype": 11
                },
                {
                    "brokerid": "ha-button-plus",
                    "topic": "buttonplus/btn_462b80/button/6/top_label",
                    "payload": "",
                    "eventtype": 12
                }
            ]
        },
        {
            "id": 7,
            "label": "66 km",
            "toplabel": "Auto laden",
            "ledcolorfront": 0,
            "ledcolorwall": 0,
            "longdelay": 75,
            "longrepeat": 15,
            "topics": [
                {
                    "brokerid": "ha-button-plus",
                    "topic": "buttonplus/btn_462b80/button/7/click",
                    "payload": "press",
                    "eventtype": 0
                },
                {
                    "brokerid": "buttonha",
                    "topic": "button.plus/notification/auto/range",
                    "payload": "on",
                    "eventtype": 9
                },
                {
                    "brokerid": "ha-button-plus",
                    "topic": "buttonplus/btn_462b80/button/7/label",
                    "payload": "",
                    "eventtype": 11
                },
                {
                    "brokerid": "ha-button-plus",
                    "topic": "buttonplus/btn_462b80/button/7/top_label",
                    "payload": "",
                    "eventtype": 12
                }
            ]
        }
    ],
    "mqttdisplays": [
        {
            "x": 0,
            "y": 0,
            "fontsize": 4,
            "align": 1,
            "width": 50,
            "round": 0,
            "label": "Nijmegen",
            "unit": "",
            "page": 0,
            "topics": [
                {
                    "brokerid": "buttonplus",
                    "topic": "system/datetime/amsterdam",
                    "payload": "",
                    "eventtype": 15
                }
            ]
        },
        {
            "x": 0,
            "y": 40,
            "fontsize": 2,
            "align": 1,
            "width": 20,
            "round": 1,
            "label": "Kamer",
            "unit": "°C",
            "page": 0,
            "topics": [
                {
                    "brokerid": "buttonplus",
                    "topic": "button/btn_462b80/temperature",
                    "payload": "",
                    "eventtype": 15
                }
            ]
        },
        {
            "x": 30,
            "y": 40,
            "fontsize": 2,
            "align": 1,
            "width": 20,
            "round": 1,
            "label": "Buiten",
            "unit": "°C",
            "page": 0,
            "topics": [
                {
                    "brokerid": "buttonha",
                    "topic": "button.plus/woonkamer/temperature/outside",
                    "payload": "{state}",
                    "eventtype": 15
                }
            ]
        },
        {
            "x": 60,
            "y": 0,
            "fontsize": 2,
            "align": 1,
            "width": 40,
            "round": 2,
            "label": "Stroomprijs",
            "unit": "EUR/kWh",
            "page": 0,
            "topics": [
                {
                    "brokerid": "buttonha",
                    "topic": "button.plus/woonkamer/energy/current_price",
                    "payload": "",
                    "eventtype": 15
                }
            ]
        },
        {
            "x": 0,
            "y": 65,
            "fontsize": 1,
            "align": 1,
            "width": 100,
            "round": 0,
            "label": "Sonos - now playing:",
            "unit": "",
            "page": 0,
            "topics": [
                {
                    "brokerid": "buttonha",
                    "topic": "button.plus/woonkamer/speakers/title",
                    "payload": "",
                    "eventtype": 15
                }
            ]
        },
        {
            "x": 0,
            "y": 0,
            "fontsize": 1,
            "align": 1,
            "width": 95,
            "round": 0,
            "label": "Energie details",
            "unit": "",
            "page": 1,
            "topics": []
        },
        {
            "x": 0,
            "y": 25,
            "fontsize": 2,
            "align": 1,
            "width": 40,
            "round": 2,
            "label": "Stroomverbruik",
            "unit": "kWh",
            "page": 1,
            "topics": [
                {
                    "brokerid": "buttonha",
                    "topic": "button.plus/woonkamer/energy/accumulated_consumption",
                    "payload": "",
                    "eventtype": 15
                }
            ]
        },
        {
            "x": 45,
            "y": 25,
            "fontsize": 2,
            "align": 1,
            "width": 40,
            "round": 2,
            "label": "Zonnepanelen",
            "unit": "kWh",
            "page": 1,
            "topics": [
                {
                    "brokerid": "buttonha",
                    "topic": "button.plus/woonkamer/energy/accumulated_production",
                    "payload": "",
                    "eventtype": 15
                }
            ]
        },
        {
            "x": 0,
            "y": 50,
            "fontsize": 2,
            "align": 1,
            "width": 40,
            "round": 0,
            "label": "Waterverbruik",
            "unit": "L",
            "page": 1,
            "topics": [
                {
                    "brokerid": "buttonha",
                    "topic": "button.plus/woonkamer/energy/accumulated_water",
                    "payload": "",
                    "eventtype": 15
                }
            ]
        },
        {
            "x": 45,
            "y": 50,
            "fontsize": 2,
            "align": 1,
            "width": 40,
            "round": 3,
            "label": "Warmtenet",
            "unit": "GJ",
            "page": 1,
            "topics": [
                {
                    "brokerid": "buttonha",
                    "topic": "button.plus/woonkamer/energy/accumulated_warmtenet",
                    "payload": "",
                    "eventtype": 15
                }
            ]
        }
    ],
    "mqttbrokers": [
        {
            "brokerid": "buttonha",
            "url": "mqtt://192.168.xxx.xxx",
            "port": 1883,
            "wsport": 0,
            "username": "xxx",
            "password": "xxx"
        },
        {
            "brokerid": "buttonplus",
            "url": "mqtt://mqtt.button.plus",
            "port": 0,
            "wsport": 0,
            "username": "",
            "password": ""
        },
        {
            "brokerid": "ha-button-plus",
            "url": "mqtt://192.168.xxx.xxx/",
            "port": 1883,
            "wsport": 9001,
            "username": "xxx",
            "password": "xxx"
        }
    ],
    "mqttsensors": [
        {
            "sensorid": 1,
            "interval": 10,
            "topic": {
                "brokerid": "buttonplus",
                "topic": "button/btn_462b80/temperature",
                "payload": "",
                "eventtype": 18
            }
        }
    ]
}

koenhendriks added a commit that referenced this issue Mar 24, 2024
Fixing #50 - topics not there/empty
@koenhendriks
Copy link
Owner

@Al3xand3R360 Please try out the latest version (0.0.10) of the integration. You can re-open this issue if this has not been fixed.

@Al3xand3R360
Copy link
Author

It does not seem to work yet. With version 0.10 the integration does not load after restart.

Logger: homeassistant.loader
Source: loader.py:921
First occurred: 21:55:00 (1 occurrences)
Last logged: 21:55:00

Unexpected exception importing component custom_components.button_plus
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/loader.py", line 921, in get_component
    ComponentProtocol, importlib.import_module(self.pkg_path)
                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/importlib/__init__.py", line 90, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<frozen importlib._bootstrap>", line 1387, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1360, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1331, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 935, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 995, in exec_module
  File "<frozen importlib._bootstrap>", line 488, in _call_with_frames_removed
  File "/config/custom_components/button_plus/__init__.py", line 10, in <module>
    from custom_components.button_plus.button_plus_api.model import DeviceConfiguration
  File "/config/custom_components/button_plus/button_plus_api/model.py", line 63, in <module>
    class Topic:
  File "/config/custom_components/button_plus/button_plus_api/model.py", line 70, in Topic
    def connector_type_enum(self) -> EventType:
                                     ^^^^^^^^^
NameError: name 'EventType' is not defined

and

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/loader.py", line 921, in get_component
    ComponentProtocol, importlib.import_module(self.pkg_path)
                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/importlib/__init__.py", line 90, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<frozen importlib._bootstrap>", line 1387, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1360, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1331, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 935, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 995, in exec_module
  File "<frozen importlib._bootstrap>", line 488, in _call_with_frames_removed
  File "/config/custom_components/button_plus/__init__.py", line 10, in <module>
    from custom_components.button_plus.button_plus_api.model import DeviceConfiguration
  File "/config/custom_components/button_plus/button_plus_api/model.py", line 63, in <module>
    class Topic:
  File "/config/custom_components/button_plus/button_plus_api/model.py", line 70, in Topic
    def connector_type_enum(self) -> EventType:
                                     ^^^^^^^^^
NameError: name 'EventType' is not defined

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/setup.py", line 296, in _async_setup_component
    component = await integration.async_get_component()
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/loader.py", line 894, in async_get_component
    comp = self.get_component()
           ^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/loader.py", line 932, in get_component
    raise ImportError(f"Exception importing {self.pkg_path}") from err
ImportError: Exception importing custom_components.button_plus

are logged after restart.

@Al3xand3R360
Copy link
Author

@Al3xand3R360 Please try out the latest version (0.0.10) of the integration. You can re-open this issue if this has not been fixed.

@koenhendriks I can’t seem to re-open this issue myself. Would you mind te-opening it?

@nvdweem
Copy link

nvdweem commented Mar 24, 2024

For me it's now impossible to start the config flow in 0.10.
I removed the devices, updated to 0.10 and tried to re-add them, logs show this stacktrace:

Logger: homeassistant.loader
Source: loader.py:1025
First occurred: 22:18:52 (2 occurrences)
Last logged: 22:20:05

Unexpected exception importing platform custom_components.button_plus.config_flow
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/loader.py", line 1025, in _load_platform
    cache[full_name] = self._import_platform(platform_name)
                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/loader.py", line 1058, in _import_platform
    return importlib.import_module(f"{self.pkg_path}.{platform_name}")
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/importlib/__init__.py", line 90, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<frozen importlib._bootstrap>", line 1387, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1360, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1310, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 488, in _call_with_frames_removed
  File "<frozen importlib._bootstrap>", line 1387, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1360, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1331, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 935, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 995, in exec_module
  File "<frozen importlib._bootstrap>", line 488, in _call_with_frames_removed
  File "/config/custom_components/button_plus/__init__.py", line 10, in <module>
    from custom_components.button_plus.button_plus_api.model import DeviceConfiguration
  File "/config/custom_components/button_plus/button_plus_api/model.py", line 63, in <module>
    class Topic:
  File "/config/custom_components/button_plus/button_plus_api/model.py", line 70, in Topic
    def connector_type_enum(self) -> EventType:
                                     ^^^^^^^^^
NameError: name 'EventType' is not defined

Looks like it's failing on the same EventType

@P-Storm
Copy link
Contributor

P-Storm commented Mar 24, 2024

Looks like something weird is happened with merging, let's check.

@P-Storm
Copy link
Contributor

P-Storm commented Mar 24, 2024

Well, my change didn't include, dunno how that could be, but gonna test this out before submitting another PR. Sorry about this!

from config.custom_components.button_plus.button_plus_api.event_type import EventType

@P-Storm
Copy link
Contributor

P-Storm commented Mar 24, 2024

And also tested on my non-dev HA instance. Looks like this fixes it.

@koenhendriks koenhendriks reopened this Mar 25, 2024
@koenhendriks
Copy link
Owner

Should add some linter for python to avoid missing imports and such.

The PR to fix the event types has been merged. I'll keep this issue open for now to ensure any fixes.

@koenhendriks
Copy link
Owner

Released v0.0.11

@Al3xand3R360
Copy link
Author

Thanks for the quick response guys!

But still no luck, sorry... After updating and restart the following stacktrace is logged:

Logger: homeassistant.setup
Source: setup.py:296
First occurred: 13:57:11 (1 occurrences)
Last logged: 13:57:11

Setup failed for custom integration 'button_plus': Unable to import component: No module named 'config.custom_components'
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/setup.py", line 296, in _async_setup_component
    component = await integration.async_get_component()
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/loader.py", line 894, in async_get_component
    comp = self.get_component()
           ^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/loader.py", line 921, in get_component
    ComponentProtocol, importlib.import_module(self.pkg_path)
                       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/importlib/__init__.py", line 90, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "<frozen importlib._bootstrap>", line 1387, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1360, in _find_and_load
  File "<frozen importlib._bootstrap>", line 1331, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 935, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 995, in exec_module
  File "<frozen importlib._bootstrap>", line 488, in _call_with_frames_removed
  File "/config/custom_components/button_plus/__init__.py", line 11, in <module>
    from custom_components.button_plus.buttonplushub import ButtonPlusHub
  File "/config/custom_components/button_plus/buttonplushub.py", line 6, in <module>
    from config.custom_components.button_plus.button_plus_api.local_api_client import LocalApiClient
ModuleNotFoundError: No module named 'config.custom_components'

@Al3xand3R360
Copy link
Author

Don't know if it helps, but I'm updating from version 0.0.8 straight to 0.0.11

@nvdweem
Copy link

nvdweem commented Mar 25, 2024

The No module named 'config.custom_components' is the same error that I reported on the pull-request:
#52 (comment)

@P-Storm
Copy link
Contributor

P-Storm commented Mar 25, 2024

The last part of the stacktrace is pointing to our code:

button_plus.button_plus_api.local_api_client import LocalApiClient
ModuleNotFoundError: No module named 'config.custom_components

Sounds like a way forward. Also big confusion why I don't have this problem with the code on my instance.

@koenhendriks
Copy link
Owner

@Al3xand3R360 Could you trie manually deleting the the entire integration (custom_component) and also removing the entries from the .storage/core.config and .storage/core.config_entries and maybe check .storage/core.devices_registry as well?

I think your setup got corrupted a bit...

@wimjanse
Copy link
Contributor

I also tried a direct upgrade from 0.0.8 to 0.0.11, same error:
No module named “config.custom _components” with same stack dump as Al3xand3R360

@wimjanse
Copy link
Contributor

wimjanse commented Mar 25, 2024

I (manually) changed lines 6/7/8 in buttonplushub.py from

from config.custom_components.button_plus.button_plus_api.local_api_client import LocalApiClient
from config.custom_components.button_plus.button_plus_api.model import ConnectorEnum, DeviceConfiguration
from config.custom_components.button_plus.const import DOMAIN, MANUFACTURER

to

from .button_plus_api.local_api_client import LocalApiClient
from .button_plus_api.model import ConnectorEnum, DeviceConfiguration
from .const import DOMAIN, MANUFACTURER

with these changes to v0.0.11, I got rid off the errors and the integration starts normally - and I do see the devices in the integration overview.

I do get an error message, as follows:

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 350, in _async_setup_platform
    await asyncio.shield(awaitable)
  File "/config/custom_components/button_plus/number.py", line 37, in async_setup_entry
    _LOGGER.info(f"Current version {hub.config.info.firmware} doesn't support the brightness, it must be at least firmware version {min_version}")
                                                                                                                                    ^^^^^^^^^^^
NameError: name 'min_version' is not defined

Sorry for putting this all in a comment message, will have to learn how to use git commands.

@koenhendriks
Copy link
Owner

@P-Storm seems like you might need to use relative mapping in the imports?

@roodbaard80
Copy link

roodbaard80 commented Mar 25, 2024

Same issue here, I upgraded from version 0.9 and now get this error:

Logger: homeassistant.setup
Source: setup.py:296
First occurred: 21:52:45 (1 occurrences)
Last logged: 21:52:45

Setup failed for custom integration 'button_plus': Unable to import component: No module named 'config.custom_components'
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/setup.py", line 296, in _async_setup_component
component = await integration.async_get_component()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/loader.py", line 894, in async_get_component
comp = self.get_component()
^^^^^^^^^^^^^^^^^^^^
File "/usr/src/homeassistant/homeassistant/loader.py", line 921, in get_component
ComponentProtocol, importlib.import_module(self.pkg_path)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.12/importlib/init.py", line 90, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "", line 1387, in _gcd_import
File "", line 1360, in _find_and_load
File "", line 1331, in _find_and_load_unlocked
File "", line 935, in _load_unlocked
File "", line 995, in exec_module
File "", line 488, in _call_with_frames_removed
File "/config/custom_components/button_plus/init.py", line 11, in
from custom_components.button_plus.buttonplushub import ButtonPlusHub
File "/config/custom_components/button_plus/buttonplushub.py", line 6, in
from config.custom_components.button_plus.button_plus_api.local_api_client import LocalApiClient
ModuleNotFoundError: No module named 'config.custom_components'

@P-Storm
Copy link
Contributor

P-Storm commented Mar 25, 2024

@P-Storm seems like you might need to use relative mapping in the imports?

Sounds like you're right, I didn't look that big into the package mapping of python. But this looks like it is a part of the problem indeed. Will look into the code where this is a problem.

@P-Storm
Copy link
Contributor

P-Storm commented Mar 25, 2024

I (manually) changed lines 6/7/8 in buttonplushub.py from

from config.custom_components.button_plus.button_plus_api.local_api_client import LocalApiClient
from config.custom_components.button_plus.button_plus_api.model import ConnectorEnum, DeviceConfiguration
from config.custom_components.button_plus.const import DOMAIN, MANUFACTURER

to

from .button_plus_api.local_api_client import LocalApiClient
from .button_plus_api.model import ConnectorEnum, DeviceConfiguration
from .const import DOMAIN, MANUFACTURER

with these changes to v0.0.11, I got rid off the errors and the integration starts normally - and I do see the devices in the integration overview.

I do get an error message, as follows:

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 350, in _async_setup_platform
    await asyncio.shield(awaitable)
  File "/config/custom_components/button_plus/number.py", line 37, in async_setup_entry
    _LOGGER.info(f"Current version {hub.config.info.firmware} doesn't support the brightness, it must be at least firmware version {min_version}")
                                                                                                                                    ^^^^^^^^^^^
NameError: name 'min_version' is not defined

Sorry for putting this all in a comment message, will have to learn how to use git commands.

The module importing I'm fixing. The last error you reported, it seems that your Button+ firmware is lower than version 1.11. To use this you have to update this. It shouldn't fail, and I'm repairing that, but that is why this is reporting the error.

So @wimjanse please double check if you have the latest firmware version.

@P-Storm
Copy link
Contributor

P-Storm commented Mar 25, 2024

@P-Storm seems like you might need to use relative mapping in the imports?

Sounds like you're right, I didn't look that big into the package mapping of python. But this looks like it is a part of the problem indeed. Will look into the code where this is a problem.

It seems that the auto generate does include the config.custom_components and not choosing to make it relative. That I didn't see and broke some stuff. Added a new PR.

@wimjanse
Copy link
Contributor

@P-Storm
I do confirm both my B+’s are on 1.11 firmware.
min_version is not defined in number.py, I think you are missing an import.

@P-Storm
Copy link
Contributor

P-Storm commented Mar 26, 2024

@P-Storm I do confirm both my B+’s are on 1.11 firmware. min_version is not defined in number.py, I think you are missing an import.

Can you share your /config? I didn't have the variable defined, and have to check what is going wrong in the check itself. The error it throws is that the variable was not defined, I have also added this in the pull request #54. (sorry if I have already your config, but best way to reproduce these errors is the current config)

@wimjanse
Copy link
Contributor

Herewith the configs of both B+'s

[button149.json](https://github.com/koenhendriks/ha-button-plus/files/14754806/button149.json)

and

[button151.json](https://github.com/koenhendriks/ha-button-plus/files/14754814/button151.json)

@wimjanse
Copy link
Contributor

Don't know if that went alright with the triple `, so here without:

button149.json
button151.json

@P-Storm
Copy link
Contributor

P-Storm commented Mar 26, 2024

Don't know if that went alright with the triple `, so here without:

button149.json button151.json

I have downloaded the files. And will look when I can work on them :)

@wimjanse
Copy link
Contributor

the "min_version" issue is (imho) not related to the config file.

Python complaints about a "not defined" variable.

min_version is defined in config_flow.py, but neither config_flow in general nor min_version in particular is imported in number.py .

Hope this solves the issue.

@P-Storm
Copy link
Contributor

P-Storm commented Mar 26, 2024

the "min_version" issue is (imho) not related to the config file.

Python complaints about a "not defined" variable.

min_version is defined in config_flow.py, but neither config_flow in general nor min_version in particular is imported in number.py .

Hope this solves the issue.

Maybe I explained it wrong. The min_version was a variable that I was forgetting to include. See the changes on this PR:

@P-Storm
Copy link
Contributor

P-Storm commented Apr 3, 2024

@wimjanse @roodbaard80 @Al3xand3R360 sorry for the notification, but the newest release is available: https://github.com/koenhendriks/ha-button-plus/releases/tag/0.0.12 . Ofcourse, it can have errors, but it fixes as far as I know the mentioned items.

@roodbaard80
Copy link

Just upgrade from 0.9 to 0.12 and I can confirm that the issue is solved for me.
Thanks!
I do get a different warning in the HA log, but will create a separate issue for that.

@koenhendriks
Copy link
Owner

if 1 more (@wimjanse or @Al3xand3R360) can confirm this solves the issue I'll close this.

@wimjanse
Copy link
Contributor

wimjanse commented Apr 4, 2024

I had v0.08 running, removed both devices from the Button+ integration, which then also removed the integration itself.

Installed v0.12 and (manually) added both B+'s, everything looks ok, issues are gone. (I did get same warning as @roodbaard80 , will mentioned that in his separate issue.

For me, this issue can be closed.

@koenhendriks
Copy link
Owner

Closing this as of PR #54

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants