Parse the salt please, or at least the sector declarations


So, I spent some time on how to parse zone commands for the sprinklers in the form “sector1=1,sector3=4,sector2=0,sector3=1”, from the google calendar event titles, into mqtt commands for the WeMOS nodes.

Regex have never been a favourite of mine, being a clunky solution from hackers for hackers.

While it is a small problem to solve I still wanted to do something smart so I looked around for a parser generator for javascript.

I came across pegjs.

Brilliant!

Though, as usual, bugger all help.

However, I started with the JSON example and parred it back to get a solution that returns an array of zones (sector/zone) to act as a fragment of an MQTT topic.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: