naofireblade / homebridge-weather-plus

A comprehensive weather plugin for homebridge.
MIT License
316 stars 63 forks source link

Bug Temperature at or below 0 Home App not working #160

Closed frans2526 closed 3 years ago

frans2526 commented 3 years ago

Good evening,

First of all thank you for this plugin which is really nice! I have a small issue with the following sensors :

When I reach 0 degrees or below the Home App from Apple see these as "No reponse", this is a bit strange because on Homebridge I can see the temperature -1.1°C or 0°C. I first, I thought the API wasn't working properly but this isn't the case as in debug mode I can see the JSON from openweathermap and obviously the temperature is showed correctly in Homebridge.

If any one as any idea, I already restart homebridge and the server. I will try to remove and reinstall the package to see if this is making any change.

You can see below my config file : `{ "units": "ca", "interval": 15, "stations": [ { "nameNow": "Home", "service": "openweathermap", "key": " ", "locationGeo": [ ,


                ],
                "locationCity": " *******",
                "language": "en",
                "compatibility": "home",
                "conditionCategory": "simple",
                "now": true,
                "extraHumidity": false
            },
            {
                "nameNow": "forecast",
                "service": "openweathermap",
                "key": " *******",
                "locationGeo": [
                   *******,
                   *******
                ],
                "locationCity": " *******",
                "language": "en",
                "compatibility": "home",
                "forecast": [
                    "Tomorrow"
                ],
                "nameForecast": "forecast",
                "conditionCategory": "simple",
                "now": false,
                "extraHumidity": false
            }
        ],
        "platform": "WeatherPlus"
    }`

Thank you,

Francois

frans2526 commented 3 years ago

Hello Guys,

I found the issue, it is due of these lines in openweathermap.js, unfortunately I dont have setup, Xcode so i modifie directly the file on my on my raspberry (I know I shouldn't) , I just write 12 for example and I got the correct info on EVE and Home app. Anyone has any clue, how we could fixed it and why we get this kind of errors ?

Before I got "65535" as temperature and "no response" on Apple home kit.

Thanks

NB: I think this is the same issue describe in #162

report.Temperature = typeof values.temp === 'object' ? parseFloat(values.temp.day) : parseFloat(values.temp);
report.TemperatureApparent = typeof values.feels_like === 'object' ? parseInt(values.feels_like.day) : parseInt(values.feels_like);
frans2526 commented 3 years ago

Well, I found a fix after searching quite sometimes, the problem is in fact that homebridge cannot emulate a negative temperature, there is a fix for that : https://github.com/homebridge/HAP-NodeJS/issues/147. I try then to find in the plugin and I was a bit surprised, this is done on currentConditions.js and forecats.js but apparently there is an issue over there (if someone can fix it properly, it would be great).

Until then you can modify the index.js from line 352 until 393 :

                                else if (name === "DewPoint")
                {
                    accessory.DewPointService.setCharacteristic(Characteristic.CurrentTemperature, convertedValue);

                    accessory.DewPointService
                    .getCharacteristic(Characteristic.CurrentTemperature)
                    .setProps({
                        minValue: -100,
                        maxValue: 100   
                    });
                }
                else if (name === "Humidity")
                {
                    accessory.HumidityService.setCharacteristic(Characteristic.CurrentRelativeHumidity, convertedValue);
                }
                else if (["RainBool", "SnowBool"].includes(name))
                {
                    accessory[name + "Service"].setCharacteristic(Characteristic.OccupancyDetected, convertedValue);
                }
                else if (name === "TemperatureMin")
                {
                    accessory.TemperatureMinService.setCharacteristic(Characteristic.CurrentTemperature, convertedValue);

                    accessory.TemperatureMinService
                    .getCharacteristic(Characteristic.CurrentTemperature)
                    .setProps({
                        minValue: -100,
                        maxValue: 100
                    });
                }
                else if (name === "TemperatureApparent")
                {
                    accessory.TemperatureApparentService.setCharacteristic(Characteristic.CurrentTemperature, convertedValue);

                    accessory.TemperatureApparentService
                    .getCharacteristic(Characteristic.CurrentTemperature)
                    .setProps({
                        minValue: -100,
                        maxValue: 100
                    });

                }