Update NSAPI to version 3.0.0#30599
Conversation
|
I have updated both manifest file and requirements_all, however running either |
|
Could you elaborate a bit on the syntax error you've received? |
|
According to the CI is $ black homeassistant/components/nederlandse_spoorwegen/sensor.pyshould do the job. |
Ran the command, it says: Indeed, the file has not been modified by black. |
When running script.hassfest, it says: For script.gen_requirements_all: Python is not my forte, I'm trying to solve it |
|
@YarmoM Looks like you haven't set up your development environment correctly since it is missing dependencies. For more information on how to set up a local development environment, see: https://developers.home-assistant.io/docs/en/development_environment.html |
|
Did the "Set up Development Environment" again, noticed I forgot to run Ran both scripts, first one returned zero invalid integrations and second ran without output. --EDIT--- |
|
CI says to run ---UPDATE--- Can we ask the CI to run again? ---UPDATE--- |
|
Ok, this is getting strange. So I I run I run I run I'm not sure how to solve this. ---UPDATE--- |
amelchio
left a comment
There was a problem hiding this comment.
Looks good, let me just propose a couple of cleanups.
Also, this seems like a breaking change so you should fill out that section of the PR template.
|
Agreed on all accounts. This PR started as a simple fix to get it working again as soon as possible, but the more I look at the code, the more it begs for some improvements. Alright, let's do this the correct way. Question: how do you feel about the same sensor being able to produce different outputs? This sensor currently reports on the next train departure. This should always happens when you input a departure station and an destination station. Now, let's say functionality gets added that detects whether you only inputted a departure station. The code notices this and goes into "disruption mode", giving feedback on whether something has happened at that station. Technically, this is easy, but it does not follow the "1 component 1 function" principle. How do you feel about this? Or should this be a separate sensor? |
| attributes["departure_time_actual"] = self._trips[ | ||
| 0 | ||
| ].departure_time_planned.strftime("%H:%M") |
There was a problem hiding this comment.
Why do you put departure_time_planned into departure_time_actual? It is already in departure_time_planned so I don't see that you are adding any new information, only duplication.
There was a problem hiding this comment.
This made most sense to me, mainly 2 reasons:
- it is named "actual" so we need to get the actual departure time, this could either be the planned time or a delayed time but in all cases should the "actual" time be the time the train will depart;
- this is a conditional statement that needs to be made at some point. If we set "actual" to None, later you must first check if "actual" is none, if so take "planned", if not take "actual".
I would prefer to not go back entirely to the old way so I propose two solutions:
- we keep two departure times (requiring a conditional later on) but then "actual" needs to be refactored because that name is misleading, or
- we switch to a single departure time, there's already a "delayed" Boolean so that gives you most of the info needed.
Or third solution, we keep this. "Planned" is a reference time, "actual" is the actual time whether planned or delayed.
There was a problem hiding this comment.
Fixes and enhancements should not go into the same PR. Please limit the attribute changes to those required for the API update (if any).
It is fine to submit further PRs with the remaining proposals.
| attributes["arrival_time_actual"] = self._trips[ | ||
| 0 | ||
| ].arrival_time_planned.strftime("%H:%M") |
|
Sorry for being a bit terse. I have had only little time for review the last couple of days and thought you might like a quick response even if it was short. About your question, the current configuration is in a |
No problemo, sir! Thank you for your time and dedication and I did appreciate a quick reply so that I could get to work! Thanks for the |
amelchio
left a comment
There was a problem hiding this comment.
All right, let's go with this. Thank you for your persistence!
|
Thank you again for your time reviewing this PR, your effort is much appreciated! |
Breaking Changes:
The
nederlandse_spoorwegensensor now requires a single API token instead of username and password credentials.The following
platformattributes are renamed for consistency withtimenaming:departure_platformbecomesdeparture_platform_planneddeparture_platform_changedbecomesdeparture_platform_actualarrival_platformbecomesarrival_platform_plannedarrival_platform_changedbecomesarrival_platform_actualDescription:
The Nederlandse Spoorwegen API has recently changed and so has nsapi, the dependency home-assistant uses to communice with said API. This PR bumps the nsapi version to 3.0.0 and fixes some of its breaking changes.
Related issue (if applicable): fixes #26622
Pull request with documentation for home-assistant.io (if applicable): home-assistant/home-assistant.io#11700
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: