Add Derivative component#26456
Conversation
based on integration component remove left and right
(was'n saved)
|
Hi @afaucogney, It seems you haven't yet signed a CLA. Please do so here. Once you do that we will be able to review and accept this pull request. Thanks! |
|
Hi, this is my first PR for HomeAssistant, and I'm not a python dev. |
|
This platform should be called differentiation, not derivation. |
@JeffLIrion are you sure of this. I m an not English, but for me differentiation does not take in account the time (so the dx). What do you think ? |
|
|
Or else call it derivative. |
|
@tsvi as I said I m not either fluent in Python or homeassistant framework, so my test case always get 0 as the value to assert, so my test failed. However it seems to work in a real configuration.. I almost copy + adapt the code from integration, but have no clue what is wrong. Could you help me ? |
add test case fix test values still a prefix issue that should not
I fixed this, it was a question of rounding value. |
based on integration component remove left and right
(was'n saved)
Fix test issue with unit of measurement Co-Authored-By: Santobert <tobhaase@gmail.com>
|
Looking forward for the release. Very useful component. |
| unit_of_measurement, | ||
| ): | ||
| """Initialize the derivative sensor.""" | ||
| _LOGGER.warning("unit_of_measurement: %s", unit_of_measurement) |
|
|
||
| if unit_of_measurement is None: | ||
| self._unit_template = ( | ||
| f"{'' if unit_prefix is None else unit_prefix}{{}}/{unit_time}" |
There was a problem hiding this comment.
this is really unreadable. Please break it out into multiple statements.
balloob
left a comment
There was a problem hiding this comment.
This looks good. Ok to merge when final comments addressed and linting fixed.
@balloob thanks for the approval. I'm so young in python that I did succeed to mock the line that trigger the error handling. And this is required to achieve the expected coverage. For exemple line 104: I need a test that mock Decimal() to then throw a ValueError(). Could you give me an exemple, and then I will apply to other cases. |
|
In what case would |
Move ValueError to SyntaxError
I moved to SyntaxError |
|
@afaucogney you have a couple of unused imports, please take a look at the Linting errors to spot and remove them from your code. Thanks! |
|
@afaucogney Will you be finishing this PR? I would very much like to use it in my home automation If not, I can fork your fork, and finish it. |
…tant into feature/derivative
Hi @tkislan, thanks for your interest on my PR. I tried to fix some issue, if you think you may do better (I'm sure, cause I am a python novice), feel free to PR my branch, I will accept your contribution for sure ! |
- update doc link - migrate to general const import
|
@afaucogney please fix your failing tests :) |
Description:
Here is the derivation component based on integration component.
This sensor will be useful:
Pull request with documentation for home-assistant.io (if applicable): home-assistant/home-assistant.io#10323
Example entry for
configuration.yaml(if applicable):Checklist:
tox. Your PR cannot be merged unless tests passIf user exposed functionality or configuration variables are added/changed:
If the code communicates with devices, web services, or third-party tools:
python3 -m script.hassfest.requirements_all.txtby runningpython3 -m script.gen_requirements_all..coveragerc.If the code does not interact with devices: