diff --git a/octoprint_influxdb/__init__.py b/octoprint_influxdb/__init__.py index c236793..6d996f0 100644 --- a/octoprint_influxdb/__init__.py +++ b/octoprint_influxdb/__init__.py @@ -20,6 +20,13 @@ if sys.version_info < (3, 0): ALLOWED_TYPES = (unicode,) + ALLOWED_TYPES + +# On events cast theses fields with the function in value +EVENT_CAST_FIELDS = { + 'new': str, + 'old': str +} + # host methods HOST_NODE = "node" HOST_FQDN = "fqdn" @@ -268,6 +275,10 @@ def on_event(self, event, payload): if not payload: payload = {} + + for field in payload: + if field in EVENT_CAST_FIELDS: + payload[field] = EVENT_CAST_FIELDS[field](payload[field]) self.influx_emit('events', payload, extra_tags={'type': event}) # state changes happen on events, so...