ebaauw / homebridge-ws

Homebridege plugin for virtual weather station
Apache License 2.0
106 stars 4 forks source link

Min/max temperature values below 0 °C cannot be used #34

Closed ucsbricks closed 3 years ago

ucsbricks commented 3 years ago

Homebridge v1.3.4 homebridge-ws v2.5.0 Eve app, Home+ app

Config

{
    "name": "Weather",
    "apikey": "XXXXX",
    "dailyForecasts": 1,
    "hourlyForecasts": 1,
    "locations": [
        "XXXXX"
    ],
    "platform": "WS"
}

I tried to create automations based on min/max temperatures below 0 °C. Home+ app does not show temperatures below 0 °C but up to one hundred million billion °C in its selection dialog. Eve app on the other hand has a slider which is impossible to use. As soon as one tries to change the value it will be either a negative or positive number with about 10 digits.

I found that in v2.5.0 current temperature was fixed to support values between -270 and 100 °C. Could you please apply the same fix to all other temperature based characteristics (min, max, apparent, dew point) as well? Thanks.

redjoto commented 3 years ago

It’s the same issue with wind speed.

ebaauw commented 3 years ago

I'll have a look at this, but it's not as easy as it seems.

They changed HAP-NodeJS with recent versions to issue warnings when plugins set accessories to illegal values (e.g. outside the range given by the minValue and maxValue properties). Especially on Apple-defined characteristics, this could cause HomeKit to reject the accessory (i.c. the Homebridge bridge accessory and all bridged accessories) for non-compliance. While this is a good thing, I've never seen any issues with custom characteristics (which neither Home nor Siri supports). To prevent these warnings (and possible non-compliance issues) I simply removed the minValue and maxValue properties for read-only characteristics end Feb, thinking they wouldn't be input by users anyway. I'm afraid, I didn't consider automation triggers and conditions at that time.

I'll re-instate the min/max values, but need to ensure the value retrieved from OpenWeatherMap falls within the range. I have seen an occasional unexpected value, see #27.

Unfortunately, the creators of HomeKit apps, including Eve and Home+, seem to enjoy changing the user interface with every new version, breaking something in the process. They're becoming more and more like Apple, I'm afraid. Home+ used to provide a text box where you could type in the value, next to the slider, but they changed that to a drop-down list of values. Eve sometimes shows sliders, other times Up/Down arrows. I'm not sure if it shows the Up/Down for the Current Temperature characteristic, or for any characteristic, based on the min/max values.

So the challenge is to define a range, which includes the (valid) values that can be reported by OpenWeatherMap (or any other source or sensor), but is still small enough for effective value input for triggers, conditions, and scenes. The range of -270 to 100 for Current Temperature, now defined in HAP NodeJS makes little sense to me: I'm not sure what the coldest temperature measued on Earth is, but it's well above -270°C. And most sensors in consumer-grade weather stations will probably stop working below -40° anyways (I used to use the range -40 ... 100 for temperature-related characteristics). I don't even have a clue what a reasonable max value for wind speed would be.

ucsbricks commented 3 years ago

-270°C seems to be related to Absolute Zero (0°K = -273.1°C). The reason why I suggested to use the -270°C to 100°C range was not because they will someday be measured on Earth or weather stations support them, but Eve and Home+ seem to handle them properly in their UI. Therefore they can easily been used for automations.

ebaauw commented 3 years ago

@ucsbricks @redjoto Could you try beta v2.5.1-0? That should re-instate the minValue/maxValue properties and coerce the values to these ranges. Also fixes MaximumWindSpeed, which still reported unit km/h instead of m/s (though the value was m/s).

ucsbricks commented 3 years ago

@ebaauw I successfully tested the minValue/maxValue properties in both Eve and Home+ app. Values can now easily be set from -40 to 100 °C. Thanks for improving this!

ebaauw commented 3 years ago

Published v2.5.1.