I'm expecting a JSON msg to be parsed with Python along these lines to come in through MQTT:
{"OPTION1": "0", "OPTION2": "50", "OPTION3": "0", "OPTION4": "0"}
Depending on the circumstances, these options may or may not be parsed through Python into the JSON msg, and as such, it may end up looking as:
{"OPTION1": "0", "OPTION3": "0", "OPTION4": "0"}
And thus skipping OPTION2 and it's value entirely.
To avoid my script borking out on my, I was thinking of scanning if the option is there first, before setting it, like so:
if data['OPTION1']:
>do something here<
else:
continue
However, this doesn't seem to work, it comes up with:
File "listen-mqtt.py", line 28
continue
SyntaxError: 'continue' not properly in loop
Any help would be really appreciated! Thanks.