Android app to reset your old smart TV’s pin number — Panasonic Viera

This is the second part of another story which started on this post

Problem

As I shared on my previous post, a friend of mine was running into some trouble trying to reset his old Panasonic Viera’s PIN number.

Long story short: I wrote a python script that was able to reset the TV’s PIN number. But then another friend had the same TV with the same problem, but with an extra layer of complexity: he had completely lost his remote control.

So I though I better convert my python script into an android app, so as I could just share him a download link without needing to pay him a visit carrying around all my gadgets.

Solution

Pin Reset Remote Control android app for Panasonic Viera

Before I jump into how I managed to get this app working, I want to send a big thanks to both Victor K Varghese for his awesome react-native-boilerplate which allowed me to hit the ground running, and Daniel Reinoso for his wonderful react-native-ir-manager which got me control of my phone’s IR Blaster.

Development

To start with I had it easy this time, because just couple of days back I had written another script to automate this process. So this time I did know how to get this task done, it was only a matter of writing a small Android app.

I only went for Android, because I got an Android device with an IR Blaster, which not many devices have. I know that there are some IR Blaster plugins that you can attach to your audio jack, but I didn’t test that. Nor I did investigate the iOS side of things. Just needed a simple remote control with the capability of reseting the TV’s PIN number.

So I chose to start with react-native-boilerplate since I didn’t want to start from scratch and among all boilerplates that I found, this was the cleanest one offering me TypeScript out of the box. Not that I’m a big fan of TypeScript, but it saves me a lot of time on the long run.

Then I chose native-base from GeekyAnts which provides easy to use UI elements, which is very handy for Back End developers like me. So I mocked up a UI as quick as I could, and then started to look for into the IR side of things.

As I was writing the app in React Native, I needed a react-native interface in order to use the Infrared (IR) transmitter. I found react-native-ir-manager which worked almost out of the box. There where 2 minor compatibility issues, but nothing to do with the bridge itself but with the integration I was doing.

Once I got that sorted I browsed for the Pronto Codes, that is to say, every manufacturer has it’s own IR signals for each button — that’s why not every remote control works with every TV. To my surprise it was pretty easy to find pronto codes for the Panasonic Viera TV, you can find them on this link.

As it was a pdf file I converted it into a json file so I would be able to use them from the app. Also I wanted the app to be reusable, so should another person needs to use this remote on another TV, then it’s just a matter of swapping that json file.

Then I wired each button to it’s corresponding code and voilà! it all worked!

Pin Reset Method

Although I had the basis of this method written in my previous python script it was not as easy as I thought to rewrite it in TypeScript. And that was mainly because TypeScript is a subset of JavaScript which is an asynchronous language, which means that the code doesn’t get interpreted from top to bottom as it it written most of the times.

That meant that I had to add an extra library to create a loop that would iterate numbers one by one with some threshold without causing havoc. Luckily the Caolan McMahon wrote an the amazing async library, which got exactly what I needed, a method that would iterate numbers one by one.

That is eachOfSeries, on top of which I added a couple of timing thresholds to meet the TV’s limitations.

Pin Reset method for Panasonic Viera

As you can see on the resetPin method, I got an iteration nested onto the other. That is because I first iterate numbers from 0 to 9999, and once the code hits each number on that range it converts it to the PIN format needed — 0 = 0000, 10 = 0010, …, from where the corresponding numbers are triggered to the TV.

Conclusion

It seems to be pretty easy nowadays to write a remote control app. There are a lot of awesome libraries and projects out there you can grab and start with.

You can find the source code of the app on GitHub.

And if you are only interested on downloading the app, you can find it here.

Just make sure that your phone has enough battery or is plugged it before trying to reset the PIN number. It might take a while due to the TV’s limitations, and you don’t want to run out of battery.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store