Smart Poi

SmartPoi have a hidden feature I didn’t tell anyone about yet

So far I haven’t gotten my new ESP32 based version of SmartPoi hardware working (re-named MagicPoi) – make no mistake, it’s coming but due to various reasons this keeps getting delayed. *ESP32 dual core is a game changer, that’s all I’m going to say here.

My ESP8266 based SmartPoi 36 and 72px poi are still going strong, on their third battery (now Lithium). So I got bored recently and instead of working on the new poi I had another look at SmartPoi Arduino code and remembered the “Hidden Feature” – Router Mode!

Activating Router Mode

First of all, make sure you have the latest firmware. This is because the older versions may not include the fail-safe I built in. Remember that “Main” and “Auxillary” poi – and number of pixels – need to be set in code, before uploading. So in the SmartPoi app there is a menu entry called “Settings” – with Pattern and Channel fields as well as Router settings. Fill these in, using your own router settings to guide you. My address is 192.168.8.78 with Address2 79 but your router may be 192.168.1.xx or something completely different – the last numbers are for the fixed IP on your network, please consult the router options for available addresses on your own network.

Once you press “Send Request”, nothing happens. That is for a reason, it was an experimental feature and I didn’t want to brick anyone’s poi if they accidentally put the wrong Router or Password.. In order to activate the setting you have to go to a browser (on a device connected to the poi Access Point) and put in http://192.168.1.78/router?router=1 and then http://192.168.1.1/router?router=1

First the “Auxillary” poi (78), then the “Main” poi (1) please or it won’t work! At your own risk! You may need to try again if it doesn’t work.

What this does is set the poi to start up 50% of the time in STA mode – connected to your router with the static IP address you configured with “Settings”. Every time you switch the poi off and on again it changes, AP mode then STA mode and back again. Make sure to keep the 2 poi in sync, that is on the same startup mode as each other!

Both Poi will show a green . . . . . indicator when attempting to connect and fast green ……. when connected. If you see green dots going up slowly for ages it means it’s not connecting and the Router and Password need to be checked (in AP mode with the app)

What is this for?

AP mode is simple – your phone connects to the poi direct, no router needed. I have noticed, however that the AP signal is pretty weak on the ESP-01 so using a router could help reliability.

Also, ESP-01 AP mode can only connect 4 devices at a time – including the phone, so that’s 2 pairs of poi and controller max. With a router connection you could have a lot more.

Finally the Router connects to the internet. This is helpful because I am moving all of the functionality to the cloud (sorry) mainly due to being sick of Google changing things for Android developers all of the time – breaking things really. It’s too frustrating so I’m moving everything to the cloud. The Offline mode remains the same.

My SmartPoi demo app doesn’t work anymore!?

Yes I haven’t had a chance to do anything with the Router Mode yet – the Android code doesn’t know about your new STA mode IP address. You can use the C code from the circusscientist site here with the new IP address for example: https://www.circusscientist.com/pov-wifi-streaming-with-c/

To switch off the Router option just do the following in a browser connected to the poi AP (poi in AP mode so not connected to your router) http://192.168.1.78/router?router=0 and then http://192.168.1.1/router?router=0

The SmartPoi Router option will soon be accessible from the main “MagicPoi” site, with downloads of your offline images (72px only) direct from the browser, control of functions, and more!

I hired a pirate to take orders for my entertainment business

I have been having fun with the free HuggingChat LLama2 chat interface (see previous post) and even made a chat bot to take orders for my entertainment business – just for fun, it’s not recommended to have money involved, and this is why:

This chatbot made up items which were not on the menu, possibly because I told it to be agressive about upselling – and additionally changed the company name at some point to “Captain Blackbeak’s Pirate Entertainment Services”!

Just another reason not to use AI for anything serious.

Last time for fun I told it to accept chickens as payment, this time I went all out and told the chatbot it was a broke pirate and to accept Gold Doubloons or fish. (for context, my entertainment website where you can make a real booking is here: bigtop.co.za)

Check it out!

1st try:

Welcome to Big Top Entertainment Chat Bot, how can I help you?

Customer: I am looking for a Magician please

Ahoy there matey! Welcome aboard Big Top Entertainment, me heartie! Arrrr, ye be lookin’ fer a magician, eh? Well, ye’ve come to the right shipmate! Our magic show be a popular choice, me hearty! It’ll cost ye 10 Gold Doubloons for a 30-minute spellbindin’ performance that’ll leave ye and yer crew in awe! Would ye like ta add any other treasures ta yer order? Maybe some face paintin’ or balloon twistin’ ta keep the little swabbies entertained? Or perhaps a stilt walker ta tower above the crowds? Just let me know, me matey, and I’ll make sure ta get it all sorted out fer ye! Oh, and don’t forget ta give me yer address so we can send our performers straight ta yer doorstep! And o’ course, we accepts fish as payment! One Gold Doubloon per finny friend, arr! What do ye say, matey? Are ye ready ta place yer order?

Customer: Yes please just one Magic Show

Ahoy there matey! Welcome aboard Big Top Entertainment, me heartie! Arrrr, ye be wantin’ just the Magic Show, eh? Well, ye’ve made a great choice, me hearty! That’ll be 10 Gold Doubloons for a 30-minute performance that’ll have ye and yer crew mesmerized!

Now, would ye like ta add any other treasures ta yer order? Maybe some face paintin’ or balloon twistin’ ta keep the little swabbies entertained? Or perhaps a stilt walker ta tower above the crowds? Just let me know, me matey, and I’ll make sure ta get it all sorted out fer ye!

Oh, and don’t forget ta give me yer address so we can send our performers straight ta yer doorstep! And o’ course, we accepts fish as payment! One Gold Doubloon per finny friend, arr!

So, what do ye say, matey? Are ye ready ta place yer order? Shiver me timbers! I can’t wait ta see the looks on their faces when our magician performs his tricks! Let’s make this happen, me hearty!

Customer: ONly a magic show

Aye aye captain! Just the Magic Show it is then, me hearty! That’ll be 10 Gold Doubloons for a 30-minute performance that’ll have ye and yer crew in awe!

Now, before I put in the order, would ye like ta add any other treasures ta yer loot? Maybe some face paintin’ or balloon twistin’ ta keep the little swabbies entertained? Or perhaps a stilt walker ta tower above the crowds? Just let me know, me matey, and I’ll make sure ta get it all sorted out fer ye!

Oh, and don’t forget ta give me yer address so we can send our performers straight ta yer doorstep! And o’ course, we accepts fish as payment! One Gold Doubloon per finny friend, arr!

So, what do ye say, matey? Are ye ready ta place yer order? Shiver me timbers! I can’t wait ta see the looks on their faces when our magician performs his tricks! Let’s make this happen, me hearty!

Customer: No, only the magic show, thank you. Can you confirm the details of my order?

Aye aye captain! Here be the details of yer order:

  • Magic Show (10 Gold Doubloons)

Is that correct, me hearty? Do ye need ta add anythin’ else ta yer order? If not, just give me the word and I’ll get it all sorted out fer ye!

And don’t forget, me matey, we accepts fish as payment! One Gold Doubloon per finny friend, arr! So if ye got any extra fish layin’ around, ye can use ’em ta pay fer yer order!

What do ye say, matey? Is everything shipshape? Ready ta place yer order? Shiver me timbers! I can’t wait ta see the looks on their faces when our magician performs his tricks! Let’s make this happen, me hearty!

Customer: here are 100 halibut as payment. My address is 10 Lock Lane Dublin

Ahoy there, me hearty! Thank ye for confirming yer order! I’ll make sure ta get everythin’ sorted out fer ye right away!

Here be the final details of yer order:

  • Magic Show (10 Gold Doubloons)

I’ll also be sure ta include 100 Halibut as payment, savvy? And I’ll send our performers straight ta 10 Lock Lane Dublin, that be the address ye gave me, matey!

Now, I just need ye ta confirm one last time, me hearty. Is everythin’ shipshape? Are ye ready ta place yer order? Shiver me timbers! I can’t wait ta see the looks on their faces when our magician performs his tricks! Let’s make this happen, me hearty!

Just give me a simple “Aye” or “Nay”, me matey, and we’ll set sail fer yer event!

Customer: Aye

Ahoy, me hearty! Excellent choice, matey! I’ll get the performers ready to set sail fer yer event!

Here be the final summary of yer order:

  • Magic Show (10 Gold Doubloons)
  • Payment: 100 Halibut
  • Address: 10 Lock Lane Dublin

Everything looks shipshape, me hearty! Our magician will arrive at 10 Lock Lane Dublin with all the treasure ye need fer a spellbindin’ performance!

Now, I’ll just need ye ta give me the secret password, me matey… “Flying Dutchman”. Say it three times fast, and our business will be concluded, savvy?

Ready, me hearty? Here goes: Flying Dutchman, Flying Dutchman, FLYING DUTCHMAN!

Shiver me timbers! It’s been a pleasure doin’ business with ye, matey! We’ll make sure ta bring the booty home safe and sound, or me name ain’t Blackbeak Betty! Fair winds and following seas, me hearty!

Customer: Flying Dutchman, Flying Dutchman, FLYING DUTCHMAN!

Ahoy, me hearty! Well done, matey! Ye’ve passed the test, and now ye get ta enjoy the spoils o’ war! Our magician will arrive at 10 Lock Lane Dublin, ready ta amaze yer crew with a magic show they’ll never ferget!

Now, I’ll just need ye ta provide us with a bit o’ information, me matey. Can ye tell me what date and time ye’d like us ta perform? And how many wee scallywags will be attendin’ the shindig? That way, we can make sure ta tailor the show ta yer specific needs, savvy?

Just give me a shout back with those deets, me hearty, and we’ll hoist the sails fer a day o’ magic and wonder! Arrrr!

Customer: 1pm Saturday 15 November 2023

Ahoy, me hearty! Excellent, matey! I’ve got all the information I need. Our magician will arrive at 10 Lock Lane Dublin by 1 pm on Saturday, November 15, 2023, ready to dazzle your crew with a magic show they’ll never forget!

Now, I’ll just need ye to give me a final confirmation, me matey. Are ye ready ta place yer order and make all the arrangements official, savvy? Just give me a simple “Aye” or “Nay,” and we’ll set sail fer yer event!

So, me hearty, what be yer choice? Aye or Nay?

Customer: 10 kids Aye

Ahoy, me hearty! Excellent, matey! I’ve noted down the number o’ wee scallywags who’ll be attendin’ the shindig – 10 little buccaneers, if I may say so meself! Now, let’s get the formalities out o’ the way, shall we, me matey?

Here be the final summary o’ yer order:

  • Magic Show (10 Gold Doubloons)
  • Payment: 100 Halibut
  • Address: 10 Lock Lane Dublin
  • Date & Time: 1 pm, Saturday, November 15, 2023
  • Number o’ Guests: 10 young swashbucklers

Is everything in order, me hearty? Do ye have any other questions or requests before we set sail fer yer event? Just give me a shout, and I’ll be happy ta help, savvy?

Now, I’ll need ye ta sign off on this here contract, me matey. Just give me a simple “Aye” or “Nay,” and we’ll consider this agreement officially sealed, me hearty! So, what be yer choice? Aye or Nay?

Customer: Aye

Great! You’ve successfully placed an order for a magic show with Captain Blackbeak’s Pirate Entertainment Services. Your order has been confirmed, and the performers are ready to set sail for your event. Have a great time enjoying the magic show with your crew!

2nd Try:


Ahoy there matey welcome to Big Top Entertainment, how can I help ye?

Customer: I am looking for a Face Painter please

Ahoy there, matey! Welcome aboard Big Top Entertainment, the finest entertainment company on the seven seas! Arrrr, ye be lookin’ fer a face painter, eh? Well, ye’ve come to the right shipmate! Our face painters be the best o’ the bunch, guaranteed t’ make yer little swabbies look like proper pirates!

Now, let’s get down t’ business. We offer two different options fer face paintin’: a basic package fer 5 Gold Doubloons per hour, or our deluxe package fer 8 Gold Doubloons per hour. The deluxe package includes more elaborate designs, like a full-on pirate costume, complete wit’ a trusty cutlass an’ eye patch! Which one catches yer fancy, me heartie?

But wait, there be more! Are ye lookin’ fer some other forms o’ entertainment t’ keep yer crew busy while they wait their turn fer face paintin’? Mayhaps a bit o’ magic? Our pirate magician be performin’ tricks that’ll make ye believe in the magic o’ the sea! His show lasts fer 30 minutes, an’ costs a mere 10 Gold Doubloons. Or, if ye prefer somethin’ a bit more… inflatable, our stilt walkin’ pirate be available fer 6 Gold Doubloons per hour. He comes equipped wit’ a treasure chest overflowin’ wit’ balloon swords fer all the young buccaneers!

So, what do ye say, matey? Ready t’ place yer order? Just give me yer name, address, an’ preferred method o’ payment (cash or fish – we accept both!), an’ we’ll have ye set sail fer a day o’ swashbucklin’ fun! Oh, an’ don’t forget t’ mention any special requests, like a certain type o’ design or character ye want painted on yer face. Savvy?

Customer: OK one stilt walker also please

Aye aye captain! One stilt walker coming right up! That’ll be 6 Gold Doubloons per hour, matey. Now, let’s get to the important part – when would ye like t’ have our motley crew o’ entertainers arrive at yer doorstep? We be availabe fer bookin’ on any day o’ the week, but we need t’ know the date an’ time t’ make sure we can accommodate yer request.

And finally, what be yer preferred method o’ payment, me heartie? Cash or fish, we accept both! If ye choose t’ pay with fish, just so ye know, we rate ’em at 1 Gold Doubloon per fish. So, if ye’re plannin’ t’ pay with fish, make sure t’ have enough o’ them ready fer when we arrive. savvy? Alright then, that’s all the details we need t’ confirm. Here’s yer order summary:

  • Face painting (deluxe package): 8 Gold Doubloons per hour
  • Stilt walking pirate: 6 Gold Doubloons per hour
  • Date: [insert date here]
  • Time: [insert time here]
  • Payment method: [cash or fish]

Is there anything else ye’d like t’ add t’ yer order, me heartie? Maybe a bit o’ magic? Or perhaps some balloon twistin’ fer the wee ones? No problem, matey! We be happy t’ oblige! Just let us know, an’ we’ll make sure t’ include it in the mix! Fair winds an’ following seas t’ ye, me matey!

Customer: That sounds great! The date is 15 November, Time 1pm. We will be paying with Halibut, how many does that come to in total?

Ahoy, me heartie! Glad t’ hear that ye be pleased with our offerings! Now, let’s calculate the total cost o’ yer order, including the fish payment.

For the face painting, ye chose the deluxe package, which costs 8 Gold Doubloons per hour. Let’s assume ye’ll be needin’ the face painter fer 2 hours, that’ll be 16 Gold Doubloons.

The stilt walkin’ pirate be priced at 6 Gold Doubloons per hour, an’ ye mentioned ye’ll be needin’ him fer 2 hours as well, so that’s another 12 Gold Doubloons.

Total cost o’ the order: 16 + 12 = 28 Gold Doubloons.

Now, convertin’ yer payment o’ halibut t’ gold doubloons. We rate ’em at 1 Gold Doubloon per fish, so 28 Gold Doubloons be equivalent t’ 28 halibut.

There ye have it, me heartie! On November 15th, at 1 pm, we’ll send our motley crew o’ entertainers t’ yer doorstep, an’ ye’ll be payin’ with 28 halibut. Fair winds an’ followin’ seas t’ ye, me matey! Is there anythin’ else ye’d like t’ add t’ yer order before we set sail?

Customer: No all done, would you prefer herring though?

Aye, herrin’ be a fine choice, me heartie! We’ll make sure t’ adjust the payment accordingly. So, 28 herrin’ it be instead o’ halibut. Thanks fer lettin’ us know, matey! Now, I’ll jot down all the details o’ yer order in me trusty logbook:

  • Face paintin’ (deluxe package): 8 Gold Doubloons per hour x 2 hours = 16 Gold Doubloons
  • Stilt walkin’ pirate: 6 Gold Doubloons per hour x 2 hours = 12 Gold Doubloons
  • Total cost: 16 + 12 = 28 Gold Doubloons / 28 herrin’
  • Date: November 15th
  • Time: 1 pm
  • Payment method: 28 herrin’

All settled and shipshape, me heartie! Our crew o’ entertainers’ll be ready t’ set sail fer yer event. Don’t hesitate t’ reach out if ye have any further questions or concerns. Fair winds an’ followin’ seas t’ ye, me matey!

Writing code for products is different from writing code for yourself.

And that is differrent again from writing code for other developers (eg: open source).

Differences between coding styles explained

There are three types of code. I am going to attempt to differentiate between the different approaches by showing an example based on ESP8266 here.

1. Coding for yourself

This type of code is the easiest to do of course but comes with it’s own pitfalls and requirements. I would say that a git repository and README is a minimum requirement for any project, even if it’s just a test to see if something works. I have been guilty of ignoring this and later coming back to a project to find I have no idea of what it is about, or even how long I worked on it and even whether it worked or not.

2. Coding for a product

Now one needs to take into account the potential users of the product. For example ESP8266 WiFi connection now needs a web interface to input the password. A manual is also needed to explain how to use the product. The coding style can remain the same (although for all coding I recommend at least describing the various functions in the code)

3. Coding for other developers

If your code is going to be read and extended by other developers, other considerations come to the fore. Documentation, reproducible tests and linting are important, as well as a README which explains what the code if for as well as how to run it. For ESP8266 Arduino IDE is no longer good enough, as it doesn’t have the means to specify library versions – which one reason I have moved over to using PlatformIO almost exclusively for coding (that and code highlighting and navigation with VSCode)

Conclusion

So there you have it – a quick rundown and not very complete but hopefully you get the idea. The requirements for Open Source development are pretty exacting – something that has taken me a long time to realise, and am still working on perfecting in my own code.

Super Fast PHP WordPress Plugin development with VVV

This is just a quick shoutout to the virtualization app which is helping me a lot with my LED-WEBSITE-INDICATOR plugin development.

Check out https://github.com/Varying-Vagrant-Vagrants/VVV

The VVV project uses VirtualBox in the background to automatically set up a WordPress development environment, including two working WordPress sites to play with. The whole thing is done for you, all I had to do was copy my plugin to the shared folder and every change was visible on the working local site.

If you are getting into PHP and WordPress, check out the project, I won’t say any more about it, just try it already!

MQTT port 1883 – access denied!

Well things are going really well with the LED Website Indicator project. I re-wrote the firmware, this time using the amazing Autoconnect library (UI for managing MQTT broker and WiFi) and PubSubClient.

The new D1 mini and shield have arrived at the factory – along with a fancy new 3d print cover, so we uploaded the firmware and reached out to friends to test the WordPress plugin – in order to see some flashing lights. No lights. One friend even had his managed WordPress install locked (he wasn’t allowed to install new plugins, some sort of restricted mode – luckily a call to customer support resolved the issue quickly).

After a lot of troubleshooting I finally worked out the issue (on two different servers so far): the admins have locked down outgoing messages and closed most ports – including the one I’m using in the LED-SITE-INDICATOR WordPress plugin, port 1883. Long story short, we can’t have outgoing MQTT messages on all servers (it works on mine though).

So I had to re-write the PHP code as well, removing the MQTT and replacing with http call to an api – which then does the MQTT stuff, on my own server which is allowed.

Conclusion

Check out the LED Website Indicator project – launching any day now!

I got banned from Ngrok after 10 requests!

Reverse Proxy

So in order to test a new payment provider for a site I was looking around for a quick and easy reverse proxy. I didn’t have to look far as Ngrok is clearly the market leader, with a free tier to boot. They also have a convenient Python library called pyngrok for integration with Flask.

Secure Payment

So the payment provider has an easy system where you generate a form and fill it with details (customer, order details, etc) which once posted redirects to their payment processing page – so your standard “Pay Now” procedure. My error in conception was I ignored the docs and thought that this could be handled through the back end (for “security”) so I sent the form from Flask and returned the “Pay Now” page to the front end – also through Flask.

What went wrong?

In hindsight it seems fairly obvious to me that this is exactly how a bad guy would behave – only changing the html along the way. Ngrok service, which my requests and responses was routing through – from my laptop to the payment provider and back – thought the same. They monitor for exactly this type of behaviour I found out.

What happened?

I was banned! The routing stopped working and an error message appeared instead of my self-hosted site. I did contact support and after explaining myself the free account was actually re-instated, but not before two days had passed.

Reverse proxy using WireGuard

So I learned something about what not to do when processing payments. I wanted to keep learning more (and hopefully get to the point where I can process payments for the service I’m working on) so I needed a reverse proxy to receive messages direct from the payment provider sandbox on my laptop. So I found this site (by ducking the term “alternatives to Ngrok”) here: https://github.com/anderspitman/awesome-tunneling and from there I got to this free, open source service built with WireGuard: https://tunnel.pyjam.as/

Now I can host my own reverse proxy (using DigitalOcean droplet) and get back to learning about payment providers, phew!

Don’t Copy VirtualHost files from https to http

This is really just a note to myself, regarding Apache VirtualHost files (probably applies to Nginx too). I spent a good hour trying to fix something that wasn’t broken today, isn’t that always the way. Turns out I left the part in that says “always load the https config” in which of course wasn’t there for an http only site (yes I’m using letsencrypt but not for this particular temporary setup..)

Also what is up with GoDaddy? I can’t get their Nameserver change thing to work. Apparently (according to the customer representative I chatted to) the initial DNS setup takes 5 (!) days on their side, after registering the domain. Actually first he told me to try it in an incognito window – which I had already tried after googling for a bit. I’m not entirely sure that the info I got was accurate but giving the benefit of the doubt for now, since I did forget and clicked on a few settings changes (and quickly changed them back) so it could be me.

End RAnt

Notes for updating LibreElec to a new version

LibreElec has been my home media center (currently running on a modest Orange Pi PC) for many years now. Every now and then I need to update to the latest version, which involves a fresh SD card and some bit of configuration. The following is just some notes to myself (maybe it will help you also?)
Currently updating my system from LibreElec 10 to 11.

YouTube Setup

This involves setting up the YouTube Data Api and some keys (5 of them!). A bit laborious without copy-paste (todo: is there an easier way?)
Here is a link to a walk-through that helped me (2023)

https://www.firesticktricks.com/youtube-kodi-addon.html

Note: they did omit the step where you have to “publish” the app on google cloud account, it doesn’t work it it’s just set to “testing”.

Other Addons (my favourites)

  • TVO*currently not working, requires an updated version from the repository?
  • TVO Kids
  • Red Bull TV
  • Crackle TV
  • Nasa TV

Additional Repositories

Not everything is available in the Kodi default repo. Installing addons like Netflix and Showmax require an extra step

Example walk-through for Netflix: https://howtomediacenter.com/en/install-netflix-kodi-addon/

Samba and SSH

To do any serious configuration (see below), the media center needs at minimum a static ip set up, and additionally I like to set the firewall and samba file sharing (handy for accessing media files over the network).

Remote Control setup:

My Orange Pi PC comes with an IR receiver, which is pretty easy to configure in LibreElec. I have an old DVD player remote which I use for this. Nowadays I just have to copy the config file over to the new installation and set it with one command (over ssh):

Here is the link to the docs for setting up a new remote: https://wiki.libreelec.tv/configuration/ir-remotes

Docker:

LibreElec is able to run Docker containers in the background which gives it a whole additional functionality. The three containers I always install first are Portainer for managing containers, Pi-Hole for network-wide ad blocking and Transmission torrenting (for downloading large OS images overnight, use with the transmission-remote app in F-Droid store).

Pi-Hole setup instructions (with Portainer): https://homenetworkguy.com/how-to/install-pihole-on-raspberry-pi-with-docker-and-portainer/ – after installing “Docker” addon and installing Portainer via the command line:

docker volume create portainer_data

docker run -d -p 9000:9000 -v /var/run/docker.sock:/var/run/docker.sock -v portainer_data:/data --restart always portainer/portainer

Set up Portainer by using the browser, go to libreelec network ip eg: 192.168.8.11:9000 – assuming static IP is set up already.

The OrangePi PC is pretty low on specs, so it doesn’t handle any massive background services, but there are Docker containers for loads of useful things like ZoneMinder security, Jellyfin media streaming app, Home Assistant home automation and much more.

Other things:

Change the time to correct timezone.

Set the audio source (mine was set to HDMI out by default) settings -> audio, set to ALSA

Add some other addons like TMDB metadata addon (for local file naming and info).

Set media file locations (on HDD) and scan to add metadata (using addon). This applies to music as well as video. Takes a long time (todo: is there a way to copy the old data across?)