koenhendriks / ha-button-plus Goto Github PK
View Code? Open in Web Editor NEWHome Assistant integration platform for Button+
License: GNU General Public License v3.0
Home Assistant integration platform for Button+
License: GNU General Public License v3.0
The buttons have a LED on the side and on the back, these should be added as light components in HA.
I have loaded the integration and it connects to the broker successfully. I have chosen to read the config from the IP of the device. Topics configured on the device are as follows:
buttonplus/wk1/button/2/label etc
Config is loaded to Home Assistant; labels as configured on device are visible in the integration.
Adjustments to labels are published to buttonplus/btn_45a424/button/2/label
Button presses in Home Assistant are not published
Adjustments to labels are published to buttonplus/wk1/button/2/label
Button presses in Home Assistant are published to buttonplus/wk1/button/2/state
Documentation should be added how the integrations maps entities to button+ buttons, leds and screen labels.
It should also document how the MQTT broker from Home Assistant is used and how to install and update it using HACS.
The Readme needs some polishing as well.
After upgrading the HA integration from version 0.9 to 0.12 I get this warning in the HA log:
Logger: homeassistant.components.number
Source: components/number/init.py:216
integration: Number (documentation, issues)
First occurred: 10:34:27 (1 occurrences)
Last logged: 10:34:27
custom_components.button_plus.number::ButtonPlusBrightness is overriding deprecated methods on an instance of NumberEntity, this is not valid and will be unsupported from Home Assistant 2022.10. Please report it to the custom integration author
Currently the config gets parsed from Json and is used directly with getters, for instance
config = json.loads(json_config)
device_name = config.get('core').get('name')
device_id = config.get('info').get('id')
A model should be created for the config format of the button plus according to the following json:
{
"info": {
"id": "btn_1111a1",
"mac": "FF:12:FF:34:56:F1",
"ipaddress": "192.168.1.1",
"firmware": "1.03",
"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": "DevButtonPlus",
"location": "Livingroom",
"invert": true,
"autobackup": true,
"brightnesslargedisplay": 100,
"brightnessminidisplay": 100,
"ledcolorfront": 0,
"ledcolorwall": 0,
"color": 0
},
"mqttbuttons": [
{
"id": 0,
"label": "display left",
"toplabel": "display label left",
"ledcolorfront": 0,
"ledcolorwall": 0,
"topics": []
},
{
"id": 1,
"label": "display right",
"toplabel": "display label right",
"ledcolorfront": 0,
"ledcolorwall": 0,
"topics": []
},
{
"id": 2,
"label": "Btn 1 left",
"toplabel": "Label 1 left",
"ledcolorfront": 0,
"ledcolorwall": 0,
"topics": []
},
{
"id": 3,
"label": "Btn 1 right",
"toplabel": "Label 1 right",
"ledcolorfront": 0,
"ledcolorwall": 0,
"topics": []
},
{
"id": 4,
"label": "Btn 2 left",
"toplabel": "Label 2 left",
"ledcolorfront": 0,
"ledcolorwall": 0,
"topics": []
},
{
"id": 5,
"label": "Btn 2 right",
"toplabel": "Label 2 right",
"ledcolorfront": 0,
"ledcolorwall": 0,
"topics": []
},
{
"id": 6,
"label": "Btn 3 left",
"toplabel": "Label 3 left",
"ledcolorfront": 0,
"ledcolorwall": 0,
"topics": []
},
{
"id": 7,
"label": "Btn 3 right",
"toplabel": "Label 3 right",
"ledcolorfront": 0,
"ledcolorwall": 0,
"topics": []
}
],
"mqttdisplays": [
{
"x": 0,
"y": 0,
"fontsize": 4,
"align": 0,
"width": 50,
"label": "Amsterdam",
"unit": "",
"round": 0,
"topics": [
{
"brokerid": "buttonplus",
"topic": "system/datetime/amsterdam",
"payload": "",
"eventtype": 15
}
]
},
{
"x": 0,
"y": 40,
"fontsize": 2,
"align": 0,
"width": 30,
"unit": "°C",
"round": 1,
"topics": [
{
"brokerid": "buttonplus",
"topic": "button/btn_4967c8/temperature",
"payload": "",
"eventtype": 15
}
]
}
],
"mqttbrokers": [
{
"brokerid": "buttonplus",
"url": "mqtt://mqtt.button.plus",
"port": 0,
"wsport": 0
}
],
"mqttsensors": [
{
"sensorid": 1,
"topic": {
"brokerid": "buttonplus",
"topic": "button/btn_4967c8/temperature",
"payload": "",
"eventtype": 18
},
"interval": 10
}
]
}
Current all PR are failing, because the brand is not in the custom domain. I would suggest to disable this check until we are ready to add this. @koenhendriks this will also help with auto completion of branches, and the mails of a PR failing in my inbox :)
Error: <Validation brands> failed: The repository has not been added as a custom domain to the brands repo (More info: https://hacs.xyz/docs/publish/include#check-brands )
When the integration gets removed from home assistant it keeps 'dirty' configuration from the devices and entities behind. This should be cleaned up.
This should be looked into using the async_unload_entry
in the main __init__.py
of the integration.
Should add some basic linter as a GH Action to have PRs checked.
#50 (comment)_
Describe the bug
I added first B+ with ID 45_a450 to HA, area: "Studeerkamer". Then added second B+ with ID 45_a5d0, during addition I see the Display and 3 BARS, already with area "Studeerkamer". When I make a change in area ("Huiskamer") during the addition of the second B+, also the first B+ changes to "Huiskamer"
To Reproduce
Steps to reproduce the behavior:
Expected behavior
Different areas for the two B+'s
Currently the entire base module with all lights, buttons and labels are added under 1 device.
For each entry (by ip) there should be multiple devices.
Devices should be split into:
See the following image for a current desired split for a full set of Button+ consisting out of 1 Display module and 3 bar modules:
Relates to #19
We should pre-fill an input with the retrieved MQTT broker url/ip but allow the user to override this.
Describe the bug
Removed earlier versions of B+ with ID btn_45a450 and B+ with ID btn_45a5d0.
Added B+ btn_45a450, checked log file, no warnings, no errors.
Added B+ btn_45a5d0, checked log file, following errors occur:
2024-01-22 12:11:33.794 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-22 12:11:33.819 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-22 12:11:33.825 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-22 12:11:33.834 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
Despite the errors, both B+'s are working properly (except earlier bug mentioned in #36, but this is area related only)
Values of the labels and top labels disappear after certain time (i guess 10 minutes). If I make the topics retain by publishing with MQTT explorer with the retian flag the value remains.
The config flow of the integration should start with giving the user 2 options:
Describe the bug
The display module has no default top label and regular label. They have dynamical labels that can be put on any x or y of the display. Currently by default 2 labels are added for each button bar, but this shouldn't happen for the display buttons.
To Reproduce
Steps to reproduce the behavior:
Expected behavior
Currently there is a hardcoded check to see if the endpoint is core-mosquitto
. This should be replaced by a better way of detecting if the broker configuration is externally available outside of home assistant.
Use MQTT to sync states between device and Home Assistant.
Reported by @nvdweem in a PR
Describe the bug
Grouping of the modules is weird for some users.
To Reproduce
Steps to reproduce the behavior:
Expected behavior
All modules are detached and seperate.
Additional context and/or debug log.
Requested files attached.
benchmark-config.json
woonkamer-config.json
slaapkamer-config.json
Originally posted by @nvdweem in #46 (comment)
It seem that entities do not get removed upon removal of the integration
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 1246, in add_to_platform_start
raise HomeAssistantError(
homeassistant.exceptions.HomeAssistantError: Entity 'text.label_btn_45a424_0' cannot be added a second time to an entity platform
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'
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
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:
No automation exists for B+ with id 45_a5d0 on button-6
The value of the entity in Home Assistant does not match the value it is set to.
Reproduction steps:
Currently the devices are hardcoded on button ids, but should be retrieved from the connectors part of the json config:
Types are defined as following:
1 -> BAR module
2 -> Dispay Module
{
"info": {
"connectors": [
{
"id": 0,
"type": 2
},
{
"id": 1,
"type": 1
},
{
"id": 2,
"type": 1
},
{
"id": 3,
"type": 1
}
]
}
}
The buttons have a display with two label options. These should be added as text components in HA.
The integration should create labels for the display (both top label and regular label) and these should be synced over MQTT with the integration.
Currently I've made a dev container branch on my own fork. When interested, I can share this. How are you developing it @koenhendriks ?
Fork branch can be found: https://github.com/P-Storm/ha-button-plus/tree/feat/vscode-dev-container
How to use?
Run Home Assistant developer env on port 9126
Python: Attach Local
After the update i manually enter Button+ device IP address to integrate button+ device but "Failed to connect, see log for more info" occours. Log:
Logger: custom_components.button_plus.config_flow
Quelle: custom_components/button_plus/config_flow.py:120
Integration: Button+ (Dokumentation, Probleme)
Erstmals aufgetreten: 11:06:19 (5 Vorkommnisse)
Zuletzt protokolliert: 11:12:03
button_plus Exception in login : 'brightnesslargedisplay' - traceback: Traceback (most recent call last): File "/config/custom_components/button_plus/config_flow.py", line 95, in async_step_manual device_config: DeviceConfiguration = DeviceConfiguration.from_json( ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/config/custom_components/button_plus/button_plus_api/model.py", line 262, in from_json core=Core.from_dict(data["core"]), ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/config/custom_components/button_plus/button_plus_api/model.py", line 114, in from_dict brightness_large_display=data["brightnesslargedisplay"], ~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^ KeyError: 'brightnesslargedisplay'
The light entities are currently removed from registering. The lights should be added back and be able to sync with the actual state of the Button+ device over MQTT.
Single Light entity
There should only be a single light entity per button has the device does not support controller the front and back individually (see issue N. 64 @ https://button.plus/support/issues)
See https://hacs.xyz/docs/publisher for docs
When adding the integration to HA and setting up the initial config I always get a message 'Failed to set up' when I try to fetch my button+ through the button.plus website.
I have uploaded the current config to the button.plus website.
What am I missing?
The log gives me this error:
Logger: homeassistant.config_entries
Source: config_entries.py:594
First occurred: 22:14:41 (9 occurrences)
Last logged: 22:50:27
Error setting up entry btn_4674c0 for button_plus
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/config_entries.py", line 594, in async_setup
result = await component.async_setup_entry(hass, self)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/config/custom_components/button_plus/init.py", line 26, in async_setup_entry
device_configuration: DeviceConfiguration = DeviceConfiguration.from_json(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/config/custom_components/button_plus/button_plus_api/model.py", line 259, in from_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
I was looking into the MQTT auto discovery. I found the following documentation: https://www.home-assistant.io/integrations/mqtt/#mqtt-discovery
Not sure how to implement it yet, but this is something for the future probably :)
The images / logo of button+ should be added to https://github.com/home-assistant/brands to ensure the integration UI looks correct without missing images.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.