Home Assistant: Change Binary Sensor from on/off to open/close

I use Home Assistant to tie all of the devices in my house together. I recently purchased a z-wave sensor for my garage door to tell if it was open or closed. Home Assistant would show the sensor as either being on or off. Since it represented a door I wanted Home Assistant to show it as open or closed.

Below is how I did it. My sensor’s entity is binary_sensor.garage_door.

customize.yaml:

binary_sensor.garage_door:
  friendly_name: 'Garage Door'
  device_class: garage_door

 

Fixing Sickbeard’s Plex Notifications

I use Sickbeard in 2018. Even though Sickbeard’s development is dead it still works for me and switching to something like Sonarr would take time I don’t want to spend.

Sickbeard is able to notify Plex when a new show is downloaded and force Plex to update its libraries. At some point either Plex or Sickbeard broke support for this. I found a way around to fix it.

The idea is we will write our own script to update Plex. We’ll give it a name and location that fits into what Sickbeard expects to find.

You’ll need a web server on the same network as Sickbeard and Plex.

You’ll need to get your Plex Authorization Token.

You’ll need the Plex library ID of the library you want to update. (Look for librarySectionID= in the same place you get the authorization token)

On your web server in the web root:

mkdir xbmcCmds
cd xbmcCmds/
mkdir xbmcHttp
cd xbmcHttp/

Once in the xbmcHttp dir, create index.php and add to it:

<?PHP
file_get_contents('http://PLEX-SERVER-IP:32400/library/sections/YOUR-LIBRARY-ID/refresh?force=1&X-Plex-Token=YOUR-PLEX-TOKEN');
print 'OK';

Replace PLEX-SERVER-IP with your Plex server’s IP address. Replace YOUR-LIBRARY-ID with the Plex library ID you want to update. Replace YOUR-PLEX-TOKEN with your Plex Authorization Token.

Now in Sickbeard go to Config and then Notifications. Make it look like the screen shot below, adding in your web server’s IP address.

That’s it. Save it and test. You should see the Plex library update.
 

VMWare: Start VM automatically at boot without turning on Shared VMs

Unless you want to turn on VM Sharing, VMWare Workstation does not have an easy way to start your virtual machines automatically when Windows starts.

However, you can get them to start by creating a batch file that starts the VM. Once you have the batch file working, create a shortcut to it and place the shortcut into your start menu’s Startup folder.

Example Batch file:

cd "\Program Files (x86)\VMware\VMware Workstation"

vmware -x "C:\Users\dean\Documents\Virtual Machines\Oaktrace\Oaktrace.vmx"

The first line changes the working directory to the directory you have VMWare installed in.

The second line starts the VM.

High Ping Time on Local Network

Since my other articles on figuring out problems that you can’t Google are popular I thought I would write about my latest mood killer. I began to get a very high ping time on my local network, even higher out to the Internet. This caused problems with ssh sessions and NVIDIA game streaming, but was not noticeable when watching Netflix.

It started simply enough, one night I left my wife to watch Netflix downstairs while I went up stairs to get some work done. My job involves using ssh to login to remote servers, any latency (high ping) is very noticeable. That was the case this night. I could type much faster than the text would display, using the arrow keys to navigate was jerky at best. I figured my ISP was being lame. I finished up as quickly as possible. The next day there was no problem.

Jump cut to a few days later. Same situation. I head upstairs to work and my ssh session is just crap. The next day its fine.

The next morning is a Saturday. I take a seat on the couch and try to play Grim Dawn over NVIDIA game streaming and it doesn’t work. The bad connection icon appears in the top right, the graphics are pixelated and jerky, not good. Having no clue what could be wrong, I give my PC and Shield TV a restart. No luck, same problem. I tried the test connection option on the Shield TV, it reported back that I have a 9mb/s connection and 200ms ping. Considering I was on a wired gigabit network with only a switch between the Shield TV and my PC this was very bad.

My wife and children, bored of me, starting watching Netflix as I furiously Googled for a hint at a solution. Immediately my phone’s connection started having problems. Sites wouldn’t load or would load slowly. I tried a speed test and while my bandwidth was ok, my ping was 500ms. I tried pinging my PC, the ping times were all over the place, 1ms, 50ms, 100ms, and everything in between. Netflix worked fine, which I chalked up to streaming not being interactive and thus not caring about latency.

I at this point I knew it was something with my local network affecting both wired and wireless, but I had no idea what.

I had several command prompts open pinging devices around my house. All showed high pings. I expected less than one millisecond and the lowest was 5ms and very jittery.

I then thought about the problems I had with UNRAID. What if another port on my router’s switch is bad? My wife stopped watching Netflix and went into another room. I unplugged everything from my router and tried wifi, all good. I started plugging in all of my devices one at a time, testing in between each one. All good again. I opened up a couple of command prompts and started continuous pings, all good. I tried the NVIDIA game streaming test, the test failed just as before. I noticed something new this time though, my continuous pings were fine until the streaming test; during the test they were high. As soon as the test stopped they went back to normal. I started a movie on Netflix, the pings went bad again. I moved the Shield TV to a different port on my switch. The game streaming test succeeded. Netflix could play without jacking up the pings. It was another bad port in the router’s switch.

That left me with a switch that had four gigabit ports. One would say it was connected at a gigabit, but only pass 100mb/s of traffic. Another port messed up my entire wired and wireless network if any decent amount of traffic was passed. As a quickie fix I daisy chained another gigabit switch to one of the good ports. For a real long term fix I purchased another router.

Netflix was red herring. Watching Netflix would pass traffic over the bad port in the switch, jacking up the network. When I watch Netflix I’m not doing anything else on the Internet and therefor would not see the problem.

The router causing all of this was an ASUS NT-N66U. I got four years of use out of it before sending it to the trash. In the first year I had a pretty bad problem with it dropping my WAN connection. Otherwise I was happy with it. Its a shame it didn’t last longer.

Getting Started with Modding a PlayStation 2

I recently decided to buy a used PlayStation 2 and try my hand at modding it to play backups. Unlike the original XBOX, which has loads of good articles on modding, the PS2 was very lacking. Not that there isn’t some good information out there, just nothing boiled down into bullet points for a country boy such as myself.

Step 1: Get a PS2

Ebay was my first choice. Premodded PlayStation 2s go for 6-7 times what an unmodded PlayStation goes for. This is a little sad as what you need to do the mod costs very little. You’re pretty much buying a PS2 with a memory card when you buy one premodded.

You need a PS2 which has a model number that does NOT start with a 9. These unmoddable PS2s are ‘slims’ and have a shiny top.

I bought a SCPH-39001 from Ebay, commonly referred to as a fat PS2. It came with two controllers and a memory card.

Step 2: Do the Mod

Free McBoot is an exploit/mod you install on a PS2 memory card. It allows you to run unsigned code on the PS2, meaning you can run what ever you want, like game backups.

Long story short on this one, buy a memory card that already has the mod installed.

I bought a pre-installed memory card from Ebay. 

Step 3: Buy some other stuff

You’ll want the PS2 to look its best on your TV. Buy some component video cables. This is the same cable a PS3 uses for component out.

With what you purchased in steps 1 and 2, you can load games from a burned DVD or a USB hard drive. Having a ton of burned discs laying around is lame and since the PS2 only has USB 1.0 ports, a USB hard drive is going to be very slow, slower than a disc. You want to buy a SATA hard disk interface.

The SATA hard drive interface is normally part of a network adapter, though you can buy just the drive interface alone. Get a SATA interface, not IDE. With IDE you’ll be relying on old used drives, while SATA drives are modern and easy to buy new. Don’t bother with an SSD, its expensive overkill.

I bought a SATA adapter with no network interface. I also bought a 320GB SATA hard drive. Outside of my cheapness, there was no reason I could not have went with a larger drive.

Step 4: Using It

Modding the PS2 is simple enough, insert your Free McBoot memory card. That’s it. You’ll see a Free McBoot splash screen on boot and the main menu will have some more options, one of which will be Open PS2 Loader. This is the program you’ll use to launch backup ISOs from your hard drive.

You’ll need to get some backups of your games. The easiest way is to make a copy using ImgBurn. This is identical to the process you would use to make an ISO of any CD/DVD you have laying around.

Next up you’ll format your hard drive and load some ISOs onto it. For this you’ll need Winhiip and some way to connect the drive to your PC. I used a SATA to USB adapter.

Get your drive connected and run Winhiip. The first thing is you’ll need to do is to format the drive for 48 bits. After that load your ISOs.

Now plug the drive into the PS2, start Open PS2 Loader, hit O, and you should see your games.

Tip: R1+R2+L1+L2+Start+Select restarts the PS2. No need to get up to change games.

Step 5: Nice clean silence

The PS2 I purchased was dusty as hell. Gross even. The cooling fan was also loud. After taking the PS2 apart and giving every thing a good dusting and cleaning, the fan was still loud. 

I replaced the cooling fan with a Noctua 60x25mm fan. I followed this guide. I deviated from it some and connected the fan to the power supply to motherboard connector. This causes the fan to run whenever the rear power switch is on, but the fan does get the full 12v… sort of. Directly connecting the fan to the 12v made it run louder than I liked. I ended up using one of the noise suppressors that came with the fan. This made it silent. I probably could have saved some effort and connected it to the original fan’s leads.

The fan’s connection to the power supply connector.

The End

All said I spent less than $75 and took about three hours start to finish. Not too shabby.

 

UNRAID is Slow, What to do?

I recently built an UNRAID server for use as backup storage. The plan was to build a computer and then shuck and use the many USB drives I already had for storage. This mostly went to plan.

TLDR: Network equipment lies about connection speed.

I went with UNRAID because it boots off of a USB drive; saving a SATA port, works well with mixed drive types and sizes, and you can take a drive out of the array and read/write to it from any other PC.

The build:

Case: Cooler Master Elite 342 RC-342-KKRJ-GP 400W
CPU: Intel Celeron 2.90 GHz Dual Core FCLGA1151
Motherboard: MSI Pro Series Intel B250
Memory: Corsair Vengeance LPX 16GB (2x8GB) DDR4 DRAM 2400MHz
Boot Drive: SanDisk Cruzer Fit CZ33 16GB
Misc Items likes fans and cables I already had.

I had five 4TB Western Digital drives in USB enclosures that I planned on using in UNRAID. I bought a 4TB SATA drive, getting me a total of six drives. All of the USB drives appeared to work fine in their enclosures, no SMART errors, no problems reading and writing to them. After taking the drives out of their enclosures and putting them into the new server, three of them started reporting SMART errors. I wasn’t happy about this, but figured I would load them up and see what happens, only buying new drives if they actually failed.

Right off my transfer speeds were limited to 10-12MB/s. I was expecting more like 100MB/s, being on a gigabit network. After fiddling around for a bit I did a restart, UNRAID refused to boot. I got a monitor on it and saw in the message buffer that one of the drives was freaking out. I removed the drive and UNRAID booted up. I still had the slow transfer speeds though.

I disconnected the other two SMART error reporting drives. It was still slow. I logged in via the command line and did an rsync between one of the formerly USB drives and the new drive, still slow, albeit I was getting 15MB/s now. I put the two SMART error reporting drives back in.

I was a little lost at this point. If rsync between two sata drives was only getting me 15MB/s, something was seriously up. I figured the former USB drives were crappy and bought another new 4TB SATA drive. A day later I tried another rsync between the new drives. Same problem.

Now I started down the horrible path of googling ‘UNRAID slow.’ There wasn’t much to see here. Lots of posts about parity drives causing slow downs; I wasn’t using a parity drive. Lots of posts about using a cache drive; also not relevant since I’m not using parity.

I kept pounding my head trying everything and anything I could think of until I stumbled onto a problem with rsync. I was using the -z option, this compresses the files before they are copied. This is all good when sending files over the Internet like I normally would, but when going disk to disk the overhead kills the transfer speed. I ditched the -z option from my rsync command and I was getting full speed between all of my disks. 140MB/s+

Then I tried to do a copy from my Windows desktop to UNRAID’s windows share. Slow again. 10-12MB/s. I tried FTP, same deal. I tried rsync (no -z), same deal. Now I had a network problem.

My desktop, the unraid server, and my router all had gigabit ports. My desktop could do 100MB/s (Gigabit speeds, bit vs byte) to other devices in my house. Nothing could do better than 12MB/s to UNRAID though. UNRAID and my router both showed that UNRAID was connected at 1Gbp/s. Something was a liar.

I tried my laptop on the same ethernet cable and wall jack that UNRAID was using. The speed was bad. I tried UNRAID on a different cable and wall jack. The speed was great. Something was wrong with my cabling.

I swapped cables, redid did the wall jacks, no luck. I then tried making a simple network between my desktop and UNRAID, just a switch and two ethernet cables. The speed was great. There was only one thing left that could be the problem, the switch built into my router.

In the end, it ended up being a dodgy port in the router’s switch. Even though it says devices are connected at gigabit speeds, they are not. It works fine as a 100mbp/s port. No latency or dropped packet problems. I plugged the UNRAID server into a different port on the router, problem solved.

That’s my UNRAID saga. Hopefully my experience will help someone else.

Almost as a side note, I’ve been very happy with UNRAID. I have a 24TB array about 1/3 full. I have this 24TB array split into two 12TB user shares. I sync up the shares with rsync now and again as a backup. I’m not using parity. If a drive fails in the array I’ll either replace it with live data or use the backup in the other share to replace it. I still have a good collection of USB drives and I plug those in and rsync to them too, making for a nice third backup.

Here are some of the scripts I use to keep everything synced.

Syncing between the user shares:

rsync -Wa –delete –progress /mnt/user/UNRAID/* /mnt/user/UNRAID-BK/

Syncing between internal disks and USB disks:

dmesg | tail -10
echo -n “Mount which device? ”
read DEVICE
echo “Mounting $DEVICE”
mkdir /root/disk
mount $DEVICE /root/disk
if [ $? -gt 0 ]
then
echo “Could not mount $DEVICE”
exit
fi
echo -n “Which disk to sync? ”
read DISK
echo “SYNCING disk$DISK!”
rsync -aW –delete –progress /mnt/disk$DISK/* /root/disk
echo “UMOUNT $DEVICE”
umount $DEVICE
rmdir /root/disk

Original XBOX: Your XBOX requires service – No Error Code

I managed to mess up the files in my original XBOX’s C: drive. The XBOX would boot to this error:

According to the Internet there should have been an error code in the top corner to tell me what was going on.  I did a good enough job on it I wasn’t getting any error at all.

I had a backup of my XBOX’s drive and eeprom. What I needed to do was get access to the C: drive so I could copy over the backed up files. My first thought was to boot off of a DVD and FTP the files over. I tried Slayers and Hexen, neither would boot. Seems the XBOX needs something on the C: drive to be able to boot a DVD.

My next plan was to plug the drive into a PC. There were a few problems with that. I didn’t have anything with an IDE interface like the XBOX’s drive uses. The drive is locked to the XBOX, meaning I would have to unlock it to use it on another computer. The XBOX’s drive uses the FATX file system and I didn’t think anything supported that.

The first problem was solved by a USB to IDE adapter. I ordered a Vantec CB-ISATAU2 SATA/IDE. It also supports SATA drives. It’s pretty nice.

The second problem is solved by xboxhdm23usb. Among many other useful things, it will lock and unlock drives.

The third problem was solved by Xplorer360. It will allow you to copy to/from the FATX file system.

Here is what I did:

  1. Removed the hard drive from the XBOX.
  2. Changed jumper on the drive from master with slave to single/master.
  3. Plugged the drive into the USB adapter and plugged it into my PC.
  4. Placed my eeprom backup in the same folder as xboxhdm23usb.
  5. Used xboxhdm23usb to unlock the drive.
  6. Opened Xplorer360 and use it to copy in your backup.
  7. Locked the drive
  8. Put the jumper on the drive back to master with slave.
  9. Put the XBOX back together.

Some gotchas that I ran into:

The USB adapter was very flaky when connected to the front USB ports on my computer. It would only get recognized half the time and when recognized would sometimes just drop out. It worked fine when connected to the rear USB ports. This is the only device I’ve ever hard problems with on my front ports. The front ports are USB 2.0 while the rear ports are 3.0, maybe the problem, maybe not.

Don’t forget to lock the drive when you are done. I had it my head the drive starts locked and you have to unlock it to use  it, that is not right. The drive is unlocked until locked and then locked until unlocked.

In the end it worked out for me and my XBOX is working properly again.

 

Random Thoughts on Emulation and Retro Gaming

What follows are some very brief thoughts that are not worthy of an entire article.

I have owned a GPD XD for about a year now. It is by far the best handheld emulation device I’ve used. It plays the fifth generation consoles (PlayStation, N64) very well. Since it has a built in stand via the controller it also makes for an excellent device for watching movies during flights or lying in bed.

Hipsters have the market for buying old consoles all messed up. Everything is much more expensive than it should be. If you’re dead set on collecting you are going to spend some money, if you just want to play some games:

  • A Raspberry Pi 3 plays everything up to the fifth generations of consoles well. PlayStation support is excellent, N64 support is very bad. A Pi 3 and a PS4 controller makes for a very nice couch experience. Run RetroPie, its the easiest way to go.
  • A Nintendo DS will play GBA games. A Nintendo DS also costs a lot less than a GBA.
  • A 3DS can play DS games. A modded New 3DS can play GBA, SNES, GEN, Gameboy, NES, and more very well.
  • Nothing can emulate an original XBOX. Spend some money and get one that is pre-modded. TSOP is preferred since it makes it easy to change the hard drive.
  • A modded PS3 will play PSX, PS2, PSP, and PS3 games.
  • A modded Wii-U will play Wii-U and Wii.
  • A modded Wii will play Wii and GameCube.
  • You can buy pre-modded consoles on Ebay for not much more than a non-modded one.
  • If your PC is within 50 feet of your TV, a long HDMI cable and a PS4 or XBOX One controller will turn it into a great couch gaming ‘console’. If you also have a wireless keyboard and a mouse you’re in for good times.

Emulation on a Playstation Portable 3000 (PSP)

A PSP is a fun handheld. Compared to it’s rival the Nintendo DS, its more powerful, the games look better, and they are arguably more adult orientated.

As a long time PSP owner here is my impression of its emulation quality.

NES: Great
Gameboy: Great
Gameboy Advance: Good
Genesis: Poor. Lots of slowdowns. Sound is laggy or doesn’t sound right.
SNES: Poor. Lots of slowdowns. Sound is laggy or doesn’t sound right.
N64: Nope
Playstation/PSX: Great, if not close to perfect. The PSX emulator on the PSP was written by Sony. The quality is outstanding.
NDS: Nope
GameCube and above: Nope

I see a lot of recommendations online to use a PSP as a cheap SNES emulator handheld. Don’t fall for that. The SNES emulation is bad. It’s so bad I don’t even keep the emulators or ROMs on my PSP. I have never played through a game. I couldn’t even make it through the first level of Contra 3 because the sound of my gun was so high pitched it was annoying me.

If you want to play some PSP or PSX games, definitely get it. You’ll never go wrong playing a game on the original hardware it was designed for. PSX emulation is great, in my opinion it’s better than the PC emulators.

The biggest downside to a PSP is the battery. Batteries don’t age well and the PSP is getting old. Official replacement batteries from Sony don’t exist. Aftermarket batteries are horror stories (check out some Amazon reviews). Most people either stay plugged in all of the time or use an external battery like you would use to charge your phone in an emergency. I read an article of one guy who removed the UMD drive and soldered in two NDS batteries in their place. I’m lucky enough that my battery is in good shape, but when the time comes for a new one I’m a bit worried.

 

How to play GameCube, Wii, and Playstation 2 games on Android or Amazon Fire TV

I’m a big fan of Limelight game streaming. It works remarkable well on my Galaxy Tab S and Amazon FireTV with a PS4 controller.

I had something of a revelation the last week. If you add an emulator as a Non-Steam Game to your Steam library, you can then stream the emulator over Limelight. I’ve tried Dolphin and PCSX2, and they both work well. At this point I’ve played through all of the cups at 100cc in Mario Kart Double Dash on my Tab S and I couldn’t be happier.

The prerequisites for the setup are out there, you need:

  • A PC capable of running the emulator(s).
  • That PC needs to be GFE compatible. (Basically a GeForce GTX 650 or higher graphics card. I use a GTX 760)
  • An Android device
  • A controller for the Android device. (My Tab S is rooted and I use a PS4 controller over Bluetooth)
  • A network connection between the Android device and PC of at least 30mbp/s. (My PC and Amazon FireTV is on a gig wired connection to the same AP/router my Tab S connects to via 5GHZ wifi)
  • The Limelight software installed on the Android device. (this part is free)
  • Steam installed on the PC with the emulator(s) added as Non-Steam Games.

At the time of this writing that’s about $700 worth of PC, a $50 controller, a $80 router/AP, and then whatever your Android device costs. Anywhere between ‘free’ for a phone and $500 for a nice tablet.

As an aside, you can also stream PC games. I play a lot of Borderlands 2 over Limelight, its great playing it on my big TV with surround sound in the living room or even playing in bed.

I’ve played a lot on my Tab S and an Amazon Fire TV. I also have the Samsung Galaxy S3 and Samsung Note 4 phones, I’ve loaded Limelight and played around for a few minutes, as far as that goes it works on those devices.

 Edit: For giggles I decide to give my Galaxy S3 a go and see how well it works. I played Left 4 Dead 2 for about an hour and a half. It was playable. The only issue I ever saw was that sometimes when there was a lot of things going on on screen the game would briefly stutter, losing maybe 1/4 second worth of frames. It mostly happened when a propane tank exploded. A bit annoying but nothing to make me stop playing.