Driver Storing State

I just switched from SmartThings to Hubitat for the hub in my RV mainly because I use cellular internet and the connection is not always on. So far so great!

My RV has a Magnum MS2012 Inverter which uses a MagWeb module to report system values back to the Magnum mothership. The only way I can see this data is to access the Magnum site (which won't work when I'm offline for days camping with no internet) or I can scroll through some values on the inverter's remote but that has no history.

I've been able to build a driver that makes a socket connection to the MagWeb module every 30 seconds to read the system values and save them to the state variable. I can then use these values in various other rules such as shutting off fans/lights when battery is low, etc. I am get a long hex string which I'm parsing down to a couple dozen values:
234D15437F19DBD1010101FFFFFFFF0701FFFF06400000840002770001003B1627222300000002580000052892001E1C060070BE92000F1438143814007601DA7A12C3544DA1A19FF297DCF26A78DA7A50D1D291A5D15A143800001E0001254300850EB88FC1050D3805360082046305FCFF7E523200150A01F00B066D0A3C => battery %, charging rate, generator status, etc.

Now my current dilemma is finding the best way to save that hex string for future analysis. I'd like save that data so I can visualize it in something like Grafana (which I'm already running in my main home) and compare it against GPS coordinates and the weather at the time. Power and internet are concerns so I can't count on being able to consistently upload to an offsite server and I can't run a full webserver 24/7. I'd like to be to cache and then send it off once a day or week when I have internet. It would only be about 720kb/day or 5mb/week.

Setting up a Raspberry Pi is one option but I'm trying to avoid yet another device. Is there any way to do this with the Local Files access that was added in 2.2. Anyway yet to read/write to the File Manager from a driver?

Officially, files can only be read/written by rules, so that part of the answer is "no," but there are unofficial attempts to provide an interface to this via other means. Personally, I'd wait until Hubitat offers something officially, though there is of course a chance they may not (the feature is relatively new, and we were told they just want to see what kinds of things people use it for first).

However, I'm not sure you'd need that for what you're doing. State is a good place to store things your driver cares about but that users won't really need for automation, i.e., things the driver might just want to store internally. If this information would be usable to you as a Hubitat user, and more specifically if an app might want to read the values or subscribe to events (changes), then using an attribute is probably more appropriate. Hubitat has lots of standard attributes (and commands) defined by the available standard capabilities, but you can always use custom attributes (or commands) if the standard ones are not sufficient. In any case, what an attribute would allow you to do is use an app in conjunction with these values--including an app that makes use of one of the database solutions people sometimes use for Grafana and similar (there's an InfluxDB + Grafana thread here that seems to be the most popular, though there are probably others I haven't seen). Along those lines, HubiGraphs is a recent community offering that you might also want to check out (no external "server" required, though this might be less appealing to you since you do already have something set up that could do this).

Thanks for this information!

I already have a few of the key values going to standard attributes (battery%, voltage, power, energy, switch). Even if those are the only ones I was able to save I would be fine, I don't actually need the full hex string since many of the values are the inverter settings that rarely change.

I just briefly looked at HubiGraphs but hadn't had a chance to thoroughly dig into it yet. I'm also still working on getting a VPN set up on the RV hotspot so I can actually work on Hubitat without being on the network.

Also I saw InfluxDB come up in my searches but I just assumed it would need a separate server. or am I mistaken on that? If it is somehow running on the Hub w/ Grafana that would be epic. Is there a good thread you'd recommend I can start reading about that...

This thread is where I've seen most of the info I've read, though I'm sure there's more I haven't: Share Your Data Logging and Visualization Implementations. You would need a separate server (than the hub, I mean) for InfluxDB (or whatever you choose to handle that part), which I guess I wasn't sure whether you already had or just Grafana. I wish I could speak more to how this works for me, but I gave up on this idea early on and just kept using Home Assistant for this purpose, which I used for a bit before Hubitat and never quite gave up on because I liked its built-in history graphs. :slight_smile: (And that's all it does for me anymore. Yes, I'm using a full-blown home automation platform for only this side benefit.)

InfluxDB looks like a headache waiting to happen.

So Hubigraphs Long Term Storage is the way to go for me. The dashboard integration is seamless and the setup was easier than I imagined.

1 Like

I also have a Magnum Inverter with the Mag Web wireless and would love to be able to have access to its information. Care to share your driver?

Thanks!

I know it has been awhile since this was originally posted, but I too have a mag web. @anthonyou can you share how you enabled a socket connection and picked up this data?