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
Add a feature to control away mode for the Phyn Plus device #5
Comments
I've started a forked branch to work on this feature. |
I have implemented this new feature in my forked branch and will submit prepare to submit a pull request to merge this new functionality into the integration. Note that for testing it required pointing adding my own github repository to HACs to install/download the updated integration. Then I also needed to adjust the manifest.json file to point to my forked repository for the modified aiophyn module and also to update the version number of that module for it to force HA to pull the newer aiophyn module with the updated method. I had trouble choosing the right icons to show for away mode. I ended up choosing the suitcase to signify AWAY (on) and home cirlce for HOME (off). It might be more clear to choose airplane for the AWAY (on) icon. An example of the UX showing the new switch is here @MizterB - let me know if you want me to work in a particular way to submit the pull request or have any other feedback. |
@opq8 - I don't actually have any of the addon sensors. I currently only have a single Phyn Plus device in each of my properties. I had debugged the aiophyn library that calls the Phyn API to determine the response data and derive the get_away_mode attributes. But I didn't take into account the possibility that it would not be included in the payload. I infer from your note that the phyn integration enumerates all sensors and the addons must not have an away mode. I will perhaps try two steps:
A couple of questions for you to perhaps clarify: without my fork, does Home Assistant show a device for each of your sensors (main and addon)? Are there any different, additional entities on the addon devices that I should be aware of? |
@opq8 - you said you implemented a work-around. Are you able to share with me where you get the error occurring? Is it during the initialization of the integration? I suspect its either In the device.py file (_update_away_mode method) which in turn is calling the API (line 141) or is it when retrieving the property value in device.py line 121 |
No problem. I didn't crack open the code to debug yet and was just analyzing. I might push a "debugging" version of the feature to have you validate against your config since I don't have the add on devices to test against locally. |
Thanks! Looking at my new issue #11 I'm starting to wonder if the whole integration was written assuming no water sensors (pw1) devices which don't have sov_status or flow attributes.... |
... yeah, so that's the issue. I don't think this integration works at all with a Phyn setup where it's more than just the Phyn Plus (aka there are water sensors)... async_add_entities(entities) tries to add the same set in sensor.py and switch.py regardless of the device being a pp1/2 (the Phyn Plus) vs. a pw1 (water sensor) In case it's helpful -- here are the attributes taken from my logs: For a water sensor (PW1)
For the Phyn Plus itself (pp1 or pp2, example taken from pp1)
So yeah, we might have to fix this for the entire integration and not just your proposed changes... |
OK my last update for tonight -- I managed to fix it both for @MizterB's master and for @rsocko's changes: The easiest fix is in switch.py and sensor.py, to add checks to async_setup_entry() to only do entities.extend() if device.model (product_code) is 'PP1' or 'PP2'. switch.py
sensor.py
Later on, to extend the integration to report useful things for water sensors, we can else if 'PW1'. Interesting attributes to report out would be:
|
OK, I created #12 on top of the main branch and tested my changes on both main and with @rsocko 's changes in #6 and my Phyn setup works great. @MizterB -- @rsocko 's PR has been open since August. Can we accept and merge? I would like to do work to add Water Sensor (pw1) support in the coming weeks so it'd be great to have a single clean master. Thanks! |
Corresponding to the feature in aiophyn this feature would add a switch entity to the Phyn device in Home Assistant in order to toggle on/off the away mode.
Switch On = Away Mode Active
Switch Off = Away Mode Inactive / Disabled
This would allow not only monitoring and awareness of the away mode setting, but it could then be used in conjunction with other triggers, scenes and automations to protect your home as well as not cause unexpected functionality.
Example Automation Scenarios:
The text was updated successfully, but these errors were encountered: