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
Calculate _attr_native_value when no restore state and appliance is running in Whirlpool #88559
Calculate _attr_native_value when no restore state and appliance is running in Whirlpool #88559
Conversation
Hey there @abmantis, mind taking a look at this pull request as it has been labeled with an integration ( Code owner commandsCode owners of
|
move init at startup if _attr_native_value is None
Please take a look at the requested changes, and use the Ready for review button when you are done, thanks 👍 |
I believe the requested changes have been satisfied. What do I need to do to get this over the bar? |
Stuck? |
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.
Please address the comments in a new PR. Thanks!
if ( | ||
isinstance(self._attr_native_value, datetime) | ||
and abs(new_timestamp - self._attr_native_value) > timedelta(seconds=60) | ||
or self._attr_native_value is None |
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.
It's more efficient to start with the None
check as that is faster than isinstance
and Python conditions will short circuit.
await init_integration(hass) | ||
# restore from cache | ||
state = hass.states.get(entity_id) | ||
state.state = "unknown" |
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.
Should this be an assertion?
state.state = "unknown" | ||
|
||
state = await update_sensor_state(hass, entity_id, mock_sensor1_api) | ||
state.state = datetime.now().isoformat() |
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 too?
Proposed change
Currently, if the appliance is running when the integration is added (aka restore state is None), the time stamp will not be calculated until the appliance finishes a cycle.
This change will allow a time stamp to be set if the appliance is running when the integration is added.
Type of change
Additional information
Checklist
black --fast 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: