aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBjørn Mork <bjorn@mork.no>2019-05-25 15:17:25 +0200
committerBjørn Mork <bjorn@mork.no>2019-05-25 15:17:25 +0200
commitf46d1c9af14760d623f92b7f287424d3e25a5a3f (patch)
tree1a92686cf8d40ee268de7a658c67de89e17c060c
parent93caa716a61f85a78a22709b3a093e6fd27d4671 (diff)
fixup Aidon meter-time field
Signed-off-by: Bjørn Mork <bjorn@mork.no>
-rw-r--r--obinsectd.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/obinsectd.c b/obinsectd.c
index bf59b1d..0a3e7d2 100644
--- a/obinsectd.c
+++ b/obinsectd.c
@@ -945,10 +945,15 @@ static const char *obis_lookup(const char *list, int idx)
return "unknown";
}
+/* some OBIS codes use "wrong" types - fixup for normailization */
static json_object *obis_get_val(const char *key, json_object *val)
{
- /* some OBIS codes use "wrong" types - fixup for normailization*/
- if (!strcmp(key, "0-1:1.0.0.255") && json_object_get_string_len(val) == 12) // date-time coded as octet-string
+ /*
+ * Both Aidon and Kaifa use "0-0:1.0.0.255" for the meter time
+ * OBIS code, while Kamstrup use "0-1:1.0.0.255". Aidon and
+ * Kamstrup get the type wrong, so we have to fixup both cases
+ */
+ if (!strcmp(key + 3, ":1.0.0.255") && json_object_get_string_len(val) == 12) // date-time coded as octet-string
return json_object_new_int(decode_datetime((unsigned char *)json_object_get_string(val)));
/* default to return val as-is, but with increased ref */