{"action":"closed","issue":{"url":"https://api.github.com/repos/arendst/Sonoff-Tasmota/issues/2519","repository_url":"https://api.github.com/repos/arendst/Sonoff-Tasmota","labels_url":"https://api.github.com/repos/arendst/Sonoff-Tasmota/issues/2519/labels{/name}","comments_url":"https://api.github.com/repos/arendst/Sonoff-Tasmota/issues/2519/comments","events_url":"https://api.github.com/repos/arendst/Sonoff-Tasmota/issues/2519/events","html_url":"https://github.com/arendst/Sonoff-Tasmota/issues/2519","id":316572040,"number":2519,"title":"Sonoff Pow JSON Enery format in MQTT message causes problem with JSONPath","user":{"login":"beamish04","id":38612842,"avatar_url":"https://avatars1.githubusercontent.com/u/38612842?v=4","gravatar_id":"","url":"https://api.github.com/users/beamish04","html_url":"https://github.com/beamish04","followers_url":"https://api.github.com/users/beamish04/followers","following_url":"https://api.github.com/users/beamish04/following{/other_user}","gists_url":"https://api.github.com/users/beamish04/gists{/gist_id}","starred_url":"https://api.github.com/users/beamish04/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/beamish04/subscriptions","organizations_url":"https://api.github.com/users/beamish04/orgs","repos_url":"https://api.github.com/users/beamish04/repos","events_url":"https://api.github.com/users/beamish04/events{/privacy}","received_events_url":"https://api.github.com/users/beamish04/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2018-04-22T11:41:16Z","updated_at":"2018-04-22T12:46:57Z","closed_at":"2018-04-22T12:46:57Z","author_association":"NONE","body":"\r\nI am configuring Sonoff POW modules in Openhab2 using MQTT / Mosquitto. The powe is running Tasmota firmware  5.12.0 \r\n\r\nI am having troubles to convert the value for power consuption, i.e. Yesterday or Today. \r\nI am not sure if this issue is a Tasmota related issue or more related to the transformation module \r\nJSONPath  in Openhab. \r\n\r\nMy observation is that JSONPath is cutting off trailing zeros of a value when it is interpreted as a number. \r\nAs the structure of the MQTT message is sending the value for Yesterday as number and not as string in quotes I see this problem as follows: \r\n\r\nThis is the message which Sonoff POW is sending per console and received by the MQTT broker: \r\n\r\n`12:21:08 MQT: tele/pow1/SENSOR = {\"Time\":\"2018.04.22 12:21:08\",\"ENERGY\":{\"Total\":29.214,\"Yesterday\":1.200,\"Today\":0.10,\"Period\":0,\"Power\":0,\"Factor\":0.00,\"Voltage\":219,\"Current\":0.000}}`\r\n\r\nWith the obove message the values for Yesterday is interpreted as 1.2 instead of 1200\r\n\r\nThis seems not only to be true for the Openhab JSONPath implementation. I checked this as well with \r\n[http://www.jsonquerytool.com/#/JSONPath](url)\r\n\r\n![image](https://user-images.githubusercontent.com/38612842/39094607-3e675368-4632-11e8-8ce8-3a4e92bc9032.png)\r\n\r\n\r\nAssuming the POW has logged power consumption of 1207 W the day before then the parsing with JSONPath works fine. But when the power consumption was only 1200 W then the value gets truncated to 12 by JSONPath. \r\n\r\nWould it make sense to send such values as strings instead of numbers? This would differenticate \r\nint numbers as such for values like Total, Yesterday, Today as INT from values as float like temperature. The JSON definition for Temperature is also using the number representation but the same is used for the presentation of thousands for other parameters\r\n\r\n```\r\n**Sonoff Module: BMP280**\r\n{\r\n  \"StatusSNS\": {\r\n    \"Time\": \"2018-02-10T22:46:34\",\r\n    \"BMP280\": {\r\n      \"Temperature\": 80.9,\r\n      \"Pressure\": 984.4\r\n    }\r\n  }\r\n}\r\n```\r\n**Sonoff Module: POW**\r\n\"StatusPTH\": {\r\n    \"PowerLow\": 0,\r\n    \"PowerHigh\": 0,\r\n    \"VoltageLow\": 0,\r\n    \"VoltageHigh\": 0,\r\n    \"CurrentLow\": 0,\r\n    \"CurrentHigh\": 0\r\n  },\r\n  \"StatusSNS\": {\r\n    \"Time\": \"2018.02.04 23:17:01\",\r\n    \"ENERGY\": {\r\n      \"Total\": 3.185,\r\n      \"Yesterday\": 3.058,\r\n      \"Today\": 0.127,\r\n      \"Power\": 0,\r\n      \"Factor\": 0.00,\r\n      \"Voltage\": 221,\r\n      \"Current\": 0.000\r\n    }\r\n  },\r\n\r\nOr is there a possiblility to change the representation of tousands to not use the dot? \r\nIf not sending the value as string would make it possible to run customized transformation \r\nof the string, i.e. remove the dot and parse the value to Int of Float, whatever is needed. Right now I did not find a solution to retrieve the complete value from the MQTT message as the number gets manupilated by JSONPath upfront. \r\n\r\nmany thanks & Regards, \r\n\r\n\r\n"}}
{"actor":{"display_login":"beamish04"}}