From 7b8cec3c2ad1d940cce133e0c3e6fb18a0c36de7 Mon Sep 17 00:00:00 2001 From: Arne Date: Sat, 30 Nov 2019 20:09:33 +0100 Subject: [PATCH] Added rounding for non metric values in Apple Home app --- CHANGELOG.md | 5 ++++- README.md | 3 +-- package.json | 2 +- util/characteristics.js | 8 ++++---- 4 files changed, 10 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b5276e2..26c8610 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -163,4 +163,7 @@ * Updated readme ## 3.0.2 -* Updated readme \ No newline at end of file +* Updated readme + +## 3.0.3 +* Added rounding for non metric values in Apple Home app \ No newline at end of file diff --git a/README.md b/README.md index 48172ab..3d42e9c 100644 --- a/README.md +++ b/README.md @@ -7,8 +7,7 @@ This is a weather plugin for [homebridge](https://github.com/nfarina/homebridge) that features current observations, daily forecasts and history graphs for multiple locations and services. You can download it via [npm](https://www.npmjs.com/package/homebridge-weather-plus). ![Screenshots](https://user-images.githubusercontent.com/12081369/69379083-feb05300-0caf-11ea-9a0d-cf8e1879d007.png) - ->Screenshots 2 and 3 are taken from the Elgato Eve app. +*Screenshots 2 and 3 are taken from the Elgato Eve app.* If you like this plugin and find it useful, I would be forever grateful for your support: diff --git a/package.json b/package.json index d6d382d..0bb7a0c 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "homebridge-weather-plus", - "version": "3.0.2", + "version": "3.0.3", "description": "A comprehensive weather plugin for homekit with current observations, forecasts and history.", "license": "MIT", "keywords": [ diff --git a/util/characteristics.js b/util/characteristics.js index caacf5f..45f44b6 100644 --- a/util/characteristics.js +++ b/util/characteristics.js @@ -62,7 +62,7 @@ module.exports = function (Characteristic, units) }; var rainfallValue = (val) => { - return (units !== 'imperial') ? val : (val / 25.4); + return (units !== 'imperial') ? val : Math.round(val / 25.4 * 100) / 100; }; var c2f = (celsius) => @@ -88,7 +88,7 @@ module.exports = function (Characteristic, units) }; var visibilityProps = (max) => { - var range = ((units === 'si') || (units == 'ca')) ? {unit: 'km', maxValue: max, minValue: 0} + var range = ((units === 'si') || (units === 'ca')) ? {unit: 'km', maxValue: max, minValue: 0} : {unit: 'mi', maxValue: km2mi(max), minValue: 0}; return underscore.extend( @@ -105,11 +105,11 @@ module.exports = function (Characteristic, units) var mtos2kmh = (m) => { - return ((m * 3600) / 1000); + return (Math.round(m * 3.6 * 10) / 10); }; var mtos2mih = (m) => { - return ((m * 3600) / 1609.34); + return (Math.round(((m * 3600) / 1609.34) * 10) / 10); }; var windspeedProps = (max) => {