Saturday, July 14, 2018

Playing with Docker

It's been stressful at work, home, and everything else but I have had some time to learn new technologies (or learn more about them). I just published my first node-red node called node-red-contrib-mytimeout. It started out as a clone of Pete Scargill's node-red-contrib-timeout. I just wanted to learn how to create a node and publish it. It quickly morphed into a node of it's own. I found I didn't really understand Pete's code so I poked at it until it did what I wanted. But the code ended up having so many corner cases and patches to get it to work that it became unmaintainable. So I rewrote it starting with a simple state machine. Then I started to run into the corner cases (mostly the different types of input) that the node needed to handle. So I rewrote it again and again and again. I think it's much better now. :-) I'm not saying it's the best way to do things or that I'm a great programmer just that it's better than it was ... a lot cleaner. One thing I picked up was putting node-red into it's own docker container. That helped with testing the new code. Which is all manual at the moment. It seems that I need to learn to make better use of git branches to deal with master, hotfix and features. I did try to make use of node-red-node-test-helper but I don't quite understand it yet and I haven't been able to get the examples to work. I'll spend a bit more time with docker and node-red and understanding node-red-node-test-helper. I did manage to find the solution to being able to do a docker exec and getting an error

$ docker exec -it mynodered /bin/bash
unable to find user node-red: no matching entries in passwd file
$ docker exec -it -u 1001 mynodered /bin/bash
node-red@49cd98fddf2e:~$

I figured out 1001 for user node-red by looking at the /etc/passwd file that I copied out of the container. I could have also logged in as root with 0 and poked around but being root should be limited to only when you need it.

Once I figure out node-red and some kind of reasonable testing strategy I'll have my first Continous Integration (CI) project completed. I do see the full value of this as a way not to repeat the mistakes of the past.

Sunday, March 25, 2018

My TCF HA Demo & Presentation (March 17th 2018)

My 2018 presentation went well but not perfectly. I decided that I would explain a little bit, then demo, then go on to further explain everything. I really want the demo to stay at the start of the presentation, perhaps better if it runs throughout the demonstration as I show the parts so the demo is more interactive (I can do that). Perhaps a little paint would also help indicate what is what. The demo went perfectly (unlike last year where dnsmasq somehow lost it's settings). The test program did a nice job and wow'd everyone. I think I need to take advantage of that. This year I put a lot of effort into building the display, then at the last minute realized I hadn't organized my slides (Doh! I have a lot!). So I tossed out anything I couldn't easily explain or wasn't pertinent and tried to get some order. I didn't get a chance to run through the material but I really know this stuff, what could go wrong? Well the first thing, I didn't really looked at the front of the display. It seems I cleaned up so well that there was no way to tell what controller was controlling what bulb. So basically no one knew what they were looking at which led to a lot of confusion. Also the next issue was that there was no base use case. Something simple (thanks Bill Dudley for pointing that out). That would have given me a nice base to start with. So next year's presentation will be clearer, start with something simple, one Sonoff Basic and a bulb and grow from there. I've also noticed that many folks have said that I have so much that I probably need 2 hours to cover it all. So next year I'll do 2 presentations. For now I'll start off with the explanation, then the second I'll actually build and add devices (sonoff's with the Arduino Sonoff-Tasmota software) and add it to the Node-Red setup. Perhaps, if there's time I can show some of what MQTT is doing.

So the lessons learned, always walk through the presentation even if you know the material. Start simple and expand. Share the presentation with others and listen to their opinions. You may not be able to use their advice but it should give you some ideas. Look at things from the audience view (literally) you might see something that confusing or not clear.