-
-
Notifications
You must be signed in to change notification settings - Fork 34.6k
Add number
platform for LED brightness to air-Q
#145385
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
Add number
platform for LED brightness to air-Q
#145385
Conversation
Hey there @dl2080, mind taking a look at this pull request as it has been labeled with an integration ( Code owner commandsCode owners of
|
7010337
to
311af0b
Compare
Please take a look at the requested changes, and use the Ready for review button when you are done, thanks 👍 |
57203d9
to
bb21fa0
Compare
bb21fa0
to
4fc0501
Compare
this PR is currently waiting for #146169 |
4fc0501
to
f69d299
Compare
I believe, I addressed every comment, @joostlek. |
353f466
to
b703a52
Compare
number
platform for LED brightnessnumber
platform for LED brightness to air-Q
7229533
to
43a71f7
Compare
43a71f7
to
df7c9d4
Compare
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.
As discussed on discord, the tests shouldn't touch hass.data and instead test the state via the state machine
I had added this `usefixtures("mock_setup_entry")` by accident
Instead of explicitly patching calls to `aioairq.AirQ` methods, patch out the whole class, as imported either in the coordinator or the config flow, some of its most used methods with sensible defaults, and then only modify the mocks when necessary
Instead of explicitly patching each method, create a fixture that patches the whole class with an AsyncMock and some meaningful defaults for most used methods. Then patch only where and when needed
Brightness is fetched by `AirQCoordinator` in `_async_update_data` and is expressed in %
df7c9d4
to
85de44d
Compare
async def setup_platform(hass: HomeAssistant) -> None: | ||
"""Load AirQ integration. | ||
This function does not patch AirQ itself, rather it depends on being | ||
run in presence of `mock_coordinator_airq` fixture, which patches calls | ||
by `AirQCoordinator.airq`, which are done under `async_setup`. | ||
""" | ||
config_entry = MockConfigEntry( | ||
domain=DOMAIN, data=TEST_USER_DATA, unique_id=TEST_DEVICE_INFO["id"] | ||
) | ||
config_entry.add_to_hass(hass) | ||
|
||
# The patching is now handled by the mock_coorinator_airq fixture. | ||
# We just need to load the component. | ||
assert await hass.config_entries.async_setup(config_entry.entry_id) | ||
await hass.async_block_till_done() |
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.
This is something for __init__.py
TEST_USER_DATA = { | ||
CONF_IP_ADDRESS: "192.168.0.0", | ||
CONF_PASSWORD: "password", | ||
} | ||
TEST_DEVICE_INFO = DeviceInfo( | ||
id="id", | ||
name="name", | ||
model="model", | ||
sw_version="sw", | ||
hw_version="hw", | ||
) | ||
TEST_DEVICE_DATA = {"co2": 500.0, "Status": "OK"} | ||
TEST_BRIGHTNESS = 42 |
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.
And this for const.py
Co-authored-by: Joost Lekkerkerker <joostlek@outlook.com>
closing this because I somehow botched the history of the remote branch from which the PR is open, will open a new one, sorry for proliferating them |
Proposed change
Each air-Q device is equipped with 2 LED strips that function as LED level indicators / bar graphs for two (configurable) sensors. This PR exposes a single
number
entity for eachairq
device, allowing to set the brightness of both strips simultaneously.This is the changes to the backend
aioairq
package that permit such brightness control.Type of change
Additional information
number
platform forairq
integration home-assistant.io#39129Checklist
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
.To help with the load of incoming pull requests: