keans / lmnotify

A package for sending notifications to LaMetric Time.
MIT License
27 stars 4 forks source link

Option for local only #5

Closed alex-ruehe closed 6 years ago

alex-ruehe commented 7 years ago

Someone was asking about a "local only" mode, which uses the api key directly without getting it from the LaMetric servers.

I was thinking about how to implement this, but I'm not sure about the best way. I thought about subclassing the LaMetricManager, but then it would have to call super().__init__() which means, I need client_id and client_secret or the init() fails.

So, what would be a good solution? Writing a new superclass (possibly called LaMetricManager) and create two subclasses - one for local only (new) and one for using oAuth (similar to the current LaMetricManager)?

keans commented 7 years ago

Maybe it is better to have some sort of authentication object to separate both options. I will have a detailed look on it.

keans commented 7 years ago

I created a new branch to do some testing regarding the authentication: https://github.com/keans/lmnotify/tree/local

I did some testing now and the cloud version seems to work as expected. However, I do not get the local version really working. What is working is that the devices from the cloud can be stored, then loaded again and then notifications can be sent without the cloud. However, normally a UPNP request can be sent to discover the local devices. I am not sure what the problem is, but I cannot discover the LaMetric anymore, though a while ago it was possible during my tests. Maybe there is some problem with some firmware update?

RyuzakiKK commented 6 years ago

@keans I'll take a look at your branch, but if the problem is only for the discovery then I think that this can be easily worked around leaving only the "canonical way" where the users need to manually provide the ip

keans commented 6 years ago

Finally, I found some time to work on this issue. I have now included a local session and a cloud session: While the cloud session is used to obtain the list of devices including the API key per device (normally only once), all further calls can be done locally using a saved version of this device list.