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

Palazzetti power control #131833

Open
wants to merge 7 commits into
base: dev
Choose a base branch
from

Conversation

dotvav
Copy link
Contributor

@dotvav dotvav commented Nov 28, 2024

Proposed change

Add a number entity to Palazzetti to control the "combustion power" of the stove.

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:

@dotvav dotvav marked this pull request as ready for review November 28, 2024 16:59
self,
coordinator: PalazzettiDataUpdateCoordinator,
description: PalazzettiNumberEntityDescription,
entry_id: str,
Copy link
Contributor

Choose a reason for hiding this comment

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

not used

Comment on lines 25 to 26
MIN_POWER = 1
MAX_POWER = 5
Copy link
Contributor

Choose a reason for hiding this comment

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

why set those as const if they are only used once anyways?

Comment on lines 48 to 59
config_entry.runtime_data,
PalazzettiNumberEntityDescription(
key="combustion_power",
translation_key="combustion_power",
device_class=NumberDeviceClass.POWER_FACTOR,
native_min_value=MIN_POWER,
native_max_value=MAX_POWER,
native_step=1,
value_property="power_mode",
update_fn=client.set_power_mode,
),
config_entry.entry_id,
Copy link
Contributor

Choose a reason for hiding this comment

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

imo either you are planning for more entities here, in which case you should still make a list and iterate, or you might just as well hardcode it into the entity definition directly

{ATTR_ENTITY_ID: ENTITY_ID, "value": 1},
blocking=True,
)
mock_palazzetti_client.set_power_mode.assert_called_once_with(1)
Copy link
Contributor

Choose a reason for hiding this comment

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

maybe verify that the value did indeed change

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't think that I can do that. The client API is fully mocked and does not update its state.

Comment on lines 26 to 31
@dataclass(frozen=True, kw_only=True)
class PalazzettiNumberEntityDescription(NumberEntityDescription):
"""Describes Palazzetti number entity."""

value_property: str
update_fn: Callable[[int], Coroutine[Any, Any, None]]
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
@dataclass(frozen=True, kw_only=True)
class PalazzettiNumberEntityDescription(NumberEntityDescription):
"""Describes Palazzetti number entity."""
value_property: str
update_fn: Callable[[int], Coroutine[Any, Any, None]]

unused now

Copy link
Contributor

@zweckj zweckj left a comment

Choose a reason for hiding this comment

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

Thanks, LGTM 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants