iobroker-community-adapters / ioBroker.accuweather

Accuweather forecast
MIT License
6 stars 9 forks source link

Data is always metric #340

Open stleusc opened 10 months ago

stleusc commented 10 months ago

Describe the bug
Data pulled is always metric

To Reproduce

Expected behavior
Support imperial data

Screenshots & Logfiles

Versions:
Current

Additional context
When using the data for things like NSPanel it would be nice to have imperial data too

mcm1957 commented 10 months ago

Please add version information: Current might be latest, stable, githuib , ... Please use numbers.

adapter js-controller node o/s

stleusc commented 10 months ago

Not that it's really relevant information given your code...

image

adapter v1.3.1 js-controller v7.1.4 node not sure where to find that o/s running via docker tag buanet/iobroker:latest where latest is v9.0.1

But like I said, this is not really relevant. I looked at your code here and in main.js there are a bunch of places where the API calls are built.

Example:

    request5Days() {
        if (typeof this.forecast !== "undefined") {
            const loc = this.config.loKey;
            const lang = this.config.language;
            this.forecast
                .localkey(loc)
                .timeInt("daily/5day")
                .language(lang)
                .metric(true)
                .details(true)
                .get()
                .then(res => this.setDailyStates(res))
                .catch(err => this.log.error(err));
        }
    }

I mean, there is a line saying metric(true) for EACH of them. The API can either return metric or imperial and your code CLEARLY asks for metric.

A fix would be to add a checkbox in the adapter settings and respect that setting for all those API calls instead of the constant 'true'.

algar42 commented 10 months ago

Just to note, if anyone is going to make updates for this. To switch the units from metric it is not enough to only change the 'metric' property mentioned above. It will also be required to make updates to the the object files in ./lib where all units are currently hard-coded to metric in Common object properties. And it will be required to update each parser within main.js to write the units to Common.Unit properties . :)

stleusc commented 10 months ago

@algar42 good catch. I just noticed that it is simply not working. And trust me, I wish the US would finally use the metric system! Born and raised in Germany I know too well how easy metric is haha. But now that I live in the US it makes my life so much harder if I don't adjust myself to use imperial.... Not that I like it, but seeing 0C when everyone talks about 32F makes things harder than it should be. Anyways, if there is anything I can help with, I'd be glad to do so.

algar42 commented 10 months ago

I would also be glad to help as I initially developed this adapter, but _un_fortunately I went away from IoBroker and can't continue supprot for this adapter anymore :(

mcm1957 commented 10 months ago

Well If someone has time and can create a PR I will look at it for sure. Otherwise I put it at todo list,but this list is a little bit long.