Closed eteq closed 3 years ago
Thanks.
I'm a little concerned that the primary use for the pykumo lib (at least for me) is non-interactive (i.e. from Home Assistant) so having it try to prompt for username/password in a situation where they're not configured could be problematic. If you could reorganize your code so your component that's creating the KumoAccount object does the prompting instead, I think that would be better overall.
Also, adding 're' and 'getpass' imports probably means there are enough external dependencies to warrant a requirements.txt, so if you could manage that in your PR I'd appreciate it.
I'm a little concerned that the primary use for the pykumo lib (at least for me) is non-interactive (i.e. from Home Assistant) so having it try to prompt for username/password in a situation where they're not configured could be problematic. If you could reorganize your code so your component that's creating the KumoAccount object does the prompting instead, I think that would be better overall.
I see your point here, but I think it would be ideal if we could make pykumo
to meet both of these needs. The point here is that I don't have a component to do this in - I am directly, at an interactive ipython
prompt, interacting with these objects. (For me it's quite a bit faster to just switch to the python terminal on my desktop and call set_mode('cool')
than pull out my phone and fiddle with the app, or pull it up in Home Assistant!) So I see two "compromise" solutions here:
KumoCloudAccount.__init__
doesn't default to None
for username
and password
. Then I have to do KumoCloudAccount(None, None)
, but that's not so bad (and less likely for me to accidentally reveal my password on the ipython
history). And then that way there's little chance of "accidentally" triggering the non-interactive mode in a hass or similar context.InteractiveKumoCloud
and add the changes I'm suggesting there.Does one of those sound good to you @dlarrick ?
Also, adding 're' and 'getpass' imports probably means there are enough external dependencies to warrant a requirements.txt, so if you could manage that in your PR I'd appreciate it.
Those are both in the python standard library, so I don't think a requirements
would apply there...?
Oh, but I'm happy to add a requirements.txt
or add a dependency to setup.py
which I think is just requests
, right?
I think a subclass for InteractiveKumoCloud sounds fine, thanks!
Lack of 'requests' in a requirements / setup hasn't mattered till now since (naturally) HA itself needs requests. If you're willing to do something to fix this in your PR I'll be grateful, but if not I'll fix it later.
@eteq I have just now pushed something akin to this PR. Instead of a wrapper class I added a static method Factory
that will allow you to do what you want. I'll push to PyPI shortly. I also included your make_pykumos
utility.
This PR adds a few conveniences I found helpful when trying to work with
KumoCloudAccount
. Specifically:input
andgetpass
mechanismsmake_pykumos
method that createsPyKumo
objects for everything in the kumo cloud account, skipping over some mildly awkward creation steps.