Skip to content

Non-json mqtt values #14

@oernii

Description

@oernii

Hi, I have some devices which return raw strings values, in mqtt sub it looks like this:

2020-10-14T13:36:31+0200 stat/nodemcu02_B3D47D/POWER OFF
2020-10-14T13:36:43+0200 stat/nodemcu02_B3D47D/POWER ON
2020-10-14T13:40:00+0200 stat/nodemcu02_B3D47D/POWER OFF
2020-10-14T13:40:02+0200 stat/nodemcu02_B3D47D/POWER ON
2020-10-14T13:42:51+0200 stat/nodemcu02_B3D47D/POWER OFF
2020-10-14T13:43:00+0200 stat/nodemcu02_B3D47D/POWER ON

mqtt2influxdb seems trying to parse that as JSON:

2020-10-14 13:40:13,994 DEBUG: mqtt_on_message stat/nodemcu02_B3D47D/POWER b'OFF'
2020-10-14 13:40:13,995 ERROR: parse json: Expecting value: line 1 column 1 (char 0) topic: stat/nodemcu02_B3D47D/POWER payload: b'OFF'
2020-10-14 13:40:16,638 DEBUG: mqtt_on_message stat/nodemcu02_B3D47D/POWER b'ON'
2020-10-14 13:40:16,639 ERROR: parse json: Expecting value: line 1 column 1 (char 0) topic: stat/nodemcu02_B3D47D/POWER payload: b'ON'

mqtt:
  host: 192.168.1.1
  port: 1883

influxdb:
  host: 192.168.1.1
  port: 8086
  database: temp

points:
  - measurement: movement
    topic: stat/+/POWER
    fields:
      value: $.payload
    #  type: "string"
    tags:
      id: $.topic

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions