Conversation
added 2 commits
April 13, 2018 18:31
pvizeli
reviewed
Apr 14, 2018
| return | ||
|
|
||
| @Throttle(MIN_TIME_BETWEEN_UPDATES) | ||
| async def _fetch_data(): |
Member
There was a problem hiding this comment.
Expose this as normal member variable, So It don't create a function every 1min that maybe not used and need cleanup from garbridge collector.
| self._device_state_attributes['estimated_annual_consumption'] = \ | ||
| data['meteringPointData']['estimatedAnnualConsumption'] | ||
|
|
||
| def _find_current_price(): |
Member
There was a problem hiding this comment.
If you export the other, you can also export this
| (self._newest_data_timestamp - now).total_seconds()/3600 < 12 | ||
| or not self._is_available): | ||
| _LOGGER.debug("Asking for new data.") | ||
| await _fetch_data() |
Member
There was a problem hiding this comment.
Optional, since you us Throttle, you could call this every time.
| self._device_state_attributes['estimated_annual_consumption'] =\ | ||
| data['meteringPointData']['estimatedAnnualConsumption'] | ||
| _find_current_price() | ||
| self._is_available = _find_current_price() |
Member
There was a problem hiding this comment.
_find_currect_price() should now return True/false
houndci-bot
reviewed
Apr 14, 2018
| for key, price_total in self._tibber_home.price_total.items(): | ||
| price_time = dt_util.as_utc(dt_util.parse_datetime(key)) | ||
| price_total = round(price_total, 3) | ||
| time_diff = (now - price_time).total_seconds()/60 |
Member
Author
|
@pvizeli thanks for your comments. Always good review from you 👍 |
Member
Author
|
@pvizeli Is this good now? |
pvizeli
approved these changes
Apr 20, 2018
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description:
Set the availability status of the Tibber sensor.
Fetching the data in a smarter way.
Checklist:
tox. Your PR cannot be merged unless tests pass