Fixing Display Issues on iPad with HDMI out

Several years ago when Apple released Macs with USB-C connectors, there seemed to be a lot of talk about needing a bunch of dongles to connect things. When I got my first USB-C based Mac, I only had 2 dongles and was content. Over time, I saw various USB-C hubs that had multiple USB-A ports, power delivery, Ethernet and HDMI out. I bought one and used it for everything except the HDMI out as I use an old Thunderbolt Display.

When I bought my 2018 iPad Pro with USB-C, I tried the hub on it, but was told by the support folks that the iPad Pro wasn’t fully supported; I guess the power delivery didn’t work properly. It would have been nice for it to work, but it didn’t really matter to me at the time.

Earlier this year I saw a sale on the Plugable 7-in-1 USB-C hub that had all the ports I’d ever need into SD card slots (I had been working a bit with SD cards at the time, so that seemed convenient). I used the hub with my 2017 MacBook Pro without issues, but never tested the HDMI output as I rarely took my machine anywhere.

Last month we were getting ready to go on a trip and I decided to check the hub to see if I could connect my iPad Pro to our TV in case we wanted to watch a show. The Plugable hub was advertised as iPad Pro compatible, so I had no reason to think it wouldn’t work. When I plugged it in, all the colors were messed up. I plugged in my MacBook Air and it didn’t have any problems.

Messed up display colors

I contacted Plugable’s support and they assured me it was compatible and started going through troubleshooting steps. For our trip, I brought the Plugable adapter as well as my older adapter that didn’t have the same problem. When we wanted to watch a show, I decided to try the Plugable hub and much to my surprise, it worked fine. I sent my findings along with the model number of the TV in our room and thought maybe it was a 4K vs 1080p issue.

When we got home, I tried a few more troubleshooting steps that were recommended to me and didn’t see any change. After much Internet searching, I discovered that when you plug an HDMI display into the iPad Pro, an extra option appears in Displays & Brightness for the display. Under connected displays, there is my TV, the 55R617.

Tapping on the option brought up 3 choices for Preferred Display Setting with the checked one being Dolby Vision. I selected the second option (High Dynamic Range) and boom, the picture problem cleared up!

Preferred Display Setting

I relayed this information to Plugable support and the person I was working with commended me on my sleuthing and said that was exactly the issue as the chipset used in the hub didn’t support Dolby Vision (extra licensing for it) and offered me a refund if I wanted it. I told him it wasn’t necessary (support was great and would definitely recommend their products) as I just wanted to make sure I knew how to work around the issue when I traveled.

Now I can just bring 1 hub for both my iPad Pro and my MacBook Air when I travel and hook up either device to a TV if needed. As long as I remember to bring an HDMI cable (it’s on my packing list), we should be good to watch our own content when we travel.

My Take on the M1 MacBook Air

Years ago Mac laptops were getting so much better every year that I was on a 2-3 year cycle for upgrading my machine. The performance increases helped with my productivity as it reduced compile times for my work. This increase slowed dramatically in the last decade and I stopped buying new machines so often.

When the Retina MacBook Pro was released (2012), I got a fairly loaded one (quad core i7, 16 GB RAM, 512 GB SSD). This machine was a workhorse for me for 5 years. In 2017, I bought a new 15" MacBook Pro that was kind of a mid range machine that was still a quad core i7, but had a higher clock speed. It definitely was faster, but for being 5 years newer, I really had expected more. In any case, I gave my 2012 machine to my wife (she says she doesn’t mind getting older hardware as long as it works; does she really mean it? I hope so!).

For a few years, the 2012 machine has had an indicator saying that the battery needs service, but it can still be used. We’ve ignored that for awhile as it mostly stays connected to power. Two weeks ago, the machine restarted a few times while my wife was using it to teach. My theory was that the battery was on its last legs and when the MagSafe adapter got knocked out, it lost power and restarted. That might not quite be the issue, but started me thinking about what to do with it. We had basically 2 options; option 1 was to replace the battery myself using a battery from iFixit or buy a new computer.

I’ve opened up machines before and replacing a battery should be doable. However, this machine has the battery glued in and was rated as a hard to replace. If anything went wrong, the machine was basically toast. A friend of mine saw a technician replace the battery and advised me against it. Apple put the machine on its obsolete list last year so Apple wouldn’t touch it and authorized repair centers couldn’t get Apple parts for it; so if I wasn’t going to replace the battery, who would? If the battery wasn’t the problem, getting it serviced would be near impossible. It would also be throwing money at a very old computer (9 years is a pretty long life for a laptop).

The second option of buying a new computer was the easier option, but far more expensive. My wife didn’t care if I got a new machine and she got my 2017 machine or if we got her a new machine. I asked a few friends what they would do and the answers ranged from don’t buy an M1 machine now because it is a first generation to loving his M1 MacBook Air. I had shied away from the MacBook Air for me in the past because they had been underpowered and I thought the screens were too small. These days I use an 11" iPad Pro often and don’t use my laptop all that often without it being connected to an external display, so I would be OK with the 13" display and the differences between the Air and the 13" MacBook Pro were relatively minor that I’d save a few dollars by going with the Air.

I decided to get a new M1 based MacBook Air and my wife would get the 2017 machine. While she didn’t care, I justified me getting the new machine thinking that if there were any problems with the M1, it would be better that I had them than she did as the computer is just a tool for her and she doesn’t like futzing with technology.

The machine I picked up was a 16 GB/1TB/8 GPU M1 MacBook Air. Of course I bought AppleCare+ with it as I now buy AppleCare+ on just about every Apple product that is portable. This was the least I’ve spent on a laptop (in raw, non-adjusted dollars) in a long time; did I make the right decision? Would the machine be able to handle my daily work?

After setting up the machine, I worked on getting my projects to build. While they built fine for an iOS device, they wouldn’t build for the iOS simulator due to a different simulator architecture. Unfortunately there are a few 3rd party libraries I use that I don’t have source for and needed a workaround until the libraries are updated. I did a bunch of searching and found the answer:

EXCLUDED_ARCHS[sdk=iphonesimulator*] = arm64

That magic line in my project (as well as sub projects) got me going again. A full build of one project on the M1 machine was 42 seconds; on my 2017 machine it was 1 minute 24 seconds. Wow! That’s some pretty impressive performance.

The next part of getting setup was getting a Ruby on Rails project setup. Luckily Homebrew has many packages compiled for the M1, so I installed that, Ruby and some other pieces. Unfortunately it took me about a week to figure out that I had to change the version of a library to the latest as someone committed changes to build on the M1.

I took the machine on a trip last week and I absolutely love the size and weight! Even though it is a lot smaller than my 15" machine, the screen is easy to read. The keyboard is excellent and the machine performs well in everything I’ve thrown at it. While it only has 2 Thunderbolt/USB-C ports, that’s not a problem. I have 1 connected to a Thunderbolt 3 to Thunderbolt adapter for my Thunderbolt Display and the second is connected to a USB-C hub that has a few USB-A ports, SD Card reader and power delivery.

Up until yesterday I hadn’t restarted the machine since I got it, but have had 3 kernel panics since then which is concerning to me. I’m not sure if it is related to the external hard drive I connected to perform a backup or running Cura in Rosetta 2.

As long as the kernel panics stop and performance remains as good or better than my old machine, then I’ll be a happy camper and this will have been a good purchase. When Apple releases new machines with either the M1 or a newer processor, I think they’ll be a hit. However, I’m so taken with the size and weight of the MacBook Air, I might not want to move to a larger machine even if it has better performance.

Another stab at fixing the Vizio SB36512-F6 Soundbar

About a year and a half ago, I wrote about fixing the SB36512-F6 soundbar as sometimes we just couldn’t hear anything from it. My "fix" seemed to work for awhile, but over the last few months, the problems have been worse. We would start a show using Channels or Netflix (primarily) and got no sound. Lately the volume buttons wouldn’t work (through HDMI-CEC) which is also frustrating. Through a combination of powering down the TV, changing the input on the soundbar, and powering off the outlet for the devices, we were able to get sound again.

I’ve been so frustrated with this that I’ve been on the verge of purchasing another soundbar, but waiting for a Costco sale so that I can take advantage of their return policy when it performs poorly. Today I decided to do another web search to see if others encountered the same problem. Unfortunately my original post was one of the hits! On the positive side, other posts indicated that Dolby Atmos was pretty poor on these types of soundbars which gave me an idea.

In order to get Dolby Atmos on the soundbar, I plugged the Apple TV into the soundbar’s HDMI port and then the TV into the soundbar’s HDMI ARC port. If I was willing to forego Atmos, I had more options for connecting the soundbar. Since I like HDMI-CEC for controlling all my devices, I decided to plug the Apple TV directly into my TV and then plugged the soundbar into the TV using HDMI-ARC.

Initial tests show that the setup works as expected with HDMI-CEC working for controlling volume and the power to the devices (I use power loosely as the devices are always in some type of standby mode). Will this fix my problems? I sure hope so or it is back to the drawing board on how to deal with this frustration.

It still baffles me that getting devices that adhere to standards working together is such a crapshoot. I have no idea how the average person gets any type of technology or electronic device to work.

Apple Watch 6 – My Take

When the first Apple Watch came out, I was immediately hooked. I wrote that it did everything I needed it to do. The next few generations of watches didn’t add a huge amount of value to me, so I skipped them. When the Apple Watch 4 came out, I decided to upgrade because it was waterproof, was significantly faster and could run the latest watchOS. I skipped the following year even though the always on display looked like a great feature.

This year with the pandemic, I was unable to goto the pool (last year I swam a lot and used my watch all the time being thankful it was waterproof) so I went back to running. When I run, I take my iPhone and put it in an armband carrier. This has worked well for years, but really started getting on me as I was running on an almost daily basis. When the Apple Watch 6 came out, I was torn. I didn’t need a new watch, but the blood oxygen sensor was interesting, the always on display was something that I didn’t know I really wanted (I’ve been shaking my arm for the last 5 years to get the screen to light up!) and the faster processor would make the watch more usable.

After looking at my usage pattern and selling a bunch of old stuff on eBay to cover the cost, I decided to get the GPS+Cellular version of the Apple Watch 6. Yes, I was going to have to pay an additional $10+fees per month for it, but I’d be freed a little bit from my phone tether.

I can’t say enough good things about this watch; the always on display is absolutely amazing and I can stop shaking my wrist all the time! Running (and walking) without carrying my phone is very pleasant allowing me to still be connected if need be, but not having a phone in my pocket (walks) or attached to my arm (runs). Apple is making huge strides with the processing speed of these watches with each generation. This watch is instantly responsive and Siri on it works very well.

With watchOS 7 comes sleep tracking and I’ve been wearing my watch almost 24/7 because of it. While I didn’t know exactly what my sleep pattern was, I could kind of tell when I didn’t sleep well. My watch now tells me (for the most part) if I had trouble sleeping. This, of course, isn’t exact as it is based on arm movement, but it is much better than not knowing.

Wearing my watch 24/7 causes an interesting problem with battery life. The cellular connection on my watch drains the watch faster than without it, so on days that I run or walk, I have to be aware that I have to charge my watch. In order to make it through the day, I am typically charging my watch in the morning and depending on the day, in the late evening. Some people would say that this is inconvenient, but just dropping it on the charging stand isn’t a big deal.

If I’m as happy with my Apple Watch 6 as I was with my last 2 Apple Watches, it will be another good purchase.

Toyota RAV4 Prime – The vehicle I wanted 4 years ago

When I was shopping for a car over 4 years ago, I had a few requirements including CarPlay and being a plugin hybrid. The plugin hybrid would have been perfect for my needs, but had to have around 40-50 miles of electric range.

Unfortunately I was unable to get a plugin hybrid, but I wouldn’t budge on having CarPlay. At the time, I had a Toyota Highlander and would have jumped at another Toyota, but Toyota dragged their heals on putting CarPlay in their vehicles, so I settled on the Subaru Impreza and was reasonably happy with it. However, as time went on, there were a few things that started getting on my nerves about it. The first was that it was too low to the ground. This, of course, was entirely my fault for making the decision to get a sportier car. The second was some low speed shifting issues that the dealer said were normal, Third was the local dealer; one of the service people was rude and lied to me. There are limited choices for Subaru dealers in close proximity to where I live. The fourth and most annoying problem was the infotainment system and CarPlay. I found that CarPlay wouldn’t always start and required me to reboot the system. I wasn’t the only person that had problems with the system as Subaru settled a class action lawsuit for the issues with it; I walked away with $350 which seems pretty significant for an issue that didn’t physically affect me. On various forums, people have argued that the infotainment system problems aren’t a big deal and that people don’t buy cars just for the infotainment system. Well, I’m not most people! CarPlay and the infotainment system were probably the biggest reasons I went with a Subaru instead of another Toyota.

In August, I wrote about looking for a new car. As much as I wanted to keep my Subaru for as long as I kept my Highlander (14 years), the annoyances I listed above especially the infotainment system, pushed me to long for a new car. My driving habits back when I was looking for the Impreza were pretty similar to before the pandemic whereby a plugin hybrid with 40-50 mile range would be ideal for me. I wouldn’t have range anxiety and could go on longer trips without having to plan charging stops. The RAV4 Prime fit the bill and I searched and searched for months to get one at a reasonable price. Most dealers wanted significantly above MSRP and those that didn’t had no idea when they would be getting what I wanted. However, I didn’t let that deter me.

On Black Friday, I got an alert from cars.com that I had setup and quickly sent an email to the dealer that was 90 miles away. Based on my communications with other dealers, I wasn’t holding my breath, but when I flat out refused his first price, he came down to a reasonable number. I made all the arrangements, packed the family in the car and made the drive up to the dealer. As one last middle finger to me, when I started the Impreza I could not get any volume out of the infotainment system. Luckily my wife was able to futz with it and get sound out of it again!

I’ve now had the vehicle for 5 weeks and driven it in a mix of electric and hybrid modes and like most new car owners, I’m generally pleased with it. Driving electric is amazing as it is quiet and the acceleration is unbelievable, so much so that the Toyota app has told me that I have aggressive acceleration as I’m not even aware that I’m pressing the pedal that hard!

Four years ago, I wanted a compact SUV (similar to my Highlander), plugin hybrid, and CarPlay. I finally have all that in my RAV4 Prime; I would not have thought twice about buying this vehicle if it was out back then.

Time, of course, will tell if I made the right decision and if there are any major problems with it.

A look at UL/ETL Certification and Home Automation

Ever since I can remember, my dad has told me that any piece of electrical equipment that has a cord or is hardwired should be Underwriters Laboratories listed. UL listing means that a sample of the product has undergone testing and meets certain criteria for the type of device it is. Does this mean that items that lack the UL listing aren’t safe? No, it could just mean that the company didn’t spend the money to get the product tested.

Most things you buy with a cord are UL listed, so it really isn’t a concern. However, with more and more products coming direct from overseas and being developed faster and cheaper, it is becoming more common to see mass market products lacking UL listing.

Taking a slight detour here, UL has been the predominant testing lab/certification and the one that most people recognize. However, recently more products bear the ETL mark. Edison Testing Laboratory was started by none other than Thomas Edison and performs similar functions to UL. I’ve done a bit of research and the only real difference is which service a company choses to use. ETL tests to the same standard as UL. I suspect there could be a cost or time to test difference between the two.

I’ve been very cautious about things I buy direct from overseas and even some things I buy here that aren’t from mainstream manufacturers. While a UL or ETL mark doesn’t guarantee that something is going to be safe, it gives me some reassurance that an independent lab has looked at the product.

When I went to purchase a 3D printer, the Creality Ender 3 Pro was advertised as having a UL listed power supply (older ones didn’t). This got me curious about what that meant. Components of products can be UL listed without the entire product being listed; for whatever reason the whole device didn’t go through certification. These components bear a different mark called a "listed component".

So while the power supply on the printer is UL listed, the printer itself is not. I’m not overly concerned about this as the power supply is the piece that connects to 120 V and outputs low voltage. This, of course, doesn’t mean that the printer couldn’t catch fire (I’ve seen reports of this).

For my son’s Eagle Scout project, he’s building something (I’ll post about it when it is complete) that plugs into the wall and is controlled by a low voltage circuit. We found an example of what he wants to do on GitHub where the author posted a list of components. One of the components is a solid state relay that takes line voltage (120V) on one side and is controlled by low voltage on the other. While relays are quite common, mixing low and line voltage can be dangerous. According to the National Electric Code any time low voltage and line voltage are placed in the same electrical box, there must be a plastic separator between the two. When we remodeled our house, I had to find electrical boxes that had separators as I put low voltage audio controls in every room next to the bank of light switches.

Looking at this relay, I didn’t see a UL component mark on it and even if I did, I’d be concerned about putting it in a box that had line voltage and low voltage. So in my effort to help my son (adults can help on projects and he’s asked me to handle the electrical part and some of the electronics due to my knowledge of the field), I started researching parts that are UL or ETL certified so that we didn’t have to worry about mixing line voltage and low voltage. The pieces we’re looking at are widely used in IoT devices and consist of an outlet that can be controlled by a low voltage circuit.

I’ve looked and looked and have found some standalone outlets that are listed. I came across a blog post talking about the Sonoff smart plugs that are UL listed. Excellent, I may have found what I needed. I purchased 2 of the plugs and received them last week. They didn’t have an ETL logo on them, but did have a UL logo on them. Unfortunately looking up the product in the UL database didn’t come up with anything, but it did appear in the ETL database. When I asked Sonoff about this, they said that the S31 was ETL certified and not UL listed. That’s kind of odd and the discrepancy is enough for me to send them back. I did, however, find another outlet TGWF115PQM by Top Greener that is UL listed (and is in the UL database). In addition, this plug was easily flashed with the Tasmota firmware that works with Home Assistant and I believe it will work for my son’s project.

Many of the major brands of IoT devices, including the Belkin plugs don’t list UL or ETL certification on their web pages. If they are listed, I think that would be an important fact to mention on their site. If you browse Amazon for smart plugs, you’ll see some say CE or FCC certification; this is NOT the same as UL or ETL certification. Even if they say ETL or UL listed, I’d strongly encourage people to lookup the products and verify the certifications at UL or ETL.

If you’re in the market for IoT devices, look carefully at the certification on the devices and would not order anything direct from overseas that is line voltage (I ordered a small computer last year direct and the external power supply was not UL listed so I just swapped it with another one that I had just to be on the safe side).

Stay tuned for more on the project and the journey.

Building an Air Quality Sensor

With the recent fires in California, I’ve been concerned about the air quality as it tells me if I should run, if we should go on our daily walk and if we should leave our doors open like we usually do. The EPA uses air quality sensors around the country to collect data and displays them on the AirNow website. These sensors are very expensive and therefore not placed everywhere. The air quality, of course, can differ depending on where you live and the closest EPA sensor to where I live is about 10 miles away. The EPA has started including data from low cost sensors made by a company called PurpleAir in their fire and smoke map.

With someone’s PurpleAir sensor about 0.5 miles from me, I can get a reasonable view of local air quality. Being the tinkerer that I am, I decided to look into the PurpleAir outdoor air sensor. At $279, it was a little out of my “curiosity price range”. After a little research, I was able to determine what parts are in the PurpleAir sensor. It consists of 2 Plantower PM5003 laser particulate sensors, a BME 280 temperature/pressure/humidity sensor running on an ESP8266 board.

I’ve been experimenting with the NodeMCU microcontroller which is based on the ESP8266, so I was already familiar with parts of the setup. I already have an indoor temperature sensor running on a NodeMCU, so adding a second device shouldn’t be that difficult. On my Home Assistant instance, I’m running the ESPHome add on which makes the ESP modules available to Home Assistant. ESPHome has support for lots of devices including the PM5003 and the BME280 which simplifies the software part of the setup.

In addition to purchasing the PM5003, BME 280 and a Wemos Mini d1 compatible board (ESP8266), I purchased a PVC cap to mount it. Total parts cost was about $45. I followed parts of an online tutorial for wiring things up which meant soldering the PMS5003 power to the 5V on the board, the ground on the sensor to the board and the TX line to D4 on the board. For the BME 280, power went to 3V, SDA to D2 and SCL to D1.

Wired Board

After wiring up the board, I used my trusty Ryobi Hot Glue Gun to glue the pieces into the PVC housing.

Mounted components

I then configured ESPHome. The ESPHome configuration is below:

uart:
  rx_pin: D4
  baud_rate: 9600

sensor:
  - platform: pmsx003
    type: PMSX003
    pm_1_0:
      name: "Particulate Matter <1.0µm Concentration"
      filters:
        - throttle: 30s
    pm_2_5:
      name: "Particulate Matter <2.5µm Concentration"
      filters:
        - throttle: 30s
    pm_10_0:
      name: "Particulate Matter <10.0µm Concentration"
      filters:
        - throttle: 30s

  - platform: bme280
    address: 0x76
    i2c_id: bus_a
    temperature:
      name: "Outside Temperature"
      oversampling: 16x
      accuracy_decimals: 1
    pressure:
      name: "Outside Pressure"
      accuracy_decimals: 1
    humidity:
      name: "Outside Humidity"
      accuracy_decimals: 1
    update_interval: 30s

  - platform: dht
    pin: D5
    temperature:
      name: "Outside Temperature Alt"
    humidity:
      name: "Outside Humidity Alt"
    update_interval: 30s

i2c:
  sda: D2
  scl: D1
  scan: True
  id: bus_a

In addition to the BME 280 sensor, I added a second temperature/humidity sensor, the DHT22 so that I can compare results as the BME 280 apparently doesn’t have accurate results as the component heats up itself. (I added the DHT22 after the pictures were taken.)

With the sensor setup in ESPHome, the next part was getting the readings converted into an air quality index (AQI). There are various calculations and corrections used to calculate the index. I stuck to a simple calculation that I found in Jason Snell‘s Scriptable widget that works with PurpleAir data.

I’m a big fan of Node-RED and used that to periodically take the data from the sensors and generate an AQI. In Node-RED, I have it poll the sensor once a minute and then calculate the AQI and then update the Home Assistant sensor

[{"id":"90c83f52.90ab4","type":"poll-state","z":"3c8c01a5.14121e","name":"2.5um","server":"d83da4b3.5bea38","version":1,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"updateinterval":"60","updateIntervalUnits":"seconds","outputinitially":true,"outputonchanged":false,"entity_id":"sensor.particulate_matter_2_5um_concentration","state_type":"str","halt_if":"","halt_if_type":"str","halt_if_compare":"is","outputs":1,"x":110,"y":1380,"wires":[["46dfb46e.8c564c"]]},{"id":"46dfb46e.8c564c","type":"change","z":"3c8c01a5.14121e","name":"Set Payload","rules":[{"t":"set","p":"particulate","pt":"msg","to":"payload","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":350,"y":1380,"wires":[["54903d05.bb2a04"]]},{"id":"54903d05.bb2a04","type":"function","z":"3c8c01a5.14121e","name":"","func":"function calcAQI(Cp, Ih, Il, BPh, BPl) {\n    var a = (Ih - Il);\n    var b = (BPh - BPl);\n    var c = (Cp - BPl);\n    return Math.round((a/b) * c + Il);\n}\n      \nfunction getAQIDescription(aqi) {\n\tif (aqi >= 401) {\n\t  return 'Hazardous';\n\t} else if (aqi >= 301) {\n\t  return 'Hazardous';\n\t} else if (aqi >= 201) {\n\t  return 'Very Unhealthy';\n\t} else if (aqi >= 151) {\n\t  return 'Unhealthy';\n\t} else if (aqi >= 101) {\n\t  return 'Unhealthy for Sensitive Groups';\n\t} else if (aqi >= 51) {\n\t  return 'Moderate';\n\t} else if (aqi >= 0) {\n\t  return 'Good';\n\t} else {\n\t  return undefined;\n\t}\n }\n\nfunction getAQIMessage(aqi) {\n\tif (aqi >= 401) {\n\t  return '>401: Health alert: everyone may experience more serious health effects';\n\t} else if (aqi >= 301) {\n\t  return '301-400: Health alert: everyone may experience more serious health effects';\n\t} else if (aqi >= 201) {\n\t  return '201-300: Health warnings of emergency conditions. The entire population is more likely to be affected. ';\n\t} else if (aqi >= 151) {\n\t  return '151-200: Everyone may begin to experience health effects; members of sensitive groups may experience more serious health effects.';\n\t} else if (aqi >= 101) {\n\t  return '101-150: Members of sensitive groups may experience health effects. The general public is not likely to be affected.';\n\t} else if (aqi >= 51) {\n\t  return '51-100: Air quality is acceptable; however, for some pollutants there may be a moderate health concern for a very small number of people who are unusually sensitive to air pollution.';\n\t} else if (aqi >= 0) {\n\t  return '0-50: Air quality is considered satisfactory, and air pollution poses little or no risk';\n\t} else {\n\t  return undefined;\n\t}\n }\n\n\n\nvar pm = msg.particulate;\nvar aqi;\n\nif (isNaN(pm)) aqi = \"-\"; \nif (pm === undefined) aqi = \"-\";\nif (pm < 0) aqi = pm; \nif (pm > 1000) aqi = \"-\"; \n        /*      \n              Good                              0 - 50         0.0 - 15.0         0.0 – 12.0\n        Moderate                        51 - 100           >15.0 - 40        12.1 – 35.4\n        Unhealthy for Sensitive Groups   101 – 150     >40 – 65          35.5 – 55.4\n        Unhealthy                                 151 – 200         > 65 – 150       55.5 – 150.4\n        Very Unhealthy                    201 – 300 > 150 – 250     150.5 – 250.4\n        Hazardous                                 301 – 400         > 250 – 350     250.5 – 350.4\n        Hazardous                                 401 – 500         > 350 – 500     350.5 – 500\n        */\n\nvar particulateSize;\nvar sensorName;\nvar sensorFriendlyName;\nif (msg.topic.includes('2_5')) { \n    particulateSize = \"2.5\";\n    sensorName = \"aqi_pm_25\";\n    sensorFriendlyName = \"EPA PM 2.5 AQI\";\n\n    if (aqi === undefined) {\n\t\tif (pm > 350.5) {\n\t\t\taqi = calcAQI(pm, 500, 401, 500, 350.5);\n\t\t} else if (pm > 250.5) {\n\t\t\taqi = calcAQI(pm, 400, 301, 350.4, 250.5);\n\t\t} else if (pm > 150.5) {\n\t\t\taqi = calcAQI(pm, 300, 201, 250.4, 150.5);\n\t\t} else if (pm > 55.5) {\n\t\t\taqi = calcAQI(pm, 200, 151, 150.4, 55.5);\n\t\t} else if (pm > 35.5) {\n\t\t\taqi = calcAQI(pm, 150, 101, 55.4, 35.5);\n\t\t} else if (pm > 12.1) {\n\t\t\taqi = calcAQI(pm, 100, 51, 35.4, 12.1);\n\t\t} else if (pm >= 0) {\n\t\t\taqi = calcAQI(pm, 50, 0, 12, 0);\n\t\t} else {\n\t\t\taqi = undefined;\n\t\t}\n\t}\n} else {\n    particulateSize = \"10.0\";\n    sensorName = \"aqi_pm_10\";\n    sensorFriendlyName = \"EPA PM 10 AQI\";\n    if (aqi === undefined) {\n\t\tif (pm > 425) {\n\t\t\taqi = calcAQI(pm, 500, 301, 604, 425);\n\t\t} else if (pm > 355) {\n\t\t\taqi = calcAQI(pm, 300, 201, 424, 355);\n\t\t} else if (pm > 255) {\n\t\t\taqi = calcAQI(pm, 200, 151, 354, 255);\n\t\t} else if (pm > 155) {\n\t\t\taqi = calcAQI(pm, 150, 101, 254, 155);\n\t\t} else if (pm > 55) {\n\t\t\taqi = calcAQI(pm, 100, 51, 154, 55);\n\t\t} else if (pm >= 0) {\n\t\t\taqi = calcAQI(pm, 50, 0, 54, 0);\n\t\t} else {\n\t\t\taqi = undefined;\n\t\t}\n    }\n}\nmsg.payload = {\"aqi\": aqi, \"description\": getAQIDescription(aqi), \"message\": getAQIMessage(aqi), \"particulate\" : particulateSize, \"sensor_name\": sensorName, \"friendly_name\": sensorFriendlyName};\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":560,"y":1380,"wires":[["ba491750.52e4f8"]]},{"id":"ba491750.52e4f8","type":"ha-api","z":"3c8c01a5.14121e","name":"Update Sensor State","server":"d83da4b3.5bea38","debugenabled":false,"protocol":"http","method":"post","path":"/states/sensor.{{payload.sensor_name}}","data":"{\"state\":\"{{payload.aqi}}\",\"attributes\":{\"icon\":\"mdi:chemical-weapon\",\"friendly_name\":\"{{payload.friendly_name}}\",\"description\":\"{{payload.description}}\",\"particulate_size\":\"{{payload.particulate}}\",\"unit_of_measurement\":\"AQI\",\"message\":\"{{payload.message}}\"}}","dataType":"json","location":"none","locationType":"none","responseType":"json","x":800,"y":1380,"wires":[[]]},{"id":"d83da4b3.5bea38","type":"server","z":"","name":"Home Assistant"}]

Having the AQI sensor in Home Assistant allows me to quickly glance and see how bad the air is outside (at this point, I can actually see the poor air!).

AQI Graph

Good air quality is less than 50 and from the graph above, we haven’t seen that in awhile!

I mounted my finished product under a second floor deck which should keep the major rain out of it. PurpleAir recommends not covering the bottom with anything, so I’m going to go with that and see what happens. Having it completely exposed outside isn’t great. It is powered by a PoE to USB adapter as I had Ethernet going outside there anyway.

Final mounting

The AQI data is interesting and is actually useful in telling me how much physical activity I should do. Other pieces of data I collect are neat, but not all that useful.

Searching for a new car

Several years ago I was in the market for a new car. I really wanted a PHEV (plugin hybrid electric vehicle) as most of my driving is around town, but I’d have the flexibility to go on longer trips. At the time there weren’t many choices that interested me. I test drove an Audi A3 e-tron and while it was a nice little car, it didn’t have CarPlay. After Apple introduced CarPlay, I knew that I had to have it on my next vehicle as I never wanted to update the maps in the navigation again and with annual iOS updates, I knew that I’d get tweaks to the system every year which I’ve come to expect.

I continued my car search and was looking for either a compact SUV or a hatchback/wagon/5 door that had OK gas mileage, some technology and of course, CarPlay. My options were quite limited and I found the 2017 Subaru Impreza. At the time, Toyota wasn’t onboard with CarPlay, so I’d have to leave Toyota. On paper, it had everything I wanted (except PHEV). The price was right and I purchased one right when a local dealer got it. While the car isn’t a sports car, I enjoy using the paddle shifters sometimes and the car has performed OK. It was the first model year on a new platform and has had some problems (6 recalls at the last count). The car has enough room to go camping (I’ve downsized our camping equipment and am strategic about what we bring) and we’ve used it on a few road trips. I went from a Toyota Highlander to the Impreza, so I lost a bit of room.

As I mentioned earlier, CarPlay was a requirement for me and I’ve written about it before. Unfortunately, the infotainment system in the car has been the biggest disappointment for me. Early on, CarPlay wouldn’t always start and required me to figure out how to reboot the system which sometimes doesn’t work. There have been a number of software updates each requiring me to take it to the dealer. It has gotten better, but there are still times when the system won’t boot or I have to reset it. There has even been a class action lawsuit about the system. Some people on various forums ask if others bought the car just because of the infotainment system or they are overreacting; I actually did purchase the car because of the infotainment system and would have looked elsewhere.

Other than the infotainment system, the car has functioned adequately; my new car excitement has worn off and it is just a car. I’ve had an issue with low speed shifting, but the dealer says that it isn’t a problem. With only a few Subaru dealers in San Diego, taking it to another one for service isn’t a feasible option to get a second opinion.

The car still serves its purpose and has pretty low mileage on it, but right before the world got turned upside down this year, I saw that Toyota was coming out with a PHEV RAV4. After reading about it, I knew that this is the car I would have purchased if it had been out a few years earlier. The waiting game began once I had my heart set on replacing my car!

As I’ve written about before, dealers are charging huge markups and supply is limited on the RAV4 Prime, so I wait. I’d really like to get this vehicle before the federal tax credit runs out because it will be a lot less attractive at $7,500 (+ local incentives) more.

Scott’s Cyber Safety Primer

Lately the topic of cyber safety has come up a few times for me. I’m the point person for CyberChip for my son’s Scout troop. I help the Scouts earn the award which is required for the Scout and Star ranks; I’ve overseen a few Scouts complete the requirements. In addition to this, I’ve seen how something innocuous that has been posted years ago can come back and be devastating. Lastly, have seen how someone could easily get scammed.

While I don’t claim to be an expert on cyber security, I did have lunch with Phil Zimmerman to discuss working on he Mac port of PGP and had Phil Karn as a mentor teaching me about Linux! I’ve been using the Internet for over a quarter of a century and have learned a few things about “being safe”.

Using two of the points of CyberChip Internet Safety Pledge as a starting point, I’m going to elaborate on what I think is important.

I will think before I post.

This is a pretty important point as everything on the Internet exists forever. If you do a search on my name, you’ll find posts I made years ago. Luckily, most of it is innocent. Recently I learned of someone that was terminated from a position because of a post they made many years ago. Even if you post something that you think is private, send a picture to someone or send a text, there could be a data breach or the recipient could take the message and post it, blackmail you, or in other way cause you irreparable harm.

While your messages to others could be encrypted (like using iMessage), the other end can easily take a screenshot of whatever you wrote and use it against you.

Unless you want something to come back on you at some point in the future, don’t post it or send it electronically.

Also, remember that when you take photos, the location of the photo is stamped (in the metadata) on the photo. If you are on vacation or traveling and post pictures with the location data on the photo, people can know that you aren’t home. If you are home, people can know where you live. While there are a number of ways to find out where people live, you don’t want to make it easy on them. When sharing photos, remove the location data (in iOS when you share, there is an option to remove the data) and don’t post photos when you are traveling; wait until you return home.

I will protect myself online.

This point requires a little more effort than “thinking before you post” and relates to password security, fake websites and scammers.

Passwords

The common thinking on passwords is to create complex passwords that you can remember such as substituting numbers for letters and symbols for other letters. This thinking is nearly impossible to combine with the thinking that you should create a separate password for every website. The only way to reconcile this is to use a password manager such as 1Password, LastPass, or Dashlane to name a few. Each site must have a separate password and each password must be complex. Of course, you have to remember your “master” password to get into the password manager.

You cannot write down any of your passwords with the exception that some of the password managers setup a “recovery” sheet where you write down your master key and then the sheet should be placed in a safe or a safe deposit box. It is quite unlikely that someone will go through the trouble of getting your recovery sheet.

Websites

When I first registered a domain many years ago through Network Solutions, it wasn’t easy to do. This became a slight hurdle in people setting up scammy websites. Since then, getting a domain name and setting up a website can be done in minutes. There are tons of sites that rely on typos to major websites to redirect users to their sites. Luckily many browsers pick up on this and make it easy to get to the right site. People are taught that seeing the lock icon in a browser means that a site is secure. While that is true, you have to look at what that means. Obtaining an SSL certificate up until recently took a little extra effort and wasn’t particularly cheap. With the advent of Let’s Encrypt, getting an SSL certificate is now free and easy to setup. I use Let’s Encrypt and securing traffic from my browser to servers is great.

Securing traffic is only part of a secure website. You have no idea what happens behind the scenes. Years ago I worked for a company that stored credit cards in clear text in an unencrypted database along with the CVV codes. In my tenure at the company I worked to bring it into compliance with PCI DSS, but credit card numbers were still accessible to employees and they still had roundabout access to CVV codes.

So even if a site has a lock icon, it doesn’t mean that it is safe to visit the website. Securing the traffic is very different from a site being safe to visit. Even the federal government has given given bad advice on this.

One of the safest ways to visit a website is to use a trusted search engine such as Google or DuckDuckGo and click the links from there; most popular websites should be at the top of the search results. However, before clicking a link check that it is indeed the site you want to visit.

Scammers

The other day I got a phone call that purported to be from Apple security saying that my Apple ID had been compromised. The call came from a Michigan number and was a recording. I pressed one and was connected to an agent. I asked for his employee ID and he responded with FUC…

Companies will not proactively call you about security issues. If you suspect there is an issue, hang up and call the company to verify the information. Also asking for an employee ID is a good way to weed out some scammers.

Never give out information to anyone that calls you; always call the company back if you have questions. Also never give anyone access to your computer remotely.

AppStores/Installing Software/Malware

If possible, always install software from an AppStore. While this doesn’t guarantee that you won’t get malware, it does reduce the possibility. Verify that software comes from a known source if you can’t install it from an App Store.

If you see messages that your computer is running slow or “click here” to get support, you may have malware on your computer. If this happens, immediately turn off WiFi and either contact your most tech savvy friend or family member for advice or take the computer to BestBuy’s GeekSquad to remove the malware.

Credit Cards

Whenever you pay for something online, always use a credit card. Never use a debit card. Credit cards have better consumer protections than debit cards. Never give a credit card number to anyone that calls you! If you make a purchase over the phone, verify that the phone number you are calling belongs to the proper company. Don’t just call any random number you find doing a Google search.

Conclusion

  • Anything you post on the Internet even in private could come back to haunt you.
  • Remove location data from photos before sharing.
  • Always use a different password for every website.
  • Use a password manager.
  • The lock icon on a website doesn’t mean the site is safe.
  • If you have to call a company, verify the number that you are calling is actually for the right company and not just some random number you found.
  • Install software from an App Store or a known source.
  • Never give your credit card number to someone that calls you. Always call a company back.
  • Never use a debit card on the Internet; only use credit cards.

Monitoring a SunPower Solar System

[Update: Here is a new Node-RED flow that works better with Home Assistant’s Energy Dashboard.]

After years of waffling on if I should install solar on my house, I finally decided that it would be a good investment. While the federal tax credit went down from 30% to 26%, I would still get a bit of my investment back. The tax credit goes to 22% next year and then goes away, so if I didn’t make the leap now, I’m not sure financially it would make sense for a long time until the panel prices come way down.

Like most major investments, I did a significant amount of research. I got proposals from 9 companies using a variety of panels and inverters. For better or worse, I went with a SunPower system. SunPower wants to make it easy for people to see how much energy they are producing and their monitoring site has a very, very simple dashboard. Apparently their older dashboard (still available via a different URL that uses Flash) showed output on a per panel basis. When I asked SunPower about this, here was their response:

Unfortunately, our monitoring website only shows production data of the system as a whole. Inverter level monitoring was only offered to dealers for troubleshooting and/or repair purposes. This was not offered to homeowners because, after lengthy evaluation, that feature offers more information than is necessary to monitor ongoing system performance, but not enough information to help identify problems (on the rare occasions when they do occur). We also had concerns about the feature’s design, in part due to negative feedback from customers.

After a bit of research, I found that the monitoring device (PVS6) actually has the ability to be queried for local data. An individual with better hacking/detective skills than me figured out the commands to send to the unit and posted information on GitHub describing the setup. That looked pretty straight forward. So I decided to figure out how to integrate it into Home Assistant and into my Grafana graphs.

First step was to configure a Raspberry Pi as basically a bridge where HTTP requests sent to one port would be redirected out the other port. I didn’t need a full fledged router for this, just an HTTP proxy. I decided to use a Raspberry Pi Zero W that I had lying around as a base. I ordered an Ethernet adapter for it and that was it for hardware. My son designed a case for both pieces and I 3D printed it.

Configuring the Raspberry Pi

  1. Download the Raspberry Pi Imager
  2. Select the Raspbian Lite image.
  3. Write the image to an SD card.
  4. Create a file called wpa_supplicant.conf at the root of the image with the following:
    ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
    update_config=1
    country=US
    
    network={
     ssid="<Name of your WiFi>"
    psk="<Password for your WiFi>"
    }
    
  5. Add a file called ssh at the root of the image. This file should be empty.
  6. Assign a static IP address mapping on your router for the Pi.
  7. Boot the Raspberry Pi. Login using username: pi password: raspberry
  8. Update the OS using
    sudo apt-get update
    
  9. Install ha-proxy
    sudo apt-get install haproxy
    
  10. Modify /etc/dhcpcd.conf by adding the following so that the Ethernet going to the PVS6 doesn’t attempt to setup a gateway. If this happens, the Pi no longer responds over WiFi.
    interface eth0
    nogateway
    
  11. Add the following to /etc/haproxy/haproxy.cfg:
    frontend http-in
        bind *:80
        default_backend backend_servers
    
    backend backend_servers
        server sv1 172.27.153.1:80
    
    listen stats
        bind *:8080
        stats enable
        stats uri /
        stats refresh 10s
        stats admin if LOCALHOST
    
  12. Reboot the Pi.

Now when you issue HTTP calls to the Pi, they’ll goto the PVS6.

Setting up Home Assistant

I use Node-RED for most of my automations, so the following is how I poll the PVS6 from Node-RED.

Node-RED PVS6

Basically what I do is make an HTTP call to the Raspberry Pi over the WiFi interface that redirects to the PVS6. Using the information from the GitHub repo I found, the call is: http://10.0.3.55/cgi-bin/dl_cgi?Command=DeviceList

I then parse out the different devices that are returned (one for each inverter, one for the monitoring unit, one for the consumption meter and one for the production meter). My installer didn’t hook up the consumption meter, but I use an older version of the Rainforest Automation EAGLE-200 to connect to my electric meter and get consumption data.

This Node-RED flow generates multiple sensors that can then be used to display data right in Home Assistant or in Grafana. There is more information in the output than I need such as AC voltage, DC voltage, AC current, DC, current, etc. I use Home Assistant’s HTTP interface to create new sensors and since I have no idea how fast it can respond, I rate limit the updating of the sensors.

You can download my Node-RED flow from here.

Grafana

I’m going to leave it as an exercise for the reader to setup pretty pictures in Grafana. I’ve setup a basic dashboard and some other graphs. The per panel graphs are useful to tell me if a panel isn’t operating properly. While SunPower doesn’t really want you to know this information, it is very helpful. My system was turned on (my installer and SunPower can remotely disable my system which really bothers me) yesterday and I noticed that 1 of the panels wasn’t generating power. This amounts to about 8% of my overall system; most people wouldn’t know this which makes it even more important to be able to get status on a per panel basis.

Energy Dashboard

Energy Usage

Per Panel Monitoring

Conclusion

I’ve written up this guide to help others, but also to refresh my memory in the future to figure out what I did. My home automation system is growing more and more complex by the day and if I don’t document at least parts of it, I’ll never be able to troubleshoot it.

Feel free to ask questions or provide comments.