philippelt / netatmo-api-python

Netatmo connect API python client (for Netatmo information, see https://dev.netatmo.com)
GNU General Public License v3.0
186 stars 118 forks source link

standard environment variable USERNAME on windows #40

Closed VauHa closed 3 years ago

VauHa commented 3 years ago

I was using this great module on Linux for a while, but then had the necessity to get the data on windows. I got an authentication error and found that this was due to the standard environment variable USERNAME on windows. This overwrites the given credentials. Don't know the best way how to fix this, I locally changed USERNAME/PASSWORD to NA_USERNAME/NA_PASSWORD in the code. The rest seems running fine.

philippelt commented 3 years ago

Hello,

this issue has already been raised. You are right, I made a poor choice for the username env var as this conflict with Windows default var. On Linux, the default var for the username is USER thus not conflicting with the Netatmo library requirements.

Such problem is usually solved by unsetting the environment variable before running the code (unset USERNAME in Linux) and as far as I know, the windows equivalent is (set USERNAME=). Unfortunately, I do not have access to a windows system to check that it is the right syntax.

This would allow you to use the library without modifications but, of course, you can change the code as you did. You will just have to reapply the change in case of upgrade.

I do not plan to change the environment variable name because this would be a breaking change for people who already use the library and I try to never do breaking changes to allow for automatic monitoring/upgrades without human interaction.

I consider this particularly important in the area of IoT where you may have a lot of sensors/objects and a lot of edge/core controllers to monitor these objects. It is better to be able to apply automatic upgrades for security reasons without fear of a sudden break of operations.

As it seems to be a recurrent source of trouble, I am going to see if I can output a warning in case of use on Windows platform and the USERNAME env var is defined. At least, this would allow peoples to quickly understand why it is not working and not loose time in debug.

philippelt commented 3 years ago

Warning added in 0a0f3436bf088c94762f784c13e765e199defc7d