+
Skip to content

Conversation

jbouwh
Copy link
Contributor

@jbouwh jbouwh commented Feb 13, 2025

Proposed change

Add initial MQTT subentry support for notify entities

In MVP is support for Notify entities. Not included yet is is availability support. This is planned with #138673

Type of change

  • Dependency upgrade
  • Bugfix (non-breaking change which fixes an issue)
  • New integration (thank you!)
  • New feature (which adds functionality to an existing integration)
  • Deprecation (breaking change to happen in the future)
  • Breaking change (fix/feature causing existing functionality to break)
  • Code quality improvements to existing code or addition of tests

Additional information

Checklist

  • The code change is tested and works locally.
  • Local tests pass. Your PR cannot be merged unless tests pass
  • There is no commented out code in this PR.
  • I have followed the development checklist
  • I have followed the perfect PR recommendations
  • The code has been formatted using Ruff (ruff format homeassistant tests)
  • Tests have been added to verify that the new code works.

If user exposed functionality or configuration variables are added/changed:

If the code communicates with devices, web services, or third-party tools:

  • The manifest file has all fields filled out correctly.
    Updated and included derived files by running: python3 -m script.hassfest.
  • New or updated dependencies have been added to requirements_all.txt.
    Updated by running python3 -m script.gen_requirements_all.
  • For the updated dependencies - a link to the changelog, or at minimum a diff between library versions is added to the PR description.

To help with the load of incoming pull requests:

@home-assistant
Copy link

Hey there @emontnemery, @bdraco, mind taking a look at this pull request as it has been labeled with an integration (mqtt) you are listed as a code owner for? Thanks!

Code owner commands

Code owners of mqtt can trigger bot actions by commenting:

  • @home-assistant close Closes the pull request.
  • @home-assistant rename Awesome new title Renames the pull request.
  • @home-assistant reopen Reopen the pull request.
  • @home-assistant unassign mqtt Removes the current integration label and assignees on the pull request, add the integration domain after the command.
  • @home-assistant add-label needs-more-information Add a label (needs-more-information, problem in dependency, problem in custom component) to the pull request.
  • @home-assistant remove-label needs-more-information Remove a label (needs-more-information, problem in dependency, problem in custom component) on the pull request.

@jbouwh jbouwh marked this pull request as draft February 13, 2025 15:46
@jbouwh jbouwh force-pushed the mqtt-notify-subentry branch 3 times, most recently from 22ac94e to f984795 Compare February 14, 2025 20:15
@jbouwh jbouwh marked this pull request as ready for review February 14, 2025 21:18
@frenck frenck modified the milestone: 2025.3.0b0 Feb 19, 2025
Copy link
Contributor

@emontnemery emontnemery left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some initial comments

Comment on lines +882 to +893
self._subentry_data = cast(
MqttSubentryData, deepcopy(dict(reconfigure_subentry.data))
)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interesting, should ConfigSubentryFlow be a generic? Maybe ConfigFlow and OptionFlow should also be generics?
(For separate PRs though)

@jbouwh jbouwh force-pushed the mqtt-notify-subentry branch from d335b16 to 21f5c1e Compare March 11, 2025 17:58
Comment on lines 100 to 119
MOCK_SUBENTRY_SENSOR_COMPONENT = {
"sensor_bla789": {
"platform": "sensor",
"name": "Test sensor",
"qos": 1,
"state_topic": "test-topic3",
"entity_picture": "https://example.com/sensor_bla789",
},
}

MOCK_SUBENTRY_LIGHT_COMPONENT = {
"light_bla0ab": {
"platform": "light",
"name": "Test light",
"qos": 1,
"command_topic": "test-topic4",
"schema": "basic",
"entity_picture": "https://example.com/light_bla0ab",
},
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't it a little bit weird to introduce things from the future like this? 🤔
Maybe in this PR do two notify entities, and then replace with or add other entities when they are supported?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

@emontnemery emontnemery left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A few more minor comments. This is starting to look really good 👍

@jbouwh jbouwh requested a review from emontnemery March 13, 2025 19:11
@jbouwh jbouwh requested a review from emontnemery March 14, 2025 10:38
Copy link
Contributor

@emontnemery emontnemery left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome, thanks a lot @jbouwh 👍

@emontnemery emontnemery added the noteworthy Marks a PR as noteworthy and should be in the release notes (in case it normally would not appear) label Mar 14, 2025
@jbouwh
Copy link
Contributor Author

jbouwh commented Mar 14, 2025

Thank you too!

@jbouwh jbouwh merged commit bd4d0ec into dev Mar 14, 2025
48 checks passed
@jbouwh jbouwh deleted the mqtt-notify-subentry branch March 14, 2025 13:00
},
"entity": {
"title": "Configure MQTT device \"{mqtt_device}\"",
"description": "Configure the basic {platform_label}entity settings{entity_name_label}",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like there are two space characters missing here around "entity settings"?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

They are there on purpose to allow inserting the platform and entity label if they are known, or to omit them if they are not available yet.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah OK, the spaces are added via the variables. We need to know that for proper translation, because in German there would be a hyphen in the middle of "Plattform-Entität".

Then I remove that hyphen as another translator was already faster and added one there.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah OK, the spaces are added via the variables. We need to know that for proper translation, because in German there would be a hyphen in the middle of "Plattform-Entität".

Then I remove that hyphen as another translator was already faster and added one there.

Right. I'd rather had proper working constant selectors, but we ended up here. The inserted variables will, if set take care of spaces.
Like:

afbeelding

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I went with:

"Konfiguriere die grundlegenden Einstellungen der {platform_label}Entität{entity_name_label}"

That should work with and without a platform inserted.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good!

@github-actions github-actions bot locked and limited conversation to collaborators Mar 15, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

by-code-owner cla-signed core has-tests integration: mqtt new-feature noteworthy Marks a PR as noteworthy and should be in the release notes (in case it normally would not appear) Quality Scale: platinum

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants

点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载