-
-
Notifications
You must be signed in to change notification settings - Fork 32.2k
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
vesync new platform of binary sensor #134221
base: dev
Are you sure you want to change the base?
Conversation
Hey there @markperdue, @webdjoe, @TheGardenMonkey, mind taking a look at this pull request as it has been labeled with an integration ( Code owner commandsCode owners of
|
@iprak I am interested in your feedback on the approach of this platform type. As well if you can spot why online sensor goes unavailable I am open to it! I have to add some debug lines to figure that out. |
Looks good, some comments:
|
|
Putting this ready for review, while I would like coordinator to go first that is a quick update to this PR once that is merged. In the meantime it can get some eyes. |
Please take a look at the requested changes, and use the Ready for review button when you are done, thanks 👍 |
I like this approach of adding the sensor based on presence of description.key. Can |
Co-authored-by: Joost Lekkerkerker <[email protected]>
Would it maybe be nice to have a group on discord to chat on? |
Happy to have you join. iprak and I have been chatting directly on discord. |
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.
there's a merge conflict
VeSyncBinarySensor(dev, description, coordinator) | ||
for dev in devices | ||
for description in SENSOR_DESCRIPTIONS | ||
if rgetattr(dev, description.key) is not 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.
I find the use of key as means to check attribute presence cryptic. Why not use device type based check so that we generate sensors for known cases?
It looks like a lot more attributes are populated in build_humid_dict with default value but I definitely know that my humidifier Classic 200
does not support any of them.
However it could be tat some attributes are common but someone would need to verify that fact.
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.
My theory on this types of data and sensor.py is that datapoints vary by device. Different humidifiers have different data points for example. By checking for the datapoint we don't need to check against every potential child class defined. We are agnostic and data focused so if a new humidifier type is added to the child library no update needed beyond bumping the library. Thoughts?
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.
Thinking more on this - maybe I move that same logic to a exists_fn? Still with the reget but within the exists lambda. That way it is flexible depending on what is needed.
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.
The datapoint approach is what we would want but I don't have other devices to confirm or deny my theory. Let us go with it. The custom vesync integration also seems to do something similar so there must some prior validation.
As for the key, isn't that what is being read in the value lambda. What if we called it data_path
or something and got rid of is_on lambda?
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.
is_on is binary sensor native name: https://developers.home-assistant.io/docs/core/entity/binary-sensor
Now that I look at it again I think I leave as is. Not sure an easier way exists to use the is on value to safely check it?
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.
To confirm do you have changes requested or are you okay with approving as is?
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.
I would loved to see key and value lambda be combined since they seem to be using the same data path but I am okay with what we have.
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.
Got it. So combine in description and use the same value programmatically for "is_on". I will give it a go.
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 was just an idea. If we can have cases where key is one thing but the data returned is something, then we would want to keep what we have.
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 is possible that occurs but quick to make that change when/if it occurs. VScode is uploading the changes now. Should be up shortly - it takes forever.
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.
A few comments
Ready for another round of review. |
Proposed change
Added binary sensor platform, with items around humidifiers.
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.io
Vesync Binary Sensor home-assistant.io#37004
If the code communicates with devices, web services, or third-party tools:
The manifest file has all fields filled out correctly.
Updated and included derived files by running:
python3 -m script.hassfest
.New or updated dependencies have been added to
requirements_all.txt
.Updated by running
python3 -m script.gen_requirements_all
.For the updated dependencies - a link to the changelog, or at minimum a diff between library versions is added to the PR description.
To help with the load of incoming pull requests: