-
-
Notifications
You must be signed in to change notification settings - Fork 31.4k
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
Update Flick Electric API #133475
base: dev
Are you sure you want to change the base?
Update Flick Electric API #133475
Conversation
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.
Even though it was draft, I did a review.
Some remarks that we want to have in:
- We want to have tests for the entry migration. They are quite delicate, so we want it to do what we want
- Config flow requires 100% coverage
@property | ||
def extra_state_attributes(self): | ||
def extra_state_attributes(self) -> dict[str, Any] | None: | ||
"""Return the state attributes.""" | ||
return self._attributes | ||
|
||
async def async_update(self) -> None: | ||
"""Get the Flick Pricing data from the web service.""" | ||
if self._price and self._price.end_at >= utcnow(): | ||
return # Power price data is still valid | ||
|
||
async with asyncio.timeout(60): | ||
self._price = await self._api.getPricing() | ||
|
||
_LOGGER.debug("Pricing data: %s", self._price) | ||
|
||
self._attributes[ATTR_START_AT] = self._price.start_at | ||
self._attributes[ATTR_END_AT] = self._price.end_at | ||
for component in self._price.components: | ||
if component.charge_setter not in ATTR_COMPONENTS: | ||
_LOGGER.warning("Found unknown component: %s", component.charge_setter) | ||
continue | ||
|
||
self._attributes[component.charge_setter] = float(component.value) | ||
return { | ||
ATTR_START_AT: self.coordinator.data.start_at, | ||
ATTR_END_AT: self.coordinator.data.end_at, | ||
# TODO: Components | ||
} |
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.
Another remark that's not for this PR, but ideally we try to split out attributes into their own entities or use action responses for things that return large amounts of data.
Did you also discuss when the old API would be removed? We might do another patch release before the weekend, otherwise the next release would be 3 januari |
From the email thread:
I am almost there in terms of the library itself, just need to see the structure of the "components" section, I've asked James to help with a test account with active services (unfortunately the one provided was disconnected quite a while ago) 😊 |
Check! Let's try to get this in swiftly. Feel free to ping me on discord if you have questions or remarks! |
@joostlek this is now ready for review 😊 I still haven't been able to get a full end-to-end test done, hoping James can get me some UAT credentials which are active. However I am feeling fairly confident my changes should be functional based on the sample API responses he has sent me. |
@joostlek FYI James confirmed Jan release should be fine so don't worry too much about getting it in with the last minor release 😊 |
Proposed change
Updates integration for
flick_electric
due to downstream API being turned off.ZephireNZ/PyFlick#2
The main breaking change here is that we now have multiple accounts/services returned, so the config flow has been updated to take this into account. I have also added a migration so that users will be prompted to select an account when more than one exists.
This also comes with some QoL improvements to the integration:
Type of change
Additional information
Checklist
ruff format homeassistant tests
)If user exposed functionality or configuration variables are added/changed:
Documentation added/updated for www.home-assistant.ioIf 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: