naruxde/revpipyload

Payload customization

Opened this issue · 1 comments

I think it would be useful to add the timestamp to the payload. Moreover, it would be an easy task. It is enough modifying this line (if i am not wrong):

self._mq.publish(self._mqtt_io.format(io.name), int(value))

Regards,

Well, maybe it would be cool to add an extra topic with a json object?

Maybe the topic ../json with a payload like this:

{
  "timestamp": 1647083416.5863497,
  "io": [
    {
      "name": "RevPiStatus",
      "value": 1
    },
    {
      "name": "RevPiIOCycle",
      "value": 5
    },
    {
      "name": "RevPiLED",
      "value": 0
    },
    {
      "name": "t_aus",
      "value": 1
    },
    {
      "name": "t_an",
      "value": 0
    },
    {
      "name": "t_links",
      "value": 0
    },
    {
      "name": "t_rechts",
      "value": 0
    },
    {
      "name": "t_hoch",
      "value": 0
    },
    {
      "name": "t_runter",
      "value": 0
    },
    {
      "name": "t_blau",
      "value": 0
    },
    {
      "name": "t_rot",
      "value": 0
    },
    {
      "name": "I_9",
      "value": 0
    },
    {
      "name": "I_10",
      "value": 0
    },
    {
      "name": "I_11",
      "value": 0
    },
    {
      "name": "I_12",
      "value": 0
    },
    {
      "name": "I_13",
      "value": 0
    },
    {
      "name": "I_14",
      "value": 0
    },
    {
      "name": "I_15",
      "value": 0
    },
    {
      "name": "I_16",
      "value": 0
    },
    {
      "name": "O_1",
      "value": 0
    },
    {
      "name": "O_2",
      "value": 0
    },
    {
      "name": "O_3",
      "value": 0
    },
    {
      "name": "O_4",
      "value": 0
    },
    {
      "name": "O_5",
      "value": 0
    },
    {
      "name": "O_6",
      "value": 0
    },
    {
      "name": "O_7",
      "value": 0
    },
    {
      "name": "O_8",
      "value": 0
    },
    {
      "name": "h_an",
      "value": 0
    },
    {
      "name": "h_richtung",
      "value": 0
    },
    {
      "name": "h_hoch",
      "value": 0
    },
    {
      "name": "h_runter",
      "value": 0
    },
    {
      "name": "h_blau",
      "value": 0
    },
    {
      "name": "h_rot",
      "value": 0
    },
    {
      "name": "O_15",
      "value": 0
    },
    {
      "name": "O_16",
      "value": 0
    },
    {
      "name": "PWM_1",
      "value": 0
    },
    {
      "name": "core.a1green",
      "value": 0
    },
    {
      "name": "core.a1red",
      "value": 0
    },
    {
      "name": "core.a2green",
      "value": 0
    },
    {
      "name": "core.a2red",
      "value": 0
    }
  ]
}

We could add a timestamp the IOs and other things, what do you think?