I'm trying to write a device driver for my OpenEVSE, which uses MQTT as one of its possible network interfaces. I'm not a programmer at all (I've written some HTML and CSS years ago, but nothing more than that), so I'm sure there's a lot of understanding I'm missing. I've looked at the existing HE MQTT device drivers people have written, and where I'm stuck right now is with mapping. I've read through the Hubitat docs, the SmartThings docs, and some Groovy docs, and I can't figure out how to connect the OpenEVSE MQTT output to something HE can deal with in a useful way. My Googlefu is failing me on finding anything at all similar to this in HE or ST or Groovy generally.
What I'm hoping to do eventually is get the entire OpenEVSE network control protocol (called RAPI, open_evse/rapi_proc.h at development · lincomatic/open_evse · GitHub) into this driver, but to start I just want to read the status output (plugged in status, current amps, pilot amps, and temperatures) and display it in a dashboard. For example, when I look at the MQTT output in MQTT Explorer, this is the map I've come up with for the plug-in status:
def statusMap = [
"0" : "Unknown",
"1" : "Ready/Disconnected",
"2" : "EV Connected, not charging",
"3" : "Charging",
"4" : "Error",
"254" : "Waiting/Paused/Asleep",
"255" : "Disabled"
So, the EVSE's MQTT output gives a status of "3" when the car is actively charging, for example. Where I'm stuck right now is how to actually use this map. How do I get Groovy to parse the MQTT message, convert "3" into "Charging"/etc., and then generate an event from that?
The other possibility I'm looking at for this status output is to use the "UltravioletIndex" capability, which ranges 0-255 like this, and then map that onto the text values. Same question - is this doable, and if so, how?