MySQL: Moving Data From One Table To Another

Our OpenHAB persistence data is stored in MySQL. There’s an “items” table which correlates each ItemName string to an ItemID integer. There are then Item#### tables that store persistence data for each item. If you rename an item, this means a new table is created and previous persistence data is no longer associated with the item. For some items, that’s fine — I don’t really care when the office light was on last month. But there’s persistence data that we use over a long term — outdoor temperature, luminance, electrical usage. In these cases, we want to pull the old data into the new table. There’s a quick one-liner SQL command that accomplishes this:

INSERT INTO NewTable SELECT * from OldTable;
e.g. INSERT INTO Item3857 SELECT * FROM Item3854;

You can drop the old table too:

DROP OldTable;

But I run a cleanup script against the item list so often don’t bother to remove tables one-off.

ESP8826 (12e) Multisensor

We’d set up a prototype multi-sensor with an environment sensing kit that Scott picked up at MicroCenter a few years ago. There’s a little LCD display … but we wanted to report readings back to our OpenHAB server. Which required a network connection. Checking out prices for network cards to add to the Uno … well, it wasn’t a cheap add-on. But we found these ESP8266 modules that support 802.11b/g/n and provide the memory/processing for small programs. At about 3$ delivered, that was exactly what we needed.

I ordered a bunch of components to make multi-sensors – pressure sensors, luminescence sensors, temperature/humidity sensors. The sensors connect into a CP2102 ESP8266. The device is powered by a couple of 18650’s in a little box — another buck. There’s some miscellaneous wiring and a little breadboard, too. The total cost for the multi-sensor is about 8.50$. We could add a vibration sensor for another 0.50$, a PIR sensor for 2$, and a UV sensor for 2.50$. That’s 13.50$ for 7 different sensors — and we don’t need seven sensors everywhere.

I kind of want to make a weather station too — add a water level sensor, a precipitation detector, and a wind speed sensor. Those are surprisingly expensive! I want to check out the process to build your own anemometer. But I’d probably buy a nice Davis Anemometer 🙂

Connecting to a WiFi network with the ESP8266 is really easy:

  • Add a library to the Arduino IDE
    • In the Arduino IDE preferences, select File>Preferences menu.
    • In the “Additional Boards Manager URLs” field, add ‘https://arduino.esp8266.com/stable/package_esp8266com_index.json’
    • Select the Tools > Board menu and open the Boards Manager. Search for “esp8266” and install the platform.
    • From the Tools > Board menu, select the appropriate board. I ordered the CP2102 ESP8266 module, and we’re using “NodeMCU 1.0 (ESP-12E Module)” as the board.
  • Configure the WiFi network connection details in your code
  • Compile
  • Upload
  • You’ve on the network!

We’ve used an MQTT library and send sensor readings to our MQTT server.

 

Like in the movies

Every time I’ve watched a sci-fi movie where someone builds a robot that decides to annihilate humans, I wonder how the engineer missed out on the previous thousand movies where someone’s very good idea for a robot kills us all. I mean, sure it would be a really short movie if we pan into some lady sitting in a lab with a bunch of robotic bits spread out on a table and hear her say “Wait … I’ve seen Collossus: The Forbin Project … lets not do this”. And she shuts down the computer, shelves the components, turns the lights off, and goes home. But seriously, how could anyone about to install laser cannons on a drone not think “wait … “. Some movies address this with a four-laws derivative — I know the previous thousand robots went horribly awry, but here’s my idea at coding in guardrails.

Kind of think the same thing about zombie movies — the body of work tells you that really good precautions and quarantines are totally the way to go. But what happens IRL when there’s a contagious virus about? Exposed passengers from a cruise ship are flown back to the States. HHS’s welcome committee aren’t trained for infectious disease exposure and don’t kit up.

Adding member to MS Teams without admin rights or Graph API

# To run on Linux, you need the preview mode of AzureAD
# Register-PackageSource -Trusted -ProviderName ‘PowerShellGet’ -Name ‘Posh Test Gallery’ -Location https://www.poshtestgallery.com/api/v2/
# Install-Module -Name AzureAD.Standard.Preview

# Windows, the module is
# Install-Module -Name AzureAD

# I’m lazy and just typed my creds for a proof of concept; real implementation would use the SecureString thing in the connect-azuread. See:
# https://www.rushworth.us/lisa/?p=3294
connect-azuread

# Get the object ID for the group and the user
$objMyGroup = get-azureadgroup -SearchString “LJR Sandbox Team”
$objNewMember = get-azureaduser -searchstring “NewGuy”

# Add the user to the group
add-azureadgroupmember -ObjectID $objMyGroup.ObjectId -RefObjectID $objNewMember.ObjectId

Debate Edition: South Carolina

I don’t think anyone won this debate, and the interrupting was incredibly annoying. It was like someone at CBS said “hey, people liked the energy and conflict in Nevada … what can we do to replicate that?” and came up with non-moderation and asking borderline offensive leading questions. No winners, but a few exchanges stood out to me.

Stop and frisk was a question Bloomberg knew would be asked. And he knows it’s something other candidates are going to target. I have no idea how he doesn’t manage to come up with something better in his debate prep. I contrast this with Sanders’ response on previous votes against gun control. I thought his response in the former debate — the state in which society existed in the 80’s, and what his constituents wanted in he 80’s, informed his vote. We’ve got different problems now, and he’s got different beliefs now because of this new information. This debate, where he outright called some of his votes bad … that seems like a much better approach on the stop and frisk questions. Bloomberg started down that path:

“I’ve met with black leaders to try to get an understanding of how I can better position myself and what I should have done and what I should do next time.”

But instead of continuing down a path of showing personal growth, he decided to tout his achievements.

“We’ve improved the school system for black and brown students in New York City. We’ve increased the jobs that are available to them. We’ve increased the housing that’s available to them.”

In one way, I get what he’s trying to say. But it was about the worst way I could have imagined saying it. I had an instant “umm, Brown v. Board of Education” mental response. Again, I’m certain he is speaking to the reality which is that there are schools and neighborhoods where a minority is the clear majority. But even a well phrased version of the response falls into Warren’s “so he’s saying he’s nice to some women” response. It’s ok that he made a lot of people’s lives hell for just walking down the street because he also increased funding to the school district?

And I thought that was the oddest bit right up until Buttigieg:

“I am not looking forward to a scenario where it comes down to Donald Trump, with his nostalgia for the social order of the 1950s, and Bernie Sanders with a nostalgia for the revolutionary politics of the 1960s.”

Essentially he is against the civil rights movement? The anti-war movement? The women’s lib movement? Hell, the gay rights movement?! All of which were “revolutionary politics” from the 60’s.

I was surprised that Bernie didn’t have a better response for his previous and current comments about Castro. Taking what Bernie said on Sunday on its own, he’s rejecting a “reductio ad Hitlerum” association fallacy (Hitler liked dogs, thus liking dogs is awful … Castro did a lot of awful things, therefore since Castro did it it was awful). His statements from the 80’s are essentially that there are reasons Castro wasn’t overthrown that Americans don’t understand. Which, in fairness, is totally true. There’s a dearth of communication between Americans and Cubans, so I’m certain there is a great deal of the internal political environment that was (and is) poorly understood. It *is* true, too, that people who opposed Castro were thrown into prison. Which had more impact Castro’s ability to stay in power – appeasement or totalitarianism? Americans don’t know. I doubt Cubans really know, either, since it’s not like we can isolate each input to quantify it’s impact. I’ve visited other countries with totalitarian governments, and I can absolutely say that people accepted reduced freedoms in return for an improved standard of living.

Even saying ‘hey, we could benefit by looking at what Castro did to increase literacy’ … what’s the harm? I mean, maybe ‘what he did’ was mobilize the army and anyone who couldn’t pass a fourth form reading exam has a dude with a Kalashnikov rifle standing over them as they study. Shoot anyone who couldn’t pass the exam and thereby achieved a statistical 100% literacy rate. We can look at that and reject the idea. But maybe ‘what he did’ was offer a grand to every individual who passed the fourth form reading exam and it proved to be a great motivation. Or double the number of teachers in elementary schools. Or funded adult literacy programs in every small town … which are ideas we could certainly try.

We do ourselves a disservice if we reject any idea about anything just because of its source. Hell, we do ourselves a disservice to ignore *bad* ideas from *bad* sources just because they (or the situation which gave rise to them) makes us uncomfortable. I can study something without agreeing to 100% believe and support everything about it. I’ve watched Doc McStuffins with my daughter and don’t believe the toys come alive every time we leave the room (although it *would* explain the mess!). I’ve read Harry Potter but haven’t managed to become a wizard. I think I can study what the Sandinista government did without deciding they had the right way of things, finding an armed mob, and taking over the government next Thursday. I can look at how Cuba increased literacy or started producing low-cost medication without starting a guerrilla war.

On Socialism and Socialism

One needs to differentiate between government-controlled means of production (colloquial ‘socialism’) and the employee-owned means of production that he supports (democratic socialism). Because there’s a big difference between the government taking over factories and putting out a five year plan for agricultural and manufacturing production and selling some control of companies to employees (who, logic dictates, would be driven to keep their product innovative and competitive beause they all want to have a job ten years from now so American capitalism would look for long-term prosperity instead of a few execs finding a way to get millions this year by driving the company into the ground).

Card Game: Sum War

Anya and I came up with a new card game — sum war. It’s a bit like war, but you throw two cards. The person with the higher sum wins all of the cards & puts them on the bottom of their stack. Keep going until someone has all of the cards. There’s obviously lots of addition involved, but the game uses estimation too (I have a 5 and a 7, you have a 5 and a 9 … you win without actually adding anything).

Debate Edition: Nevada

I put Warren at the top of my performance ranking too. She had a good bit of speaking time, finally. And she had good attacks against Bloomberg prepared. Noticed that she turned an opportunity to attack Sanders into an attack on Bloomberg. She seemed particularly fired up by Bloomberg.
 
Bernie in a strong second. “Socialism for the rich and rugged individualism for the poor” – I’m glad to see Bernie start to differentiate boogie-man Commie socialism and “things that benefit the unwashed masses” socialism. I think this is going to be a big thing as we go into Super Tuesday as the moderates try to make Bernie seem unelectable. And a decent line against Trump — they’re both socialists, but do you want socialism where billionaires benefit or socialism where thousand-airs benefit?
 
Biden third – not so much for any great performance (and he had some noticeable stumbles) but he didn’t stand out either positive or negative for most of the debate. Having the second lowest speaking time helped him here.
 
Buttigieg fourth. He had some good attacks, but he doesn’t do much to convey a policy beyond “can’t we all just get along”. Which, pragmatically, may well be answered with a resounding “no”.
 
Kobluchar fifth. She is lucky they didn’t go more into her Telemundo interview. Don’t remember the name of a foreign leader? Whatever. Yeah, everyone has brain farts. Don’t seem to have any clue about the policies of Mexico when you head to an interview with Telemundo prior to the primary in Nevada? That’s pretty astonishing given (1) her positions in the Senate and (2) the situation she was in. She didn’t seem to have much of an answer for her record as a prosecutor either – curious that no one seemed to ask Buttigieg a similar question about issues when he was mayor. Buttigieg had a well prepared attack against her on her voting record too. “I wish everyone was as perfect as you” isn’t much of a response. And she set him up for another obviously well prepared line about Senators feeling they are more important than Mayors and that “the arena” isn’t just Washington.
 
Steyer, Yang (who got name-checked even if he’s not running anymore), Booker and Harris (also name checked, also not running anymore), some dude who thought about running for president this year but thought the better of it. They all scored better than Bloomberg for me. Bloomberg had basically the debate I expected him to have – an easy last place finish. It’ll be interesting to see if this changes his polling trajectory. And I’m really looking forward to see if he adjusts for the next debate. And seeing if he had answers about red-lining, stop and frisk, changing party affiliation, etc is why I was hoping he’d qualify for some of the debates before he’s on the ballot. He had the lowest speaking time — which was a bit of a surprise given how much taking *about* him seemed to dominate the debate.
 
The “I’m the only one who is not a millionaire” spiel from Buttigieg is tiresome. “Millionaire” is someone with a million dollars in assets. I’m 43 and a millionaire. Half of that is retirement account, half is real estate (not literally, I’ve got like 20 bucks in my purse too). That’s not because I’m raking in Bloomberg money. It’s because I’ve been able to save a few grand a year since I was 20 – had a kid late in life, got lucky getting into IT. The fact that people in their 70’s have a mil or two … yeah, it means they’re probably part of the upper middle class. They’re probably not skipping lunch so their kid can get shoes that fit. But it’s sure as hell not true that anyone with a mil or two is “three Veyron’s in the garage so your personal shoppers don’t suffer the ignominy of showing up at Heinens in a Chevy” out-of-touch rich. And I’m surprised that someone doesn’t pick this thread up and go on about how Buttigieg’s own net worth would be significantly higher if they’d been able to take advantage of free public university tuition. Or how much do you need saved up to help pay for your kids’ college tuition(s). How much you need saved up to ensure decent health care as you age.
 
At that, use Buttigieg’s not-a-millionaire status to refute the “worked hard for that money” trope from the super rich. I have a friend who worked hard for a few years, sold a company to HP, and never worked again. I have another friend who worked two low-level retail management jobs and a part time gig with a cleaning service for a decade, took out massive loans to get a Uni degree, and works as a nurse now. I’ve got a friend who worked as a cop for a few decades, got shot on duty, and collects some disability payment now. They’ve all got about the same net worth today. I’m not saying Steyer or Bloomberg didn’t work hard for their money. But Bloomberg’s net worth is 64 *billion* dollars and my friends each have about three quarters of a mil in assets … did Bloomberg really work 85,333 times harder than any of these people? I’ll even spot him an order of magnitude – did he work 8,533 times harder? I think Mayor Pete’s net worth was estimated in the 100-200k range. Did Bloomberg work 320,000 times harder than someone who served in Afghanistan? And that’s not trying to play “I worked hard” with someone just scraping by who has two fifty in assets.
 
 
It’d be great if the moderators would have buttons to kill mic’s – there were a few times where we couldn’t follow what was being said because of others talking. Instead of trying to talk over the candidate to cut them off, just drop their audio.
 
Â