Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MQTT Split topic data into many topics #588

Closed
theonedemon opened this issue Feb 20, 2018 · 6 comments
Closed

MQTT Split topic data into many topics #588

theonedemon opened this issue Feb 20, 2018 · 6 comments
Assignees
Labels
enhancement New feature or request mqtt
Milestone

Comments

@theonedemon
Copy link
Contributor

Some problem in #260
device: sonoff pow
firmware: 1.12.3 ( binary from release page )
Settings:

  • Use JSON payload
  • MQTT Client ID empty
  • MQTT Retain on
  • MQTT Keep Alive 10
{
    "current": "0.000",
    "voltage": "219",
    "power": "0",
    "reactive": "0",
    "apparent": "0",
    "factor": "0",
    "energy": "59",
    "time": "2018-02-17 21:31:17",
    "mac": "XX:XX:XX:XX:XX:XX",
    "host": "boiler",
    "ip": "10.1.1.16",
    "id": 1004
}
{
    "app": "ESPURNA",
    "version": "1.12.3",
    "host": "boiler",
    "ip": "10.1.1.16",
    "mac": "XX:XX:XX:XX:XX:XX",
    "rssi": "-52",
    "uptime": "174696",
    "datetime": "2018-02-19 22:00:59",
    "freeheap": "20136",
    "relay/0": "1",
    "time": "2018-02-19 22:00:59",
    "id": 1041
}
{
    "relay/0": "0",
    "time": "2018-02-19 22:04:43",
    "mac": "XX:XX:XX:XX:XX:XX",
    "host": "boiler",
    "ip": "10.1.1.16",
    "id": 1049
}
{
    "vcc": "3160",
    "time": "2018-02-19 22:00:59",
    "mac": "XX:XX:XX:XX:XX:XX",
    "host": "boiler",
    "ip": "10.1.1.16",
    "id": 1042
}
@xoseperez
Copy link
Owner

Same explanation as in #260. JSON payloads are grouped by time, they all have a group of sensor/relay/heartbeat data plus some metadata.

@theonedemon
Copy link
Contributor Author

I use MQTT Dash and create button with option:
name: button
topic: boiler/data
json parse: $.relay/0
public topic: boiler/relay/0/set

and indicator always red ( off mode ):

{"app":"ESPURNA","version":"1.12.3","host":"boiler","ip":"10.1.1.16","mac":"XX:XX:XX:XX:XX","rssi":"-55","uptime":"88585","datetime":"2018-02-20 23:15:26","freeheap":"20152","relay/0":"1","time":"2018-02-20 23:15:26","id":4071}
```json
with id=4071 recieved message id=4072 at the same time:

```json
{"vcc":"3149","time":"2018-02-20 23:15:26","mac":"XX:XX:XX:XX:XX","host":"boiler","ip":"10.1.1.16","id":4072}

other indicators ( voltage, apparent ) works correctly.
Is it possible to make all metrics come in one json-message?

@xoseperez
Copy link
Owner

This is controlled by the MQTT_USE_JSON_DELAY and MQTT_QUEUE_MAX_SIZE setting in general.h. Messages within 100ms are grouped up to a max of 10 messages. Changing the MQTT_QUEUE_MAX_SIZE to something like 20 will probably group them.

@xoseperez xoseperez added the mqtt label Feb 26, 2018
@xoseperez xoseperez added this to the 1.12.4 milestone Feb 26, 2018
@xoseperez xoseperez self-assigned this Feb 26, 2018
@xoseperez xoseperez added enhancement New feature or request staged for release labels Feb 26, 2018
@theonedemon
Copy link
Contributor Author

theonedemon commented Feb 26, 2018

Sorry, but is solution not work
i tested on witty-cloud and set MQTT_QUEUE_MAX_SIZE = 20

{
    "analog": "355",
    "time": "2018-02-26 21:20:05",
    "mac": "XX:XX:XX:XX:XX:XX",
    "host": "witty",
    "ip": "10.1.1.17",
    "id": 3007
}
{
    "app": "ESPURNA",
    "version": "1.12.3",
    "host": "witty",
    "ip": "10.1.1.17",
    "mac": "XX:XX:XX:XX:XX:XX",
    "rssi": "-70",
    "uptime": "307",
    "datetime": "2018-02-26 21:20:13",
    "freeheap": "19760",
    "relay/0": "1",
    "color": "#FF0000",
    "rgb": "#FF0000",
    "hsv": "0,100,100",
    "brightness": "255",
    "channel/0": "255",
    "channel/1": "0",
    "channel/2": "0",
    "time": "2018-02-26 21:20:13",
    "id": 3008
}

@xoseperez
Copy link
Owner

These are two different messages, for the analog sensor and the heartbeat. Unless they happen within a time window of 100ms they will be sent separately. Please mind that JSON output does not mean that there will only be one message with all data in it. It just means that close-in-time messages will be grouped in a single message.

@xoseperez
Copy link
Owner

This is staged for release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request mqtt
Projects
None yet
Development

No branches or pull requests

2 participants