All posts by Thomas W-P

Upsampling with squeezelite

I had Text-To-Speech (TTW) working really well with squeezelite and Home Assistant on a Raspberry Pi 3B with max2play (which now looks sadly defunct). I thought I would pep things up a bit and use a RPi4 elsewhere as a Speaker for HA so my music was not constantly destroyed.

Getting squeezelite to work was easy but could I get TTS to work? The mp3 file was created but squeezelite looped when trying to play it. Sad times.

I worked out that it played fine when the sample speed was increased and in all my searching hit upon the concept of “Upsampling”. Hmmm. Since I had originally used “apt get install sqeezelite -y” and found it hard to find any settings at all and had not yet really understood docker I took this opportunity to move to a docker setup. Happily one of the settings allowed the magic “Eq” that got things rolling along.

version: "3"

    image: giof71/squeezelite:latest
    container_name: squeezelite
      - /dev/snd:/dev/snd
      - SQUEEZELITE_AUDIO_DEVICE="hdmi:CARD=vc4hdmi1,DEV=0"
      - SQUEEZELITE_NAME="Kitchen Panel"
      - SQUEEZELITE_MAC_ADDRESS="45:07:31:83:01:40"
      - SQUEEZELITE_PARAMS="80:4::"
    restart: unless-stopped

macvlan with docker and pihole

This web page (Set up a PiHole using Docker MacVlan Networks) is great and got me there, but here are notes on how I fixed it globally. I use many stacks.

You need MACVLAN network to fake an external IP for the DNS/DHCP server or it does not work (the requests don’t come through docker). But if you make a macvlan IP address, by design the host cannot see that IP address! You have to make a bridge.

If that bridge is local to the docker compose file, then only that stack can see it. For all stacks to see it you need to make a new macvlan and bridge network globally (I did this in portainer).

Steps to create:

1. Make a macvlan configuration

name: pihole-macvlan-config
Interface: eth0
IPV4 Subnet -	IPV4 Gateway -
IPV4 IP Range -	

2. Make the macvlan using that configuration (just select the configuration and give it a name)

name: pihole-macvlan
driver: macvlan

3. Set up the bridge

name: pihole-bridge
IPV4 Subnet -

4. In pihole set up the brige ip address.


5. Use nmtui to change the host “dockerbox” DNS to and give it a fixed IP address. All the containers will look for that for the DNS but need pihole-bridge network to see it.

sudo nmtui

6. In each container that needs pihole you add the network pihole-bridge


    container_name: tasmoadmin
      - ./tasmoadmin-data:/data 
      - 9541:80
    restart: unless-stopped
      - homeassistant
      - mqtt
      - pihole-bridge

Athom Tasmota Button On/Off

I accidentally factory reset one of the plugs and the button stopped toggling the switch. This was the coffee machine – a slight catastrophe for the odd times it needed a manual toggle.

I found the athom page had a mystery “template” and worked out where to enter it on the tasmota. Job done.

{"NAME":"Athom Plug V2","GPIO":[0,0,0,3104,0,32,0,0,224,576,0,0,0,0],"FLAG":0,"BASE":18}

Configure Other, then put it in a the top and tick Activate.

Tasmota Auto Off

This took me a while the first time, then found I had to do it again and had to look it up once more. One kind person had already worked this out and it led me to this command in the tasmota console:

Rule1  ON Power1#state=1 DO RuleTimer1 1800 ENDON ON Rules#Timer=1 DO Power1 Off ENDON


Rule1 1

To enable the rule.

This rule will turn off thetasmota socket 30 minutes after it is turned on.

Of course, I should probably be doing that with Home Assistant now. Then I don’t have to go looking for the rule.

So that is what I did!

Home Assistant Templates

I have been getting to grips with Home Assistant (hassio). (This was after attempting, late at night and tired, to update OpenHab… It didn’t go well and though I had solid backups I knew I would need to do a full restore and have kept hearing about Home Assistant. I wanted to give it a try, and found it is so much better than OpenHab. I had everything OpenHab had and more in one morning of play. Everythign is so much easier).

So the more I got in to hassio the more I kept hearing about Templates. Hassio is well documented but there are no examples at all. I can read them but miss the point because, typiccally, I read too fast.

So when the Templating documentation said:

Templating in Home Assistant is powered by the Jinja2 templating engine. This means that we are using their syntax and make some custom Home Assistant variables available to templates during rendering.

I didn’t realise this meant “custom code”. That would have helped. Template = Custom Code in Jinja2!

I went in to the Developer Tools > Template and had a play (with the help of avideo by “Smart Home Junkie”) I found that I could easily get the value of things using {{ states(‘the_thing’) }} (I also found that the Dutch word for curly bracket is “accolade” which is way better to my ear).

With my new knowledge I made my first Template to show the current rate as a read only thing so I can display is safely.

  1. A name – this is what you look up later and is turned in to a spaceless name, this one would become current_rate
  2. The Jinja2 code
  3. Preview

I made a sensor called “Current electricity period” and magic happened when creating a dashboard.

I know it is basic knowledge, but I needed to make this first step. I think I am away now.