{"action":"created","issue":{"url":"https://api.github.com/repos/SignalK/specification/issues/307","repository_url":"https://api.github.com/repos/SignalK/specification","labels_url":"https://api.github.com/repos/SignalK/specification/issues/307/labels{/name}","comments_url":"https://api.github.com/repos/SignalK/specification/issues/307/comments","events_url":"https://api.github.com/repos/SignalK/specification/issues/307/events","html_url":"https://github.com/SignalK/specification/issues/307","id":195722940,"number":307,"title":"Values are inconsistent between REST API and Delta messages","user":{"login":"jboynes","id":1704738,"avatar_url":"https://avatars.githubusercontent.com/u/1704738?v=3","gravatar_id":"","url":"https://api.github.com/users/jboynes","html_url":"https://github.com/jboynes","followers_url":"https://api.github.com/users/jboynes/followers","following_url":"https://api.github.com/users/jboynes/following{/other_user}","gists_url":"https://api.github.com/users/jboynes/gists{/gist_id}","starred_url":"https://api.github.com/users/jboynes/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jboynes/subscriptions","organizations_url":"https://api.github.com/users/jboynes/orgs","repos_url":"https://api.github.com/users/jboynes/repos","events_url":"https://api.github.com/users/jboynes/events{/privacy}","received_events_url":"https://api.github.com/users/jboynes/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2016-12-15T05:54:22Z","updated_at":"2016-12-15T07:29:29Z","closed_at":null,"body":"Working on #304, testing with the node server, I noticed the way the value of a key is sent is different when fetched from the REST API or received in a delta.\r\n\r\nFor example, a GET to `.../navigation/headingTrue` returns\r\n```json\r\n{\r\n  \"value\": 0,\r\n  \"$source\": \"nmeaFromFile.II\",\r\n  \"timestamp\": \"2016-12-15T03:29:32.000Z\",\r\n  \"sentence\": \"HDT\"\r\n}\r\n```\r\nbut updates to that key are sent as:\r\n```json\r\n{\r\n  \"context\": \"vessels.urn:mrn:signalk:uuid:c0d79334-4e25-4245-8892-54e8ccc8021d\",\r\n  \"updates\": [\r\n    {\r\n      \"source\": {\r\n        \"type\": \"NMEA0183\",\r\n        \"sentence\": \"HDT\",\r\n        \"label\": \"nmeaFromFile\",\r\n        \"talker\": \"II\"\r\n      },\r\n      \"timestamp\": \"2016-12-15T03:20:35.000Z\",\r\n      \"values\": [\r\n        {\r\n          \"path\": \"navigation.headingTrue\",\r\n          \"value\": 0\r\n        }\r\n      ]\r\n    }\r\n  ]\r\n}\r\n```\r\n\r\nThe difference here is REST call returns an `object` but the `value` property in the delta message is a scalar. The REST result matches the `numberValue` type for headingTrue as [defined by the schema](https://github.com/SignalK/specification/blob/master/schemas/groups/navigation.json#L389), the delta message does not.\r\n\r\nHowever, when the key has an object value, like `navigation.position` then both the REST API and the delta message contain the same object:\r\n\r\n```json\r\n{\r\n  \"longitude\": 23.53145,\r\n  \"latitude\": 60.0782,\r\n  \"$source\": \"nmeaFromFile.GP\",\r\n  \"timestamp\": \"2016-12-15T10:00:37.000Z\",\r\n  \"sentence\": \"GLL\"\r\n}\r\n\r\n{\r\n  \"updates\": [\r\n    {\r\n      \"source\": {\r\n        \"type\": \"NMEA0183\",\r\n        \"sentence\": \"GLL\",\r\n        \"label\": \"nmeaFromFile\",\r\n        \"talker\": \"GP\"\r\n      },\r\n      \"timestamp\": \"2016-12-15T09:56:07.000Z\",\r\n      \"values\": [\r\n        {\r\n          \"path\": \"navigation.position\",\r\n          \"value\": {\r\n            \"longitude\": 23.538766666666668,\r\n            \"latitude\": 60.08436666666667\r\n          }\r\n        }\r\n      ]\r\n    }\r\n  ],\r\n  \"context\": \"vessels.urn:mrn:signalk:uuid:c0d79334-4e25-4245-8892-54e8ccc8021d\"\r\n}\r\n```\r\n\r\nAlso, a `numberValue` like `headingTrue` can contain multiple `values` so the value for this key may at some time be representable as a scalar but for other instances may be a object containing multiple values. The client receiving the update must now handle these special cases.\r\n\r\nThis can be addressed by specifying that the `value` property in the delta message is always an object of the type as defined by the schema for that key. This would change the `headingTrue` delta message to:\r\n```json\r\n{\r\n  \"context\": \"vessels.urn:mrn:signalk:uuid:c0d79334-4e25-4245-8892-54e8ccc8021d\",\r\n  \"updates\": [\r\n    {\r\n      \"source\": {\r\n        \"type\": \"NMEA0183\",\r\n        \"sentence\": \"HDT\",\r\n        \"label\": \"nmeaFromFile\",\r\n        \"talker\": \"II\"\r\n      },\r\n      \"timestamp\": \"2016-12-15T03:20:35.000Z\",\r\n      \"values\": [\r\n        {\r\n          \"path\": \"navigation.headingTrue\",\r\n          \"value\": { \"value\": 0 }\r\n        }\r\n      ]\r\n    }\r\n  ]\r\n}\r\n```\r\nwhere the `updates/values/value` property contains a `numberValue`."},"comment":{"url":"https://api.github.com/repos/SignalK/specification/issues/comments/267258097","html_url":"https://github.com/SignalK/specification/issues/307#issuecomment-267258097","issue_url":"https://api.github.com/repos/SignalK/specification/issues/307","id":267258097,"user":{"login":"tkurki","id":1049678,"avatar_url":"https://avatars.githubusercontent.com/u/1049678?v=3","gravatar_id":"","url":"https://api.github.com/users/tkurki","html_url":"https://github.com/tkurki","followers_url":"https://api.github.com/users/tkurki/followers","following_url":"https://api.github.com/users/tkurki/following{/other_user}","gists_url":"https://api.github.com/users/tkurki/gists{/gist_id}","starred_url":"https://api.github.com/users/tkurki/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tkurki/subscriptions","organizations_url":"https://api.github.com/users/tkurki/orgs","repos_url":"https://api.github.com/users/tkurki/repos","events_url":"https://api.github.com/users/tkurki/events{/privacy}","received_events_url":"https://api.github.com/users/tkurki/received_events","type":"User","site_admin":false},"created_at":"2016-12-15T07:29:29Z","updated_at":"2016-12-15T07:29:29Z","body":"The reason for the `value` property in the full model is that it allows\r\n- metadata for the path (`timestamp`, `meta`, `_attr`)\r\n- multiple values handling with `values``\r\n\r\nDelta is not meant to convey any of this, only the updated value with minimal metadata about the updated value of the property, so the `value` in delta is not the same `value` as the one in full.\r\n\r\nI would fix the inconsistency going in the opposite direction: use `value` always, also in object valued properties, in the full model."}}
{"actor":{"display_login":"tkurki"}}