{"action":"created","issue":{"url":"https://api.github.com/repos/openhab/openhab/issues/2891","labels_url":"https://api.github.com/repos/openhab/openhab/issues/2891/labels{/name}","comments_url":"https://api.github.com/repos/openhab/openhab/issues/2891/comments","events_url":"https://api.github.com/repos/openhab/openhab/issues/2891/events","html_url":"https://github.com/openhab/openhab/pull/2891","id":94183294,"number":2891,"title":"Netatmo: Added additional types along with intervals to the binding","user":{"login":"robnielsen","id":838221,"avatar_url":"https://avatars.githubusercontent.com/u/838221?v=3","gravatar_id":"","url":"https://api.github.com/users/robnielsen","html_url":"https://github.com/robnielsen","followers_url":"https://api.github.com/users/robnielsen/followers","following_url":"https://api.github.com/users/robnielsen/following{/other_user}","gists_url":"https://api.github.com/users/robnielsen/gists{/gist_id}","starred_url":"https://api.github.com/users/robnielsen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/robnielsen/subscriptions","organizations_url":"https://api.github.com/users/robnielsen/orgs","repos_url":"https://api.github.com/users/robnielsen/repos","events_url":"https://api.github.com/users/robnielsen/events{/privacy}","received_events_url":"https://api.github.com/users/robnielsen/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/openhab/openhab/labels/enhancement","name":"enhancement","color":"84b6eb"}],"state":"open","locked":false,"assignee":null,"milestone":{"url":"https://api.github.com/repos/openhab/openhab/milestones/10","html_url":"https://github.com/openhab/openhab/milestones/1.8.0","labels_url":"https://api.github.com/repos/openhab/openhab/milestones/10/labels","id":1127272,"number":10,"title":"1.8.0","description":"","creator":{"login":"teichsta","id":2108636,"avatar_url":"https://avatars.githubusercontent.com/u/2108636?v=3","gravatar_id":"","url":"https://api.github.com/users/teichsta","html_url":"https://github.com/teichsta","followers_url":"https://api.github.com/users/teichsta/followers","following_url":"https://api.github.com/users/teichsta/following{/other_user}","gists_url":"https://api.github.com/users/teichsta/gists{/gist_id}","starred_url":"https://api.github.com/users/teichsta/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/teichsta/subscriptions","organizations_url":"https://api.github.com/users/teichsta/orgs","repos_url":"https://api.github.com/users/teichsta/repos","events_url":"https://api.github.com/users/teichsta/events{/privacy}","received_events_url":"https://api.github.com/users/teichsta/received_events","type":"User","site_admin":false},"open_issues":20,"closed_issues":13,"state":"open","created_at":"2015-05-24T06:23:20Z","updated_at":"2015-07-10T16:06:26Z","due_on":null,"closed_at":null},"comments":14,"created_at":"2015-07-10T00:38:29Z","updated_at":"2015-07-13T01:43:23Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/openhab/openhab/pulls/2891","html_url":"https://github.com/openhab/openhab/pull/2891","diff_url":"https://github.com/openhab/openhab/pull/2891.diff","patch_url":"https://github.com/openhab/openhab/pull/2891.patch"},"body":"Added support to Netatmo binding for *min_*, *max_*, sum_rain for the intervals 30 minutes, 1 hour, 3 hours, 1 day, 1 week and 1 month. The interval is configurable and defaults to 1 day. The new types and intervals (scale) are described at https://dev.netatmo.com/doc/methods/getmeasure.\r\n\r\nThe current types only returned the last measurement, which didn't allow for min/max temps, min/max humidity, etc. Rain only reported the amount of rain since the last reading, this update allows for rain to be reported in the intervals above such as hour, day, week, month."},"comment":{"url":"https://api.github.com/repos/openhab/openhab/issues/comments/120781946","html_url":"https://github.com/openhab/openhab/pull/2891#issuecomment-120781946","issue_url":"https://api.github.com/repos/openhab/openhab/issues/2891","id":120781946,"user":{"login":"robnielsen","id":838221,"avatar_url":"https://avatars.githubusercontent.com/u/838221?v=3","gravatar_id":"","url":"https://api.github.com/users/robnielsen","html_url":"https://github.com/robnielsen","followers_url":"https://api.github.com/users/robnielsen/followers","following_url":"https://api.github.com/users/robnielsen/following{/other_user}","gists_url":"https://api.github.com/users/robnielsen/gists{/gist_id}","starred_url":"https://api.github.com/users/robnielsen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/robnielsen/subscriptions","organizations_url":"https://api.github.com/users/robnielsen/orgs","repos_url":"https://api.github.com/users/robnielsen/repos","events_url":"https://api.github.com/users/robnielsen/events{/privacy}","received_events_url":"https://api.github.com/users/robnielsen/received_events","type":"User","site_admin":false},"created_at":"2015-07-13T01:43:22Z","updated_at":"2015-07-13T01:43:22Z","body":"@watou, haven't you done essentially did the same thing at https://github.com/openhab/openhab/blob/master/bundles/binding/org.openhab.binding.ecobee/src/main/java/org/openhab/binding/ecobee/internal/messages/Temperature.java#L162? It has:\r\n```java\r\npublic final BigDecimal toCelsius() {\r\n\t\treturn temp.movePointLeft(1).subtract(THIRTY_TWO).divide(NINE.divide(FIVE), MathContext.DECIMAL32);\r\n\t}\r\n```\r\n\r\nwhich is essentially no different than the code:\r\n\r\n```java\r\npublic final BigDecimal toCelsius() {\r\n\t\treturn temp.movePointLeft(1).subtract(THIRTY_TWO).divide(NINE.divide(FIVE), MathContext.DECIMAL128).setScale(5, BigDecimal.ROUND_HALF_UP);\r\n\t}\r\n```\r\n\r\nIn this case, a decision was made that 5 digits of precision was reasonable. Just to show that this works out the same way, the code:\r\n```java\r\n\t\tBigDecimal nine = new BigDecimal(\"9\");\r\n\t\tBigDecimal five = new BigDecimal(\"5\");\r\n\t\tBigDecimal thirtyTwo = new BigDecimal(\"32\");\r\n\r\n\t\tBigDecimal temp = new BigDecimal(\"789\");\r\n\t\tSystem.out.println(temp.movePointLeft(1).subtract(thirtyTwo).divide(nine.divide(five), MathContext.DECIMAL32));\r\n\t\tSystem.out.println(temp.movePointLeft(1).subtract(thirtyTwo).divide(nine.divide(five), MathContext.DECIMAL128).setScale(5, BigDecimal.ROUND_HALF_UP));\r\n\t\tSystem.out.println(temp.movePointLeft(1).subtract(thirtyTwo).divide(nine.divide(five), MathContext.DECIMAL64));\r\n\t\tSystem.out.println(temp.movePointLeft(1).subtract(thirtyTwo).divide(nine.divide(five), MathContext.DECIMAL128));\r\n```\r\nproduces the result:\r\n```\r\n26.05556\r\n26.05556\r\n26.05555555555556\r\n26.05555555555555555555555555555556\r\n```\r\nUsing your argument, the code at https://github.com/openhab/openhab/blob/master/bundles/binding/org.openhab.binding.ecobee/src/main/java/org/openhab/binding/ecobee/internal/messages/Temperature.java#L162 should be using MathContext.DECIMAL128 instead of MathContext.DECIMAL32 shouldn't it?\r\n\r\nAlso, once the code is simplified to use a single multiplication instead of two divisions, you'll run into the same problem since  5/9 is the number is 0.555555555..., when do you stop? For example, the code:\r\n```java\r\n\t\tBigDecimal thirtyTwo = new BigDecimal(\"32\");\r\n\t\tBigDecimal zeroPointFives = new BigDecimal(\"0.5555555556\");\r\n\t\tBigDecimal mmToInches     = new BigDecimal(\"0.0393700787\"); // using same number of digits for both\r\n\r\n\t\tSystem.out.println(temp.movePointLeft(1).subtract(thirtyTwo).multiply(zeroPointFives, MathContext.DECIMAL32));\r\n\t\tSystem.out.println(temp.movePointLeft(1).subtract(thirtyTwo).multiply(zeroPointFives).setScale(5, BigDecimal.ROUND_HALF_UP));\r\n\t\tSystem.out.println(temp.movePointLeft(1).subtract(thirtyTwo).multiply(zeroPointFives));\r\n```\r\nproduces the result:\r\n```\r\n26.05556\r\n26.05556\r\n26.05555555764\r\n```\r\nSo again, I'm back to the same question, what is a reasonable level of precision? I don't think we can solve it here. I'll post a question to the group. \r\n\r\n"}}