Some Bits: Nelson's log

9 posts in December 2021

Customizing a Raspberry PI Zero 2 W for PVS6

Awhile back I set up a Raspberry Pi to be a gateway to get access to my SunPower PVS6 monitoring system. That’s going great; the extra status info is really helpful and interesting. (Bonus screenshot below). I just bought a Raspberry Pi Zero 2 W to be the new computer for this. It’s so tiny it’ll fit entirely in the PVS6 box, powered by the USB that’s in there.

It works! The wifi is pretty flaky, despite me getting an amazing -30dB signal. It seems to be a problem with one specific access point, need to tinker some more. (Update: it may be wifi power saving.) The cable mess is pretty janky but it’s going to be shut inside a box, not sure I care. A smaller ethernet adapter would sure be nice.

Here’s my detailed software notes on setting this up.

  1. Mostly I’m just following this guide
  2. Use the RPi image installer to burn RPi OS Lite to a new SD card. Note this is a 32 bit OS.
  3. Create and configure a wpa_supplicant.conf file on the DOS partition of the SD card
  4. Create an empty ssh file on the DOS partition
  5. Boot the RPi, find its IP address via my DHCP server. (The name raspberrypi.local might also work.)
  6. Log in with ssh as pi/raspberry. Ignore locale complaints.
  7. Change the password for pi
  8. Become root
  9. apt update; apt upgrade. (This takes awhile!)
  10. Enable console autologin using raspi-config
  11. Fix locale using raspi-config
  12. Change the hostname to “pvspi0” using raspi-config
  13. Edit /etc/dhcpcd.conf so the ethernet is not used as a gateway
  14. apt install chrony
  15. apt install avahi-daemon
  16. Disable wifi power saving
  17. Reboot the pi
  18. Log in to pvspi0.local using pi/newpassword.
    Note mDNS takes awhile to start working, a minute or two after the RPi starts up
  19. Install haproxy
  20. Configure /etc/haproxy/haproxy.cfg. I did not include stats.

A brief note on power consumption. Idle the RPi Zero 2 W seems to use about 165mA (at 5W). Running stress-ng -c 4 peaked at 570 mA. The magic number here is 500 mA, that’s the minimum power for a USB port. I expect the system to basically be idle all the time so I think I’m safe with no extra measures. But some ideas on reducing power consumption.

  • Turn off HDMI. Instructions don’t work.
  • Turn off LEDs
  • Use fewer than 4 cores
  • Turn off unnecessary daemons. bluetoothd, hciattach (the serial console)

Here’s the bonus snapshot of some of my Grafana config. Not running on the RPi; all its doing is proxying requests. These graphs are centered on showing the status of all 28 separate panels, something you can only do by accessing the PVS6 data directly.

Faking Geolocation in Firefox

One mild annoyance with Starlink is geolocation doesn’t work very well. A lot of sites identify me by my IP address, which is the satellite base station somewhere near Winters, CA 100 miles from me. Even if they use the browser’s geolocation API to get my location my computer, since I don’t have a WiFi connection Firefox seems to fall back on that same IP based location.

Anyway, there’s a simple solution in Firefox. Open the URL about:config and search for “geo”. Edit the value of geo.provider.network.url and change it from the default (a Google service) to a static answer. Here’s what I use, for Grass Valley:

data:application/json,{"location": {"lat": 39.22, "lng": -121.06}, "accuracy": 1000.0}

Note this JSON blob is not a Javascript Geolocation API response; it must be some special backend API. Mozilla has their own location API, I wonder why they use Google’s in Firefox?

It’d be nicer to have a browser extension to manage this for me. There used to be a consensus open source choice, Location Guard, but it hasn’t gotten an update for two years. There’s a bunch of spammy looking clones on the Firefox store I won’t trust. Location Guard might still work but when I briefly tried it I couldn’t see how to give out a specific location, only enable their privacy fuzzing.

Note that browser location spoofing won’t be good enough to fake out sites that really care what your location is. They’re probably using your IP address to locate you, or some other more devious means. But it’s a nice solution for ordinary apps that are just trying to do something simple.

Also note setting a single static location is probably a bad idea for a mobile device like a laptop or phone.

underscore DNS queries

Wanted to document this learning as more than some tweets.

The amazing Julia Evans launched Mess with DNS, a little sandbox where you can register some domain names and then see what queries their DNS server of record gets. Great tool for learning.

I learned something! When I did a single A query at home on Sonic.net using their DHCP servers, Mess With DNS sees six queries all at once

That seems like an awful lot. There’s several mysteries here, but the one I focussed on was that query for _.lily6.messwithdns.com. Underscores are generally understood to not be valid in domain names, although the underlying DNS protocols do seem to allow them in some places. But why would a query for a normal subdomain also produce a query for _?

A simple way to reproduce this is
$ dig @50.0.1.1 nelson.lily6.messwithdns.com a
That’s a different Sonic resolver than I use. It only results in two queries, not six, but it still generates that underscore query.

I put the question out on Twitter and on Hacker News and got two useful replies.

First, a reply from a product manager at Cloudflare who very kindly looked in his logs for similar queries and reported.

Over the last ~5 minutes I see ~12 queries per second on average (globally) to 1.1.1.1 for _.www.google.com and ~3 QPS for _.www.cloudflare.com - which is effectively noise.

So that’s interesting. Those queries do exist but they are not very common.

As for what causes them, the Hacker News discussion came through. Several folks all pointed out this is something Bind9 does with the “QNAME optimization” option turned on. One Sonic engineer even explicitly confirmed that was the DNS server they use and the source of the queries.

So what do they mean? QNAME Minimization is a privacy thing in recursive resolvers. If you’re querying foo.bar.example.com at some point you end up asking the .com root server for information. But there’s no need for them to see the whole domain name, so you just send the minimum you need (example.com, I believe.)

That still doesn’t explain the underscore. TBH I don’t really understand it. The Bind9 code is here but there’s few comments. However I was able to find the commit that added it and the comment says

qname minimization, even in relaxed mode, can fail on some very broken domains. In relaxed mode, instead of asking for “foo.bar NS” ask for “_.foo.bar A” to either get a delegation or NXDOMAIN. It will require more queries than regular mode for proper NXDOMAINs.

So that seems to be the answer. It’s not great that this workaround for “some very broken domains” ends up doubling the name server traffic for the rest of the Internet, but here we are.

For completeness, several people pointed to RFC 2782 or RFC 8552. (It’s one of first Google search results for “underscore dns”.) That RFC is about using _ to mangle some other tokens to not collide with domain names; they are used when querying things like _tcp or _udp. I’m pretty sure that’s not what’s going on here.

I’m grateful to have gotten replies from someone at CloudFlare, my ISP, and the author of the QNAME Minimization RFC. It’s nice to be able to get an answer from actual experts.

Gaming: Starlink vs Path of Exile

I’ve been using Starlink since March. I’m also a gamer. While Starlink has gotten a lot better for gaming it’s still not perfect. See this lag graph for an example. Basically every few minutes the game freezes for a second or so and I’m 95% sure it’s Starlink packet loss. It doesn’t make the game unplayable but it is annoying.

https://i.imgur.com/6Xi4Xk8.png

Path of Exile is unusual in that the default network mode is lockstep. It only draws a frame if it receives a network packet from the TCP stream, so any packet loss and retransmit delays is immediately visible. Most games compensate for network flakiness by guessing at what probably should have happened and then catching up once the network resumes again. PoE has the option to do that too, but by default they show you exactly what’s coming in on the network. No packets, no updates.

So it’s a nice example of how Starlink’s momentary outages can cause problems. You won’t notice it streaming a video or loading web pages. You’ll see occasional hiccups in a live videoconference. In PoE you see little lag spikes.

I have more proper monitoring for similar loss: see my latency graph based on sending 5 pings at once every 5 seconds. Each red dot is packet loss. It’s really quite good but you see some latency spikes and a few lost packets here and there.

https://i.imgur.com/fNh1BVP.png

(I also posted this to Reddit.)

Small multiples in Grafana

I learned how to make lots of little graphs in Grafana 8 today. It’s a bit strange but I figured it out thanks to this video on variables and these docs. Here’s a visualization of the power production of all 28 solar panels on my house. Some of those panels aren’t doing a lot of work in the morning; hope it’s better in the summer!

The first step is to declare a variable. You do this in the dashboard settings. In this case I wanted to create a variable named “inverter” which has 28 possible values, one per serial number. I’ve already stored the serial numbers as tags in my Influx data so this Influx Query will get at them

show tag values from pvs6_inverter with key=SERIAL

When you do this Grafana will magically add a little selection UI to your dashboard. You can configure whether there’s an “All” option and whether multiple sections are allowed when you define the variable.

Then you need to make a Grafana panel for the graph that is parameterized by that variable. This is as easy as adding a where SERIAL =~ /$inverter$/ to the query for the graph data; you can do this via the graphical query builder. Once you’ve done this you can choose which graph you want to see, but there’s still only one panel with one graph.

The last step is to enable repetition. This is under “Panel Options / Repeat Options”. You choose which variable to repeat by, then what layout you want. “Horizontal” actually means vertical too; I have it set to 6 max per row and it creates multiple rows automatically. Then go back to the dashboard view and select “All”. You should see all your panels. It’s a little wonky about reloading on changes, you may have to do something to force the UI to refresh.

The last bit of polish I did was to remove all the decorations from the graph I could to get it to display more densely. No title, hide the legend, no Y axis. I switched to the Graph (old) widget because I couldn’t figure out how to hide the X time axis in the new Time Series graph. The only thing I couldn’t do was change the padding of the graphs themselves; there’s more whitespace than I’d like. But it’s not bad and I appreciate how much UI work Grafana does, so nicely.

Firefox compat hacks

This is news to me. The Firefox page at about:compat shows a bunch of cases where they spoof their User-Agent to get websites to work better. Also other hacks. The most recent one in Firefox 95 is to pretend to be Chrome for Slack so that Slack enables some features. What a terrible kludge on top of a kludge.

The “Overrides” seem to be about tricking websites into enabling features that for some reason are disabled on Firefox. The Interventions seem more targeted, patches for bugs in sites like a CSS hack that prevents some badly performing overdraws on Zillow.

This all reminds me of the hacks Microsoft does to keep broken apps working on Windows.

InfluxDB 1.8 schemas

I’m using Influx more and more for system monitoring. I’m setting up a new system to monitor my solar system and realized I don’t understand Influx data schema. Here’s my notes, based on the docs. This is for Influx 1.8; I think it’s broadly the same in Influx 2 but I’m not sure. Their docs are really quite good but I had to summarize it here to understand it.

Influx schema concepts

I’m going to follow those docs’ example: you have two scientists (langstroth and perpetua) conducting a census, recording observations in two locations (1 and 2). Each observation records two things: the count of butterflies and the count of honeybees. Observations are timestamped. Note the term observation is something I made up; it’s not an InfluxDB term. The question is how you store a bunch of observations in Influx.

Influx feels a little free-form and schemaless but really it’s pretty structured. Each observation is a row. Every row has a bunch of columns in it that boil down to key/value pairs. Rows can have different numbers of columns in them. Here’s all the components of an Influx schema

  • Measurements. These are more or less like tables in databases. You have one Influx measurement for each observation. In a traditional relational database you’d have a table per kind of data and a row for each observation. In our example there’s one measurement called “census” that records all the observations.
  • Timestamp. An integer, in nanoseconds. Signed 64 bit numbers from the years 1677 to 2262. In a table database you’d have a column named timestamp. It’s probably indexed.
  • Fields. These are the measured data for each observation. Fields have keys (names like “butterflies”) and values (numbers like 12). Field values can be strings, floats, integers, or booleans. In a table database you’d have one column per field with the column name being the field key and the values being the field values. There’s probably a lot of different values for field values. Field values are not indexed.
  • Tags. These are labels for the observations. Tags also have keys (names like “scientist” or “location”) and values (strings like “langstroth” or “location 1”). In a relational database you’d also have one column per tag, named by the tag key and with the tag value stored in the row. There’s probably only a few values for tag values. Tag values are indexed.
  • Series. A series is the name for all of the measurements that match the same measurement name and tag values. A series isn’t a thing you create explicitly, it’s implied by the set of values of tags. Ie: one series is “all of langstroth’s observations in location 1.” There’s no direct analog for a series in a relational database, but it’s the kind of data you’d regularly query.
    select timestamp, butterflies, honeybees from census
    where scientist = langstroth and location = 1

InfluxDB is schemaless in that you can create new series without having to define them first. Insert some new data with a new measurement name and tag values and it will make a new series. Each measurement can have its own collection of fields with values of various types.

In practical use it’s a pretty close match to how we use tables for storing observations in a relational database. The big difference is the distinction between tags and fields; some of the columns are independent variables like who took an observation and some are dependent variables like the count of butterflies.

Designing my solar schema

Going back to my solar monitoring project, the whole reason I’m looking at this is the code I found creates a whole lot of measurements when I think it should create one.

For example there’s a measurement named “sunpower_pvs_inverter_operating_frequency_hertz” and a different one named “sunpower_pvs_inverter_heatsink_temperature_celcius”. Each measurement then has a single field typically named “gauge” where the actual data is stored, a number like the temperature or frequency. That feels clumsy to me, maybe it’s a consequence of the data being cast in Prometheus format?

To me it feels more natural to have a single measurement named “sunpower_pvs_inverter” and for each observation to have two fields with keys “operating_frequency_hertz” and “sunpower_pvs_inverter”. Each field would store the data directly; no “gauge”.

I agree more with the tag design of the code I found. For instance I have 28 inverters and these are represented in the data with tags like device_id=E00100128000007. But they went overboard with tags; there’s separate tags for software version, URL the data came from, etc. This might come in handy with a complex hetereogeneous system but it’s confusing complexity for my simple system.

Here’s the schema I think I want. It kind of tracks the schema implied in Sunpower’s own JSON output from the device_list call. Just four measurements.

PVS status. This is information on the monitoring computer itself. No tags needed, some field keys:

  • SWVER dl_err_count dl_comm_err dl_skipped_scans dl_scan_time dl_untransmitted dl_uptime dl_cpu_load dl_mem_used dl_flash_avail

Production. This is measuring data from the PVS6 CT sensors on the solar power production power line and has type “PVS5-METER-P” in the JSON. I don’t think I need any tags at all for this. Some field keys I will record values for:

  • STATE p_3phsum_kw net_ltea_3phsum_kwh freq_hz s_3phsum_kva q_3phsum_kvar p_3phsum_kw

Consumption. Again CT sensors, this on the house consumption side independent of the solar. This has type “PVS5-METER-C” in the JSON. There’s two values for many things because I have a split phase system with different sensors on each side. Some interesting values:

  • STATE net_ltea_3phsum_kwh p_3phsum_kw q_3phsum_kvar s_3phsum_kva freq_hz i1_a i2_a v1n_v v2n_v v12_v p1_kw p2_kw neg_ltea_3phsum_kwh neg_ltea_3phsum_kwh

Inverters. This is the detailed data from each solar panel, there’s one JSON block for each of 18 panels. Some values:

  • STATE SERIAL ltea_3phsum_kwh p_3phsum_kw vln_3phavg_v i_3phsum_a p_mppt1_kw v_mppt1_v t_htsnk_degc freq_hz

Inverter rollup. I might want to add a synthetic fifth measurement, something that summarizes the state of all the inverters. You could do this at query-time in Grafana or whatever but it’s probably easier to do it in the Python code which is collecting the data. Probably this is what I’d actually graph; trying to draw 28 different inverters separately seems like a mess. Some possible measurements

  • Count of working inverters
  • Sum, average and S.D. of inverter kW (both AC and DC)
  • Number of inverters well below average kW
  • Sum, average, and S.D. of inverter voltage and current (both AC and DC)
  • Average and SD of inverter temperature

I think in all cases the timestamp should be when my own monitoring code ran. Each bit of JSON data in the PVS output has its own timestamp and I bet that can matter sometimes, say if an inverter isn’t communicating correctly. But I could imagine a lot going wrong too; I trust my own clock more.

A big question for me is if I should try to filter and reprocess all the data coming from the PVS6 JSON. Or just insert it more or less as-is. Filter each JSON item into either a tag (“SWVER”) or a field (“killowatts”). That means inserting a bunch of junk into Influx I will never care to query. But then again it means not losing data, either.

Data meanings

This has nothing to do with Influx but I was trying to understand what some of these data values mean.

“LTEA” seems to stand for “life time accumulator” and is one of the few (only?) bits of data that has history. Most of the rest are instantaneous values; current watts, not watt-hours.

“3phsum” seems to refer to three phase power, presumably the sum of all three phases so you have a single number. I think my inverters are simple single phase so this doesn’t really apply, but maybe they use that word for consistency with other products. The only measurements of wattage are labelled “3phsum” so I’m gonna just ignore the details.

Raspberry Pi 4 thoughts

I got a new Raspberry Pi 4. It’s neat! Some thoughts on it. Bottom line: it’s a great little computer and my only complaint is the SD card I/O is slow.

First, context. A friend gave me an original RPi Rev B way back in 2012 or so. I’ve used it every year or two when I needed a small Linux box to do something. For awhile I had RetroPie on it for gaming. I dusted it off last week to serve as a network proxy for my SunPower PVS6 solar power monitoring system. It’s working great for that! But it’s a very slow, limited system.

So I bought a new RPi4. I got a Vilros kit that includes a case, a power adapter, heatsinks, an SD card, various cables. It’s very convenient. The core computer is $55 but the kit is $135. Probably not a great value but this was in stock at Amazon; like everything else these days, availability is not great.

The RPi4 is the first RPi capable of running a 64 bit OS. The ARM Cortex-A72 CPU in it is quite capable but nothing too exciting, but since it’s the ARMv8-A architecture it’s pretty well up to date. You have your choice of 1-8GB RAM wired on the board. And all the IO integration that makes the RPi so popular. 4 USB ports, gigabit ethernet, two HDMI ports, WiFi and Bluetooth built in, an audio jack, and of course the famous GPIO pins for hackery.

A word on cases. A nice case goes a long way to making it feel like a “real” computer. The Vilros case is a nice aluminum case that fits just right. RPi4s apparently run hot, at least when actively used. My case has an always-on fan. There’s a bunch of passive cooling cases that basically turn the whole chunk of aluminum into a heatsink, that seems like a better idea if it’s sufficient.

On power: the RPi4 uses 3-5 watts. Everyone recommends a good USB power supply, the official one is 5.1V/3.0A. Alternately the RPI4 can be powered over ethernet with a small extra board. Note 3A is a lot of power for USB; that’s a device intended for charging, not just a random computer’s 0.5A USB port.

Operating system

Vilros shipped an SD card with Raspberry Pi OS (aka Raspbian) installed. Full desktop environment. I used it for a few minutes and it seemed to work but was as unlovely as any Linux desktop. Also slow; you could see the background picture repaint when I dragged windows. I only want this as a headless server so I wiped it and put Ubuntu 21.10 server on it. How about that? Stock Ubuntu, compiled for aarch64 and with a clean boot loader. Shout out to the RPi folks for creating a great disk imager. There was also a thing called NOOBS, a small boot system which let an RPi install its own OS, but I guess that’s deprecated.

The RPi4 has some complex boot loading and firmware overlay stuff. I don’t understand it but it seems to work. USB booting is supported via a bootloader on the SD card.

One drawback with Ubuntu is it’s less clear how to tinker with the Raspberry Pi-specific stuff. Raspbian has raspi-config which lets you adjust things like clock speeds, GPU memory usage, etc. It looks like you can just edit config.txt on the Ubuntu boot partition, this works sort of like BIOS settings but for the RPi.

Another useful tool for RPi-specific hacking is vcgencmd. This lets you get at a bunch of state on the GPU, which apparently in this Broadcom implementation is controlling the whole system. This lets you get at things like how much RAM is dedicated to video (78MB for me) and what the current temperatures, voltages, etc are.

There’s a whole lot of software dedicated to working with the GPIO pins. This capability is the really neat hidden feature of the RPi and gets pretty complex as you mess with different modes of I/O: I2C, Serial, etc.

Performance

No one buys an RPi4 for performance. But it’s pretty impressive, particularly by historical standards. Unfortunately it feels slow for interactive stuff. But then I’m spoiled by fast machines with SSDs. The main issue with the RPI4 is the SD card is slow. Some comparisons to an Intel NUC based on a i5-7260U.

With the cheap SD card Vilros sent me hdparm reports about 45 MB/s. Compare 100 MB/s for a spinning disk on an Intel NUC or 1600 MB/s to SSD. I’d hoped the SD would be faster. And that 45MB/s is for synthetic tests: this blog post says 7 MB/s for reads for random access reads. SD cards are clearly not a fast medium. This blog post suggests 100-300MB/s with a proper SSD drive plugged in to USB 3, which is big boy PC speeds but nothing amazing. The RPi4 can boot off USB so you can eliminate the SD entirely if you want. It’s too bad they don’t have an NVMe interface, but then that’d require a PCI bus. (The Compute Module product does have one.)

Another word on I/O: older RPis implemented ethernet on the USB bus so performance was severely limited, particularly if you wanted to use it as a router with multiple ethernet interfaces. Raspberry Pi 4 has a dedicated channel for its ethernet separate from USB, so that helps.

RAM is reasonably fast. Testing with sysbench I get about 4GiB/s on the RPi 4; compare 17GiB/s on the Intel NUC.

CPU is impressively fast. Again testing with sysbench, using one or two threads the RPi was about 1.35x faster than the i5-7260U. With 4 threads the RPi is 1.6x faster. The Intel CPU is 4 threads but only 2 real cores; the RPi4 has four cores. I have no idea if this is a real world CPU benchmark, probably not.

I played around with overclocking a bit. Boosting CPU speed from 1500MHz to 2000MHz gave me about 1.3x speedup. Max temps were 45C and 52C respectively. Then I found the arm_boost=1 config.txt setting, which apparently gets you 1800MHz as a temporary boost with extra voltage. I don’t normally overclock but since they say it’s safe I’ll leave that enabled.

I found a note in the docs that suggests there is no hardware support for video decoding.

Thoughts

What an impressive bit of kit. What I like best is how contained it is; a small pack of cards running a real 64 bit Ubuntu with zillions of hardwaer ports. The only drawback from a conventional computing point of view is you’re limited to USB 3 for disks. And hell that’s not bad at all, with an SSD significantly faster than computers I was using on the daily a few years ago. If I were using the RPi 4 interactively I’d be sure to set up USB booting to a fast disk.

But I’m not using it interactively. In fact I probably won’t use this RPi4 much at all. The old RPi B is doing fine as my proxy device. But now I’ve got this little swiss army knife computer sitting around for the next project where I need something this flexible. I’d like to learn more about ARM as a practical server platform. Or maybe I’ll use it as a web a server for my plotter. Or a base for some home automation tinkering via those tasty GPIO pins.

One other thought; the RPi 4 is the flagship product but there’s other devices. The Raspberry Pi Zero 2 W is a smaller, cheaper system suitable for less demanding uses (like being a web proxy). I/O ports are limited but for a certain type of application it might be more suitable. There’s also a Compute Module which looks like an RPi 4 only without all the I/O ports (and with the SD card built in). I think this may only be of interest to folks designing embedded systems.

Getting local access to SunPower PVS6 data

Tinkering with my new solar system. The install includes a fancy SunPower monitoring system called a PVS6. SunPower has a decent website which gives you current conditions and hourly history of energy production. But I want more detailed data! And thanks to this guide I’ve got access and am starting to unpack what all is there. This GitHub project also has lots of notes and this PDF is quite detailed.

Access to monitoring data

The PVS6 has a web server with stats you can access over the network. The trick is you have to use the LAN1 installer port to get to it. You don’t want to just plug it into your network; it has a DHCP server of its own that might make mischief. So instead I set up a Raspberry Pi with haproxy to forward HTTP requests to the PVS6. The guide I followed has detailed instructions and now I have access to the PVS6 web API.

So what’s there? The notes here are a detailed guide. The main command for monitoring is DeviceList. Apparently most of the data updates every 15 seconds. The JSON output is complicated, but it boils down to a block for the PVS itself, a block for each CT sensor measuring overall electricity flow, and a block for each inverter (28 microinverters for me). Note it’s pretty slow, about 6-7 seconds to answer a DeviceList query.

The numbers I get from the PVS6 do seem to match what SunPower shows me in their consumer app.

sunpower-pvs-exporter

At this point I took a left turn and decided to install this monitoring setup. It’s a Python project that creates a Prometheus service from the PVS6 data, which Telegraf can import. The project also includes some Grafana dashboards. Looks nice!

I installed sunpower-pvs-exporter directly on the Raspberry Pi, no need for haproxy in the path. Then I set up telegraf to query it (just need to configure the URL) and insert the data in to InfluxDB. The resulting schema is a bit messy; Grafana is now polluted with lots of measurements with names like sunpower_pvs_power_meter_net_energy_watt_hours. And a whole lot more series inside that, and the values all are named “gauge”. Not awesome but I can work with it.

Unfortunately importing the sample dashboards from the project did not work. Some config did come through but not the queries. (Schema mismatch?) I hand-edited a few and got some stuff working but it’s not great. Also the schema is not a great match for Grafana so the queries are pretty contorted. All told I got discouraged at this point; if I’m going to have to do this much hand-work I might as well write my own code to pull data straight from the PVS6 JSON and output it in nicely aggregated Influx format.

Mysteries

My solar install has something weird; their estimate of my usage is wrong. They seem to think that in the middle of the day I’m using 6kW, 3-4x more than I use. Also usage goes up with solar power. I think maybe the CT sensors aren’t installed correctly. Or maybe this has something to do with not being fully activated at PG&E? The electric meter display looks correct, just not the SunPower monitoring, so I’m thinking I have an install problem.

The other confusion is arithmetic. I have one CT power meter labelled “GROSS_PRODUCTION_SITE” and one labelled “NET_CONSUMPTION_LOADSIDE”. That’s what’s graphed in the picture above, those two numbers. But note that’s net consumption; if you want gross consumption you need to add those two numbers. That’s baked in to the sunpower-pvs-exporter’s queries but it confused me at first. Particularly since my net consumption numbers from the power meter seem to be wrong.

jq

I took a quick crack at getting basic wattage output with JQ. This dumps the wattage of all the things in my report; the two meters and also the individual inverters.

jq '[.devices[1:][].p_3phsum_kw? | tonumber * 1000 | round] | @csv'

p_3phsum_kw appears to be the actual AC power production. I assume that means “3 phase sum”. It seems to account for reactive loads.

Thoughts

At this point I’m declaring victory for the day. I’ve got access to the data. I still need a system to massage it and import it into InfluxDB and I don’t think sunpower-pvs-exporter is it for me. Too many problems. Telegraf’s JSON plugin might be sufficient but I’ll probably end up writing my own Python code so I can massage things as desired. In particular I’m trying to think how to handle the data streams for all 28 inverters, that seems a bit unwieldy.