Posts

Getting the Miyoo Mini Plus battery into Home Assistant

Image
I recently got the retro handheld  Miyoo Mini Plus , love it so far! I also installed Onion OS on it, never even tried the stock experience.  Your setup, especially in Home Assistant might differ, so try to adapt this guide to your needs. But enough intro, you're likely reading this because you want the battery percentage into Home Assistant or some other system. This isn't a food blog where you need to scroll a mile to get to the recipe. What you will need: A Miyoo Mini Plus Onion OS 4.2 (or newer as far as I know. I run 4.2.3 at the time of writing) Home Assistant with the Syncthing Add-On configured Or some other way of getting synced files read by Home Assistant MicroSD card reader and a computer, of course Some knowledge in Syncthing and Home Assistant What you need to do: Install Syncthing on the SD card and start it . Make sure it works. With the card inn your computer, create a folder on the root of the card, named syncthing Open the hidden folder named .tmp_update, an

How and why I read my apartment energy usage?

Let's start with why I have no good answer other than that I want to. It's 99% for fun, since I live in an apartment with district heating and good insulation, and the energy consumption does not really correlate with heating or cooling. Energy usage is tied mostly to cooking, the dishwasher and other appliances that we use consciously. I just want to get the wattage into Home Assistant in a way I can understand and/or manage myself. But how do you measure it? That's been quite the journey. The go-to way of reading the energy usage (here in Norway at least) is using a device that plugs into the HAN-port in the fuse box, and Wifi. Tibber Pulse is a good example of this. My problem with this is that my HAN-port is in the basement, four concrete stories below my apartment, way out of reach of my Wifi.  There are HAN-devices that work over ZigBee, and I did contemplate sneakily replacing lightbulbs down the stairwell with ZigBee-bulbs, to extend my ZigBee-network all the way d

Getting Company Portal apps locally using PowerShell (no auth!)

Image
As you may know, I work at Intility in the application packaging space.  I've been doing that since about 2015, and during that time I and my collegaues have developed standards and systems to help us package apps better and faster. The so far last and unifying system is AppPackBot, which you can read more about at Intility Engineering . I won't (and quite frankly can't) go into all the nuts and bolts beyond what that blog post says, but I wanted to share something. You see, there are mainly two "app stores" in a corporate Windows environment. Good old Software Center, and the new Company Portal. Software Center can be programmatically interacted with using the CCM_Application WMI Class . But Company Portal, not so much.  I burst out laughing when I read this attempt to install an app from Company Portal using PowerShell. Tldr: Using the companyportal: protocol to open Company Portal with a given app guid, and then sending a ctrl+i keystroke that equals clicking

Converting nested hashtables(or yaml) to nested psobject with PowerShell

Image
I'm dabbling with WinGet at work, and I wanted to parse the installer information about VLC Media Player provided by WinGet .  PowerShell does not natively support Yaml, so I like to use the powershell-yaml module. I thought a simple convert should be enough, but no. This just resulted in a hashtable, I wanted a psobject. So how about casting ut to a psobject? Better, at first I thought I was done. But hold on, the properties of Installers are still hashtables. Googling and thinking led me to almost use a recursive function that dealt with this, but then I remembered playing around with conversions between yaml and json. Side note, the UI config of Home Assistant may be edited as yaml, but is stored as json on disk. So I knew they are just different flavors of the same thing, really.  Anyways, this is how to convert yaml to nested psobects: Get-Content <file.yaml> | ConvertFrom-Yaml | ConvertTo-Json | ConvertFrom-Json (I added -Depth 5 just because the default value 2 is not

I think I found a bug in cmtrace

Image
At work today I was looking through a log file generated by PSADT and noticed something weird. Compare the selected line in blue and the box below. Can you see it? (cmtrace version 5.0.9068.1000, I believe this is the current up to date version) Hint: The folder in ccmcache for the content is named "n".  Now, compare this to an older version of cmtrace where we see the same log file (cmtrace version 5.0.7804.1000, some years old) In case it's not clear: (new/current cmtrace. where is the n folder? For some reason, "\n" is getting removed from the box below in the new version of cmtrace.  My guess why this is happening: \n can be interpretet as a newline character. I believe this is happening, and in addition it strips away newlines. So "\n" just vanishes. The older version does not have this issue. That's all for now, have a great day!

VIRDIestimat i Google Sheets

Image
 Hei! (This will be in Norwegian, as it only applies to norwegians or people wanting to buy or sell real estate in Norway) (tldr i fet skrift mot slutten) Dere kjenner kanskje til virdi.no  (Min eneste relasjon til den tjenesten er som bruker). Det er kort fortalt en tjeneste som gir estimerte boligverdier. Men boligprisene endrer seg over tid, og jeg liker i alle fall å ha en idé om hva min bolig er verdt (ifølge Virdi). Det er en smal sak å bokmerke siden for min leilighet og sjekke en gang iblant, men jeg liker også å integrere dette tallet med andre nøkkeltall i min økonomi. Her kommer Google Sheets inn i bildet.  Jeg ønsker å kunne hente tallet fra Virdi automatisk, inn i en celle i Google Sheets.  Sånn gjør du det: Finn boligen på virdi.no. Her bruker jeg en helt tilfeldig leilighet som eksempel. Linken du skal ende opp med skal se ut som dette: https://virdi.no/bolig/oslo/0368-oslo/kirkeveien-37a/H0201 Her skal du kunne se VIRDIestimatet, som dette:  (Teksten "12 328 700&qu

Sorting properties (not objects) in PowerShell

Image
This week I had a need for sorting the properties of an object alphabetically. Funny enough, the aptly named "Sort-Object" does not do this, that cmdlet sorts an array of objects by one or more given property names – useful for listing files in a folder, ordered by the files' size, for example. But I had to figure out something else. Take this example, just all the properties of a file in default order. Say I want to sort these alphabetically. First, I need to identify exactly which properties. Get-Member gives you the methods in addition to the properties, I don't want the methods. I just want the different properties, I got those with -MemberType *Property. I want the properties sorted by Name, and then expand the Name. Now, store that in a variable, here named $SortedProps. This variable is now a string array. Now, back to start with the Get-Item of the file. That output gets piped to Select-Object, which has the parameter "Property" that takes a string a