stas-demydiuk / ewpe-smart-mqtt

MQTT bridge for EWPE Smart powered devices
MIT License
64 stars 26 forks source link

JSON parse issue #36

Closed Onyxxed closed 1 year ago

Onyxxed commented 1 year ago

My npm service crashes with this error when trying to use the /set function to control my ac. SyntaxError: Unexpected token P in JSON at position 1 The error occurs at index.js file at line 72.

What i tried to do: mosquitto_pub -h localhost -p 21883 -t ewpe-smart/MyAcCidHere/set -m {"Pow":1, "SetTem":24}

The port is changed from 1883, and everything else works just fine, just cant control the ac.

A little help would be greatly appreciated :)

Edit: I am currently on xenomes /fix branch which helped me to start the service without crashing. @stas-demydiuk @Xenomes

FIX: What ended up working for this was adding single parentheses around mosquitto message (Json payload) ie: '{"Pow": 1}'

Xenomes commented 1 year ago

The command is wrong try: mosquitto_pub -h localhost -p 21883 -t ewpe-smart/MyAcCidHere/set -m {\"Pow\":1, \"SetTem\":24}

Onyxxed commented 1 year ago

The command is wrong try: mosquitto_pub -h localhost -p 21883 -t ewpe-smart/MyAcCidHere/set -m {\"Pow\":1, \"SetTem\":24}

Ah, thanks for the reply, i just got it working by adding single parentheses around json payload.

Xenomes commented 1 year ago

Yes is saw it, was make the comment and reserved the mail 😆 If it works it works.