joeshaw / carwings

Go package and CLI tool for the Nissan Leaf Carwings API
MIT License
31 stars 11 forks source link

Timed climate control #27

Open nigelm opened 5 years ago

nigelm commented 5 years ago

I'd like to implement the scheduled start of climate control (you can tell its getting colder here!).

The additional API calls required can be plagerised from https://gitlab.com/tobiaswkjeldsen/dartcarwings

So then the commands need to be created. The climate-on command could be reused - if it has a timespec added then it i scheduled rather than immediate. However I am tending more towards climate-on-at, or possibly climate-scheduled-at which is long and hard to type (but then leads naturally to the additional commands climate-schedule-status and climate-schedule-cancel

Ideally I'd like the timespec to be handled in a similar fashion to the unix at command (see Specifying Time in https://www.computerhope.com/unix/uat.htm ), but that really needs a usable go module that does mostly the right thing - any suggestions?

Any comments before I go ahead?

-- Nigel

joeshaw commented 5 years ago

I am happy with climate-on-at (and I guess climate-on-status an climate-on-cancel) if you are.

One question I have is whether people want to turn their climate on at a specific time, or at some time in the future? For the latter we could use Go's built-in time.Duration type, so you could say, climate-on-at 30m to turn it on in 30 minutes. Maybe both should be supported.

I'm not aware of any good fuzzy matching time libraries for Go. I will look around for one, but I think a good first stab at the problem would be to define a bunch of formats in the time.Parse mold and just run through them one at a time. Pretty gross, but it could cover a lot of the use cases.

joeshaw commented 5 years ago

A couple potential options:

https://github.com/olebedev/when https://github.com/bcampbell/fuzzytime https://github.com/kierdavis/dateparser https://github.com/araddon/dateparse

I haven't looked at transitive dependencies, but I'd like to keep them as minimal as possible.

karora commented 4 years ago

I've used https://github.com/araddon/dateparse in other places and it seems to do a pretty good job.