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

Two B+'s, automation assigned to B+ nr. 1 is also triggered by B+ nr. 2 #37

Closed
wimjanse opened this issue Jan 15, 2024 · 4 comments · Fixed by #38
Closed

Two B+'s, automation assigned to B+ nr. 1 is also triggered by B+ nr. 2 #37

wimjanse opened this issue Jan 15, 2024 · 4 comments · Fixed by #38
Assignees
Labels
bug Something isn't working

Comments

@wimjanse
Copy link
Contributor

Describe the bug
I added first B+ with ID 45_a450 to HA.
Then added second B+ with ID 45_a5d0.
I created an automation for lowering my Luxaflex screens, made sure that this automation is triggered by button/btn_45a450/button/6 (checked with MQTT-explorer).
Same automation is triggered when clicking button from second B+ (ID 45_a5d0).
(This is done with Button+ integration v0.0.6 installed, integration reloaded and devices re-added)

To Reproduce

  • Add B+ no.1 and B+ no.2
  • Create automation for B+ nr. 1, button 6 (check for proper ID of this Button)
  • Reload automation YAML's
  • Click button 6 on B+ no.1, automation is triggered -> ok, is expected behaviour
  • Click button 6 on B+ no.2, automation is triggered -> not ok, no automation is assigned to this button

Expected behavior
Different B+'s with different ID's not to influence each-other, not to trigger each-others actions.

Automation:
alias: B+LuxStdkOpen
description: ""
trigger:

  • platform: state
    entity_id:
    • button.btn_45a450_6
      condition: []
      action:
  • service: scene.turn_on
    metadata: {}
    target:
    entity_id: scene.std_open
    mode: single

No automation exists for B+ with id 45_a5d0 on button-6

@wimjanse wimjanse added the bug Something isn't working label Jan 15, 2024
@koenhendriks
Copy link
Owner

Can you check for me what MQTT topics are on the Button 6 inside the web interface of both Button+ devices? It should look something like this:

image

The idea was to use the unique Button+ device in all MQTT topics and in the entity names of HASS so that this shouldn't happen.

Could you also check the debug log when the button is pressed? It should look something like this in the log if you press buttons:

2024-01-15 14:53:58.387 DEBUG (MainThread) [custom_components.button_plus.coordinator] Received message on topic buttonplus/btn_4967c8/button/6/click: press
2024-01-15 14:53:58.388 DEBUG (MainThread) [custom_components.button_plus.button] async press from mqtt button: 6
2024-01-15 14:54:34.874 DEBUG (MainThread) [custom_components.button_plus.coordinator] Received message on topic buttonplus/btn_4967c8/button/4/click: press
2024-01-15 14:54:34.875 DEBUG (MainThread) [custom_components.button_plus.button] async press from mqtt button: 4
2024-01-15 14:54:35.808 DEBUG (MainThread) [custom_components.button_plus.coordinator] Received message on topic buttonplus/btn_4967c8/button/5/click: press
2024-01-15 14:54:35.809 DEBUG (MainThread) [custom_components.button_plus.button] async press from mqtt button: 5

@koenhendriks koenhendriks added the need more info Further information is requested label Jan 15, 2024
@wimjanse
Copy link
Contributor Author

From MQTT-Explorer
B+ with ID 45a450, click button 6 publishes: buttonplus/btn_45a450/button/6/click (press)
B+ with ID 45a5d0, click button 6 publishes: buttonplus/btn_45a5d0/button/6/click (press)

From webinterfaces: see attached files 45a450.png en 45a5d0.png

45a450 45a5d0

Debug started, each button 6 clicked ONCE:

debug log:

2024-01-15 16:50:33.921 WARNING (SyncWorker_3) [homeassistant.loader] We found a custom integration button_plus which has not been tested by Home Assistant. This component might cause stability problems, be sure to disable it if you experience issues with Home Assistant
2024-01-15 16:50:33.921 WARNING (SyncWorker_3) [homeassistant.loader] We found a custom integration hacs which has not been tested by Home Assistant. This component might cause stability problems, be sure to disable it if you experience issues with Home Assistant
2024-01-15 16:50:33.921 WARNING (SyncWorker_3) [homeassistant.loader] We found a custom integration mass which has not been tested by Home Assistant. This component might cause stability problems, be sure to disable it if you experience issues with Home Assistant
2024-01-15 16:50:33.921 WARNING (SyncWorker_3) [homeassistant.loader] We found a custom integration browser_mod which has not been tested by Home Assistant. This component might cause stability problems, be sure to disable it if you experience issues with Home Assistant
2024-01-15 16:50:33.921 WARNING (SyncWorker_3) [homeassistant.loader] We found a custom integration lovelace_gen which has not been tested by Home Assistant. This component might cause stability problems, be sure to disable it if you experience issues with Home Assistant
2024-01-15 16:50:33.922 WARNING (SyncWorker_3) [homeassistant.loader] We found a custom integration localtuya which has not been tested by Home Assistant. This component might cause stability problems, be sure to disable it if you experience issues with Home Assistant
2024-01-15 16:50:33.922 WARNING (SyncWorker_3) [homeassistant.loader] We found a custom integration scheduler which has not been tested by Home Assistant. This component might cause stability problems, be sure to disable it if you experience issues with Home Assistant
2024-01-15 16:50:37.214 ERROR (MainThread) [homeassistant.components.button] Error adding entities for domain button with platform button_plus
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 507, in async_add_entities
    await asyncio.gather(*tasks)
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 563, in _async_add_entity
    entity.add_to_platform_start(
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1250, in add_to_platform_start
    raise HomeAssistantError(
homeassistant.exceptions.HomeAssistantError: Entity 'button.btn_45a450_0' cannot be added a second time to an entity platform
2024-01-15 16:50:37.215 ERROR (MainThread) [homeassistant.components.text] Error adding entities for domain text with platform button_plus
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 507, in async_add_entities
    await asyncio.gather(*tasks)
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 563, in _async_add_entity
    entity.add_to_platform_start(
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1250, in add_to_platform_start
    raise HomeAssistantError(
homeassistant.exceptions.HomeAssistantError: Entity 'text.label_btn_45a450_0' cannot be added a second time to an entity platform
2024-01-15 16:50:37.216 ERROR (MainThread) [homeassistant.components.button] Error while setting up button_plus platform for button
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 368, in _async_setup_platform
    await asyncio.gather(*pending)
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 507, in async_add_entities
    await asyncio.gather(*tasks)
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 563, in _async_add_entity
    entity.add_to_platform_start(
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1250, in add_to_platform_start
    raise HomeAssistantError(
homeassistant.exceptions.HomeAssistantError: Entity 'button.btn_45a450_0' cannot be added a second time to an entity platform
2024-01-15 16:50:37.217 ERROR (MainThread) [homeassistant.components.text] Error while setting up button_plus platform for text
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 368, in _async_setup_platform
    await asyncio.gather(*pending)
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 507, in async_add_entities
    await asyncio.gather(*tasks)
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 563, in _async_add_entity
    entity.add_to_platform_start(
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1250, in add_to_platform_start
    raise HomeAssistantError(
homeassistant.exceptions.HomeAssistantError: Entity 'text.label_btn_45a450_0' cannot be added a second time to an entity platform
2024-01-15 16:53:24.918 DEBUG (MainThread) [custom_components.button_plus.coordinator] Received message on topic buttonplus/btn_45a450/button/6/click: press
2024-01-15 16:53:24.919 DEBUG (MainThread) [custom_components.button_plus.coordinator] Received message on topic buttonplus/btn_45a450/button/6/click: press
2024-01-15 16:53:24.919 DEBUG (MainThread) [custom_components.button_plus.button] async press from mqtt button: 6
2024-01-15 16:53:24.919 DEBUG (MainThread) [custom_components.button_plus.button] async press from mqtt button: 6
2024-01-15 16:53:27.632 DEBUG (MainThread) [custom_components.button_plus.coordinator] Received message on topic buttonplus/btn_45a5d0/button/6/click: press
2024-01-15 16:53:27.632 DEBUG (MainThread) [custom_components.button_plus.coordinator] Received message on topic buttonplus/btn_45a5d0/button/6/click: press
2024-01-15 16:53:27.633 DEBUG (MainThread) [custom_components.button_plus.button] async press from mqtt button: 6
2024-01-15 16:53:27.633 DEBUG (MainThread) [custom_components.button_plus.button] async press from mqtt button: 6
2024-01-15 16:53:27.634 WARNING (MainThread) [homeassistant.components.automation.b_luxstdkopen] B+LuxStdkOpen: Already running

home-assistant_button_plus_2024-01-15T15-53-28.960Z.log

@casparz
Copy link

casparz commented Jan 16, 2024

Could this be the problem?
https://github.com/koenhendriks/ha-button-plus/blob/cc0cc2ce1fba503a8e35a51b5a73e96787aea70e/custom_components/button_plus/coordinator.py#L28C1-L28C65
More specifically, the first +? I think that should be the hub-id
self._mqtt_topic_buttons = "buttonplus/+/button/+/click"

@koenhendriks koenhendriks linked a pull request Jan 18, 2024 that will close this issue
@koenhendriks koenhendriks removed the need more info Further information is requested label Jan 18, 2024
@koenhendriks
Copy link
Owner

Thanks for the issue details @wimjanse.

@casparz was right here and @P-Storm has already made a PR that fixes this bug. I'm about to merge and release 0.0.7

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.

3 participants