Category Archives: IOT / Domoticz / Home Assistant

Home Assistant day

1 – Added remote control for our media devices.

2 – Added automation for our green wall with plants in the garden
(These can be watered using a zigbee automatic valve.)

If during the day the temperature is above 25 degrees, a water drip value is turned on for 5 minutes

alias: Groene muur
description: ""
triggers:
  - trigger: time
    at: "01:00:00"
    id: reset
  - trigger: time
    at: "20:00:00"
    id: run
  - trigger: temperature.changed
    target:
      entity_id: sensor.buienradar_temperature
    options:
      threshold:
        type: above
        value:
          active_choice: number
          number: 25
          unit_of_measurement: °C
    id: temptrig
  - trigger: time
    at: "20:05:00"
    id: stoprun
conditions: []
actions:
  - choose:
      - conditions:
          - condition: trigger
            id:
              - reset
        sequence:
          - action: input_number.set_value
            metadata: {}
            target:
              entity_id: input_number.heattrigger
            data:
              value: 0
      - conditions:
          - condition: trigger
            id:
              - temptrig
        sequence:
          - action: input_number.set_value
            metadata: {}
            target:
              entity_id: input_number.heattrigger
            data:
              value: 25
      - conditions:
          - condition: trigger
            id:
              - run
          - condition: numeric_state
            entity_id: input_number.heattrigger
            above: 24
        sequence:
          - action: switch.turn_on
            metadata: {}
            target:
              entity_id: switch.0x4c97a1fffeef9146_valve_1
            data: {}
      - conditions:
          - condition: trigger
            id:
              - stoprun
        sequence:
          - action: switch.turn_off
            metadata: {}
            target:
              entity_id: switch.0x4c97a1fffeef9146_valve_1
            data: {}
mode: single

3 – A little automation to display “Put the bins out!” on my TV, when a led it still on and the lid not pushed on my afvalwijzer thingy

No code : this is too customized, interested? Mail me

Next to do .. make my cover art display using esphome.

Dual PICO UART test with CirquitPython

Test for UART serial communication for my whack-a-mole game

CODE for Client

import board
import busio
import time

uart = busio.UART(
    tx=board.GP16,
    rx=board.GP17,
    baudrate=115200,
    timeout=1,
)

time.sleep(2)

commands = ["PING", "HELLO", "TEST"]
while True:
    for cmd in commands:
        print("Sending:", cmd)
        uart.write((cmd + "\n").encode())

        response = uart.readline()

        if response:
            print("Response:", response.decode().strip())
        else:
            print("No response")

        time.sleep(1)

CODE for server

import board
import busio
import digitalio
import time

# UART pins
uart = busio.UART(
    tx=board.GP0,
    rx=board.GP1,
    baudrate=115200,
    timeout=0.1
)

# Onboard LED
led = digitalio.DigitalInOut(board.LED)
led.direction = digitalio.Direction.OUTPUT

print("UART LED server ready")

while True:
    data = uart.readline()

    if data:
        command = data.decode("utf-8").strip()
        print("Received:", command)

        if command == "PING":
            # Blink LED
            led.value = True
            time.sleep(0.2)
            led.value = False

            # Reply
            uart.write(b"PONG\n")

        else:
            uart.write(b"UNKNOWN\n")

    time.sleep(0.01)

New CO2 sensor

Today I got, amongst other goodies a new CO2 sensor in the mail.

This is a MH-Z19C CO2/Temperature sensor.
(Easy to implement with ESPHome)

Calibrate using HD 7 seconds to GND
(Do this in a well ventilated room)

YAML Code

# Board: Wemos D1 Mini (ESP8266) (Wemos)
# Definition: definitions/boards/d1_mini/manifest.yaml

esphome:
  name: newco2
  friendly_name: NewCO2

esp8266:
  board: d1_mini

logger:

api:
  encryption:
    key: "c/vSFcxi1YgYlXtvsjXXXXXXXXXXXXXXXXXXXXXX="

ota:
  - platform: esphome

wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password
  ap:
    ssid: NewCO2 Fallback Hotspot
    password: "tepe9XXXXXXXXXXX"

captive_portal:

uart:
  - baud_rate: 9600
    rx_pin: 4
    tx_pin: 5
    id: uart_1

sensor:
  - platform: mhz19
    uart_id: uart_1
    co2:
      id: sensor_mhz19_1_co2
      name: CO2
    temperature:
      id: sensor_mhz19_1_temperature
      name: Temperature
    id: sensor_mhz19_1
    automatic_baseline_calibration: true
    detection_range: "5000ppm"
    
switch:
  - platform: template
    name: "MH-Z19 ABC"
    optimistic: true
    on_turn_on:
      mhz19.abc_enable: sensor_mhz19_1
    on_turn_off:
      mhz19.abc_disable: sensor_mhz19_1

light:
  - platform: status_led
    name: status
    id: light_status_led_1
    pin: GPIO12

This week, a lot of networking and Home Automation fixing

(Sorry except for a mikrotik script, not much details)

  • Installed a new Home Assistant instance for testing on my Proxmox
  • Moved all dhcp/dns to my main Mikrotik, second backup in progress
  • Decommissioned an old trunked switch (lot of work)
  • Decommissioned an old router/firewall server (10+ years old)
  • Redraw my network in DrawIO
  • Installed Homelable to scan and draw my network (see below)

Meanwhile I am looking for a new welder.
Also doing some woodwork. (bird feeder stand)

Bird feeder pole (has a brownish tint now)

This is a cool project (Homelable). Below a still incomplete network.

Some code below to generate a CSV for DNS/DHCP entries from a Mikrotik.
(NOTE: seems spaces in comments/name/entries break stuff)

ssh admin@10.x.x.x "/ip/dns/static;export" | grep 10.1.0 | awk '{
    addr=""; comment="" ; name=""
    for(i=1;i<=NF;i++) {
        if($i ~ /^address=/) addr=$i
        if($i ~ /^comment=/) comment=$i
        if($i ~ /^name=/) name=$i
    }
    if(addr && name) print addr, name, comment
}' > dnsstatic.out

ssh admin@10.x.x.x "/ip/dhcp-server/lease;export terse" | awk '{
    addr=""; comment=""
    for(i=1;i<=NF;i++) {
        if($i ~ /^address=/) addr=$i
        if($i ~ /^comment=/) comment=$i
    }
    if(addr && comment) print addr, comment
}' > dhcpstatic.out

for f in $(seq 1 254) ; do lease=$(grep "10.1.0.$f " dhcpstatic.out | cut -f3 -d=) ; dns=$(grep "10.1.0.$f " dnsstatic.out | cut -f2,3 -d" " |sed s/name=//g | s
ed s/comment=//g | sed s/\ /,/g | head -1) ; echo -n 10.1.0.$f, ; echo -n $lease ; echo -n "," ; echo $dns  ;done > ips.csv

Meanwhile filling my own hosted “Spotify” clone, but better. (Navidrome)
(My immich server is also ingesting while we speak.)

Navidrome

Smoke detector (ShellySmoke) notification Home Assistant with friendly-names

Quick ‘n simple post, so I won’t forget.

Multiple triggers in one Automation, use friendly_name to distinguish entities that triggered the notification.

Message send example “Smoke detected ShellySmokeKitchen”

alias: Smoke detected
description: ""
triggers:
  - type: smoke
    device_id: bbd0c2ebb949b38a28c6ecca67fb4ebe
    entity_id: 888d20ea2075873284708125491695b5
    domain: binary_sensor
    trigger: device
  - type: smoke
    device_id: 31bda70d60fc815681fe951469e11a0a
    entity_id: 3a9538b025f7d263b5e145d6f4dda859
    domain: binary_sensor
    trigger: device
  - type: smoke
    device_id: 1a33c981b1dfca13202b5efe0237fea1
    entity_id: 6bf59d8de54a7bdef0bab7daf483221f
    domain: binary_sensor
    trigger: device
  - type: smoke
    device_id: 0496d720c844a5648d8b3789b8f4d093
    entity_id: e635593a29dc9af3977224b54bf19140
    domain: binary_sensor
    trigger: device
conditions: []
actions:
  - action: notify.pushover
    metadata: {}
    data:
      message: Smoke detected  "{{ state_attr(trigger.entity_id, 'friendly_name') }}"
      data:
        priority: 2
        sound: siren
        expire: 300
        retry: 30
mode: single

Software i use(d)

My much used set of tools (old draft I edited)

File managers

  • Midnight Commander
  • Thunar
  • Nautilus
  • nnn
  • Dolphin

Generic tools

  • rsync
  • dcfldd – an enhanced version of dd
  • screen/tmux
  • fdupes
  • ghex / xxd

Connecting/networking tools

  • mosh – roaming, faster, using ssh
  • sshfs – mount remote filesystems over ssh (see ssh tricks)
  • wavemon – wifi info
  • GNS3 – Graphical Network Simulator-3
  • Wireshark
  • PHPIpam
  • Homelable

Encryption

  • Luks
  • ecryptfs

Graphical/Photo

  • Gimp
  • Eog
  • rawtherapee
  • Inkscape
  • Darktable
  • PureRef
  • digiKam
  • Krita
  • Hugin
  • ImageMagick

Documents/Notekeeping

  • Vim
  • Joplin
  • Paperless-ngx
  • DrawIO – For network drawings
  • LibreOffice/OnlyOffice -> EuroOffice
  • Scribus

3D Print/Lasercutting

  • Cura
  • Orcaslicer
  • Bambuddy
  • LightBurn
  • Model editors: Blender and OpenScad, Meshroom, Sketchup

Coding

  • Mostly CLI
  • PlatformIO
  • Arduino IDE
  • VSCodium (stripped Visual Studio)

Electronics

  • Fritzing
  • Kicad
  • Logic

Ebook / Comic readers

  • Calibre
  • FBReader

GFX/Video

  • Blender
  • kdenlive
  • OBS Studio
  • Shotwell
  • Handbrake
  • ffmpeg
  • VLC
  • Kodi/Libreelec

Music

  • CLI abc tools
  • Musescore
  • Bagpipe Music Player
  • Audacity (after removing all bad things be-ing added in 2021)
  • LMMS
  • Ardour

Virtualisation/Emulation

  • proxmox
  • libvirt
  • ovirt
  • guestfish
  • dosbox
  • pcem
  • Martypc

Password management

  • Keepass / KeepassXC

API

  • Postman
  • Flask (Python) see ledserver

Beamer

  • Mapmap
  • LPMT
  • Qprompt

Brewing

  • Brouwhulp
  • Brewfather (web)

Web/App alternatives for bad companies (Mostly own hosted)

  • Gmail – Hosted elsewhere – Thunderbird + web
  • Google Drive – Nextcloud
  • Spotify – Navidrome
  • Google Photos (I never used this, i used Gallery2/3/Wipigo ) – Immich
  • Youtube – Jellyfin for own movies
  • Whatsapp/Google Chat – My own mattermost server, signal and IRC
  • Teams – Ownhosted jitsi
  • Teamviewer – Rustdesk
  • Google Timeline – Dawarich

Server generic

  • Databases : mariadb/mongodb/influxdb/sqlite
  • Grafana
  • NodeRed
  • gitea
  • HomeAssistant
  • Bookstack
  • Librenms
  • Check_mk (i’ve started with Netsaint (1999), Nagios,Icinga,
  • Mosquitto

Unsorted stuff

  • vimperator (old)
  • links/curl/dsniff/urlsnarf
  • Databases (mariadb/mongodb/influxdb/sqlite)
  • Metabase
  • Adminder
  • Scrot (snapshot tool)
  • Luminace-hdr
  • GDlib
  • Dia (old)
  • Blackmagic Fusion
  • gcalcli
  • Gcalcron
  • Domoticz
  • MQTT-Explorer
  • Android studio
  • Nextion IDE
  • Irssi
  • Mutt
  • Mailcow
  • Tinymediamanager
  • Cacti (old)
  • Winbox (Mikrotik)
  • iptraf
  • ntopng
  • Twiki/Foswiki (old)
  • Digikam
  • My own photo manager
  • Cewe Photobooks
  • qdlsrdashboard
  • gphoto2
  • Ktechlab
  • Ardour5
  • Puredata
  • Cadence
  • Natron
  • yt-downloader
  • 4k downloader
  • Taggers
  • Mp3tag
  • Tinymediamanager
  • MusicBrainz Picard
  • Beets
  • Music players
  • MOC
  • SoftSqueeze
  • Clementine
  • My Badly Designed Sound Machine
  • Server stuff
  • Namazu2
  • Netdata
  • Ntopng
  • Snort/Snortsam
  • Virtualisation

Window managers (See other post)

  • Xmonad (current)
  • Gnome (current)
  • Enlightenment (old)
  • Compiz (old)
  • Fluxbox (old)
  • Ratpoison (tried)
  • Twm (tried)
  • Xfce (old)
  • Window Maker(old)
  • Sawfish (old)
  • Kde (old)
  • i3 (old)
  • IceWM (old)
  • Motif (old)
  • Flwm (old)
  • Fvwm (old)
  • Ximian desktop (bought) (old)

  • Home Drawing
    • Sweethome3D
    • Blender
    • Sketchup
    • Drawio
  • Old but cool
    • Mainactor
    • Appleshake
    • Zbruch
    • Povray
    • Lightzone

Other tools:

Git, tig, xdotool, nmon, ntop, iotop, etc etc (lijstje genereren)

Nintendo Switch controller fix, and Lora measurements

One moment playing with LoRa. Next, a Nintendo Switch controller to fixed.

Side buttons or whatever you call them didn’t work anymore, so I replaced the flex PCB.

LoRa Antenna measurements

Using my NanoVNA and a RF test Kit I learned something about measuring antenna.

Below a measurement of a unknown antenna, ITs off, I need to shorten the metal spring inside.

Raspberry Pi 5 Projects

Again … out of SBCs
Where are all these things in my home. Someone is stealing Raspberry Pi’s, ESP32 and other sensors.
(Probably me)

So I’ve got multiple projects running on one RPi.

  • Dual Camera’s on top (brown ribbons), these are for VR streaming project.
  • Dual Camera’s on top. these are for a Red Light Green Light game. (Using motion detection on both camera’s for two players.
  • Below a INMP441 Mems microhone. This is a test for BirdNet recording.

All of the above are partially working. Code follows.

INMP441 is a tricky thing. I needed to do some bitbanging to get it working.

Loads of INMP441 info will be posted

Mqtt blinker for topic notifications

Last year I’ve made a led pole with digital fireworks.

Time to replace for something else ..

I’ve made a mqtt 1-D game in december.

I needed to change a lot to the javascript on the website to fix some stuff.

  • Fix IPhone control. (I hate iphone)
  • Fix screenlock timeout
  • Added meta refresh

The XMAS/Fireworks controller was often used, and I got notifications via my TV. (see other posts)

Now I want to see when MQTT movement when I’m in the livingroom.
So I programmed a Wemos controller to blink the internal when MQTT messages are received.

CODE:

#include <ESP8266WiFi.h>
#include <PubSubClient.h>

const char* ssid = "WIFIAP";
const char* password = "WIFIPASS";

const char* mqtt_server = "MQTTBROKER";  // MQTT broker IP
const char* mqtt_topic  = "game/tilt";

WiFiClient espClient;
PubSubClient client(espClient);

String lastPayload = "";

void setup_wifi() {
  delay(10);
  WiFi.begin(ssid, password);
  while (WiFi.status() != WL_CONNECTED) {
    delay(500);
  }
}

void blinkLED() {
    digitalWrite(LED_BUILTIN, LOW);   // LED ON
    delay(200);
    digitalWrite(LED_BUILTIN, HIGH);  // LED OFF
    delay(200);
}

void callback(char* topic, byte* payload, unsigned int length) {
  String message;
  for (unsigned int i = 0; i < length; i++) {
    message += (char)payload[i];
  }

  // Blink only if topic value changed
  if (message != lastPayload) {
    blinkLED();
    lastPayload = message;
  }
}

void reconnect() {
  while (!client.connected()) {
    if (client.connect("WemosClientMqttBlink")) {
      client.subscribe(mqtt_topic);
    } else {
      delay(2000);
    }
  }
}

void setup() {
  pinMode(LED_BUILTIN, OUTPUT);
  digitalWrite(LED_BUILTIN, HIGH); 

  setup_wifi();

  client.setServer(mqtt_server, 1883);
  client.setCallback(callback);
}

void loop() {
  if (!client.connected()) {
    reconnect();
  }
  client.loop();
}