Setting Up a Feit Light Bulb with Tasmota

After much research and many failed attempts, I have finally successfully set up a Feit BPA800 light bulb (full model: BPA800/RGBW/AG/w) with Tasmota.  (If you’re unfamiliar with Tasmota, it’s alternative firmware for smart devices like plugs, switches, light bulbs, etc. that give you more control and allows you to be less dependent on a company’s cloud service to control your devices).

First off, if you haven’t installed the Tasmota firmware on your device yet, see this video which explains how to convert a “Tuya” based device (like the Feit smart bulbs) to Tasmota.

Where I ran into trouble was getting a configuration in Tasmota that properly controlled the light, changed the colors correctly, controlled brightness, etc.  Here is what I used and it seems to be working:

Template: {“NAME”:“OM60/RGBW”,“GPIO”:[255,255,255,255,140,37,0,0,38,142,141,255,255],“FLAG”:0,“BASE”:18}

For some reason, I started having trouble in the Tasmota web interface in that I couldn’t import this template in the “Configure Other” screen because the “Activate” checkbox was disabled — never figured out why this was happening.  I instead just changed all of the values on the “Configure Template” screen according to the list in the brackets above.  In other words, set:

Based on to Generic (18)
GPIO0 to User (255)
GPIO1 to User (255)
GPIO2 to User (255)
GPIO3 to User (255)
GPIO4 to SM16716 CLK (140)
GPIO5 to PWM1 (37)
GPIO9 to None (0)
GPIO10 to None (0)
GPIO12 to PWM2 (38)
GPIO13 to SM16716 PWR (142)
GPIO14 to SM16716 DAT (141)
GPIO15 to User (255)
GPIO16 to User (255)
ADC0 to None (0)

After you save, the device will reboot.  You then need to go to Configuration –> Configure Other and click “Activate” under the Template.  Then save, and it will reboot again.  You should now see controls for brightness, color, etc. on the main menu.

The other important setting was to go to the Console in the Tasmota web interface and type the command: “SetOption37 54” which changes how the color slider works so that the color you select actually changes your bulb that color.

BTW, most of this info I got from this forum post, but I wanted to summarize it here.

Also, if you want to enable “automatic discovery” if you want to control the bulb from software like Home Assistant, on the console type the command: “SetOption19 1“.

IoT Resources

So, I’ve began to create my first IoT (Internet of Things) device.  I’ve decided to list the useful resources that I find along the way here:

Blynk: A mobile app that allows you to create a custom page of controls for your IoT device.  You can also receive notifications from your device.  It is free for a simple page, but if you want more bells and whistles, you eventually have to purchase more “energy” to add more things to your page.

Adafruit IO: Similar to Blynk but on the web.  Not as many control options as Blynk, but it’s  free.  They do have a paid plan with more features.  It uses “MQTT,” a simple messaging protocol that is supposedly much faster than HTTP (i.e. using a webserver and SQL database for data logging).

Dweet.io: Allows a device to send messages.  You can retrieve them on Dweet’s website.  They start charging if you want to store old messages.  At this time, Dweet holds on to only the most recent 5 messages (for free).

 

Setting Up an ESP8266 with Arduino IDE on Windows 10

So, I just bought a couple of ESP8266 boards with ESP-12E chips on them (link to exact model on Amazon), but the directions on the Amazon description didn’t quite work for me.  My Arduino IDE didn’t detect the board.  Here are the directions (for Windows 10), modified with the added step I had to perform (in bold):

1. Download the Arduino IDE, the latest version.
2. Install the IDE
3. Set up your Arduino IDE as: Go to File->Preferences and copy the URL below to get the ESP board manager extensions: http://arduino.esp8266.com/stable/package_esp8266com_index.json Placing the http:// before the URL lets the Arduino IDE use it…otherwise it gives you a protocol error.
4. Go to Tools > Board > Board Manager> Type “esp8266” and download the Community esp8266 and install.
4.5: Install Windows 10 Driver for CP2102 UART Bridge: https://www.silabs.com/products/development-tools/software/usb-to-uart-bridge-vcp-drivers
5. Set up your chip as:
Tools -> Board -> NodeMCU 1.0 (ESP-12E Module)
Tools -> Flash Size -> 4M (3M SPIFFS)
Tools -> CPU Frequency -> 80 Mhz
Tools -> Upload Speed -> 921600
Tools–>Port–> (whatever it is)
6. Download and run the 32 bit flasher exe at Github(Search for nodemcu/nodemcu-flasher/tree/master/ at Github) github.com/nodemcu/nodemcu-flasher/tree/master/Win32/Release Or download and run the 64 bit flasher exe at: github.com/nodemcu/nodemcu-flasher/tree/master/Win64/Release
7. In Arduino IDE, look for the old fashioned Blink program. Load, compile and upload.
8. Go to FILE> EXAMPLES> ESP8266> BLINK, it will start blinking.

 

Adding a Language to gedit

When I do development, my favorite editor is gedit.  Sure, I know there are other IDEs out there with lots more bells and whistles, but I like to keep it simple.  I’ve recently come back to the Ionic Framework with a new project I’m working on.  The new version of Ionic uses “TypeScript,” a language that compiles to JavaScript.  When I went to open TypeScript files using gedit, I was bummed that there was no syntax highlighting!  Just plain gray text in the entire file.

So, I looked into how I could add text highlighting for a currently unsupported language in gedit.  The files that define the syntax highlighting for gedit are located (for me at least) in:

/usr/share/gtksourceview-3.0/language-specs/

The language files have the extension *.lang. After trying to create a TypeScript language file myself with minimal success, I finally managed to get the right Google search of “gedit lang file for typescript” and found that someone had already created one. It’s on github here.

I then just downloaded this file, placed it in the directory above (using sudo cp in the terminal to do so), restarted gedit, and it worked!

The Roku “Secret Menu”

After having many issues with my Roku remote control, after doing some digging, I found that Roku has a “Secret Menu” to diagnose and solve some common issues.  Roku literally calls it a “Secret Menu” — their term, not mine!  Think of it as an “advanced settings” menu.

Anyways, here’s how to access it:

  1. On the remote control, hit the home button five times
  2. Push the following buttons in succession: Fast Forward, Play, Rewind, Play, Fast Forward

That should get you in there…I tried doing this on the Roku App on my phone, and it did NOT work.  It seems to only work on the Roku remote itself.  Since I was having remote issues, this was a bit of, well, an issue!  I found that distance from the remote to the device does make a difference.  I think that the remote communicates via WiFi directly to the Roku (I have the Roku Streaming Stick).  I don’t believe it uses the network*.  So holding the Roku remote close to the streaming stick should at least temporarily allow you to control the Roku via the handheld remote.

*NOTE: My reasoning for believing the Roku remote doesn’t access the Roku via your home network: In the “secret menu,” I was able to see the MAC address of the remote.  I logged on to my WiFi router, and noticed that this MAC address was not present on the list of current clients.  My only conclusion is that it sends WiFi signals directly to the Roku, bypassing the router.

Adding ngCordova to Ionic

Once you’ve got Ionic installed, installing ngCordova can be nice because (as I found out recently), Ionic doesn’t include a good way of accessing Cordova/Phonegap’s plugins. ngCordova is basically a collection of Angular services that allow you to use Cordova’s plugins.

To install (after already having installed Ionic and all of its dependencies), you’ll need to install “bower” (if you haven’t done so already for some other reason):

sudo npm install -g bower

Then you need to add the following to your index.html in your project:

http://lib/ngCordova/dist/ng-cordova.js

And then add ngCordova as a dependency to the app (file may be app.js):

angular.module('app', ['ionic', 'app.controllers', 'app.services', 'ngCordova'])

Then add the plugin(s) you want like so:

ionic plugin add cordovaPluginName

Testing An Ionic Android App on a Desktop and on an Android Device

Developing an Android app via Ionic can take awhile, especially testing.  Using an emulator, for me, is out of the question because it is extremely slow.  So, what I’ve done in the past is used my own phone, connecting to the machine via USB.  But, it takes at least 10-15 seconds on my set up for Android Studio to build and run the app on my phone.

I knew there must be a way to test on a Desktop.  Ionic has a built-in server that you can run to test apps via a web browser.  To use it, you can type:

ionic serve

in a terminal window.  You need to make sure you are in the root directory of the Ionic app.  

Also, another note: one mistake I made using Ionic is that I edited my source in the android/assets/www directory using Android Studio. It turns out, this isn’t a great idea. Whenever you modify something in Ionic, say install a plugin or something, it copies the root www folder into the android www folder, thus overwriting your new code.

It turns out that using Android Studio just isn’t the best way to go to test directly on an Android device. The best way to do this is via the following commands:

ionic build android
ionic run android

I was at first skeptical that Ionic would know how to deploy to my device connected via USB…but, it does.

Setting Up Cordova (for Anrdoid Development) on Xubuntu

This is quite the process.  First, you need node.js if you don’t already:

curl -sL https://deb.nodesource.com/setup_4.x | sudo -E bash - sudo apt-get install -y nodejs

Then you need to install cordova via node package manager:

npm install -g cordova

Then you need to follow this guide to install JDK and Android Studio, to set up Android Studio, and to create the Cordova project. (Skip the part about installing Cordova CLI – you already did that above.

In creating the Cordova project, I ran into some issues in which some dependencies were not install. Just keep installing the missing ones by:

npm -g [package-name]

Once the “cordova create” command works, you’ve installed all the necessary dependencies.

I ran into an issue in setting up the “JDK” in Android Studio (i.e. I had no idea where my JDK (which is OpenJRE) was located). This article might help if you have the same issue.

I also had issues in running the app from Android Studio directly on my device. This article might help with that. Also, there are a security hoop you have to jump through. This article talks about that (see the “If you’re developing on Ubuntu Linux” section — it’s the longest one!)

There may be more to come…

Touchpad Problems

The touchpad on my wife’s new laptop was acting erratic.  After doing some research, I found that this has to do with the power supply.  However, there’s nothing wrong with the power supply, per se.  I mean, it does what it’s supposed to do  – charge the laptop’s battery.  But it somehow interferes with the touchpad.  The erratic effect, in fact, would only occur when the power supply was plugged into the machine.

I found this bit of information quoted from Wikipedia.  I was going to save the original link to the Wikipedia article, but then I found out on Wikipedia’s “talk” page, that this content had been deleted.  So, I’m putting here on yet another place on the Internet so that this precious information is not lost!  Here it is:

“If the computer is powered by an external power supply unit (PSU), the detailed construction of the PSU will influence the virtual ground effect; a touchpad may work properly with one PSU but be jerky or malfunction with another (this does not imply any electrical risk; a delicate capacitive ground, not a contact ground, is at issue). This has been known to cause touchpad problems when a manufacturer’s PSU, which will have been designed to work with the touchpad, is replaced by a different type. This effect can be checked by touching a metallic part of the computer with the other hand and seeing if operation is restored. In some cases touching the (insulated) power supply with some part of the body, or using the computer on the lap instead of on a desk, can restore correct operation.”  (Wikipedia)

 

Changing content in a Bootstrap popover

It would seem like you should be able to dynamically change the content of a popover in Bootstrap just by doing the following:

$("#someElement").popover({content: "New content here"});

But that syntax can only be used for initialization of a popover. After much searching, I finally found an answer on Stack Overflow that allows the popover content to be changed whenever.  Also, see this working demo by the same person who posted the answer on Stack Overflow.  Here’s the code:

$('#someElement').attr('data-content', 'New content here');
var popover = $('#someElement').data('popover');
popover.setContent();
popover.$tip.addClass(popover.options.placement);
$('#someElement').popover('show'); //Shows popover with new content!