-
-
Notifications
You must be signed in to change notification settings - Fork 30.7k
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
Create bound callback_message_received method for handling mqtt callbacks #117951
Conversation
Hey there @emontnemery, @bdraco, mind taking a look at this pull request as it has been labeled with an integration ( Code owner commandsCode owners of
|
Let's see how useful coderabbit is... |
@coderabbitai review |
Actions PerformedReview triggered.
|
Warning Rate Limit Exceeded@bdraco has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 57 minutes and 44 seconds before requesting another review. How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (invoked as PR comments)
Additionally, you can add CodeRabbit Configration File (
|
Going to do performance testing now |
self._attr_extra_state_attributes = filtered_dict | ||
else: | ||
_LOGGER.warning("JSON result was not a dictionary") | ||
|
||
|
||
class MqttAvailability(Entity): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should probably make this MqttAvailabilityMixin
as the linters will treat it a bit differently. But thats for another PR
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@@ -401,6 +402,7 @@ class MqttAttributes(Entity): | |||
"""Mixin used for platforms that support JSON attributes.""" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should probably make this MqttAttributesMixin
as the linters will treat it a bit differently. But thats for another PR
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thnx, all looks good! |
Proposed change
The current coding style for handling call backs of MQTT messages uses multiple wrappers on inner functions.
This PR creates class bound callback methods for handling mqtt callbacks and introduces a mixin that can be used to create a new call back instead. It is expected this rework approach will gain performance and save memory.
This PR implements the new helper for the
sensor
andbinary_sensor
. Other platforms will follow:alarm_control_panel
: Refactor mqtt callbacks for alarm_control_panel #118037climate
andwater_heater
: Refactor mqtt callbacks for climate and water_heater #118040camera
,event
,image
: Rework mqtt callbacks for camera, image and event #118109cover
: Refactor mqtt callbacks for cover #118044device_tracker
: Rework mqtt callbacks for device_tracker #118110fan
: Rework mqtt callbacks for fan #118115humidifier
: Refactor mqtt callbacks for humidifier #118116lawn_mower
: Refactor mqtt callbacks for lawn_mower #118117lock
: Refactor mqtt callbacks for lock #118118number
: Refactor mqtt callbacks for number #118119select
: Refactor mqtt callbacks for select platform #118121siren
: Refactor mqtt callbacks for siren #118125switch
: Refactor mqtt callbacks for switch #118127text
: Refactor mqtt callbacks for text #118130update
: Refactor mqtt callbacks for update platform #118131vacuum
: Refactor mqtt callbacks for vacuum #118137valve
: Refactor mqtt callbacks for valve #118140light
with basic, json, and template schema: Refactor mqtt callbacks for light basic, json and template schema #118113Type of change
Additional information
Checklist
ruff format homeassistant tests
)If user exposed functionality or configuration variables are added/changed:
If the code communicates with devices, web services, or third-party tools:
Updated and included derived files by running:
python3 -m script.hassfest
.requirements_all.txt
.Updated by running
python3 -m script.gen_requirements_all
..coveragerc
.To help with the load of incoming pull requests: