Home Assistant station

In order to make the daily electricity consumption for the family visible, I built a small home assistant monitor.

Since I still had an old Raspberry Pi 3 + Kuman Touch Display brought around, the idea was implemented quickly.

Most of the work on this project was the 3D printer case. I found various housings at thingiverse, but none of them were upright. I redesigned an existing project from Thingiverse for my purposes, but the picture currently only shows a prototype which I am very happy with.

Hardware required for commissioning

Required software

3D printer housing

Home Assistant 3D Print

This is my first draft of a 3D printer case based on an existing project from Thingiverse.

I’m still trying to find time to familiarize myself with OpenSCAD. At the moment I am creating new or working on existing projects with the help of Tinkercad. I am currently assuming that it will take longer to become familiar with OpenSCAD in order to design complex models.

Software setup of Raspberry Pi OS

The first steps on how to get a Raspberry Pi OS image on an SD card can be found quickly via google. I use the SD formatter to format the SD card and the BelenaEtcher program to write the image onto the SD card.

After the image has been flashed on the SD card, the standard settings in the Linux operating system are configured such as network, language, keyboard layout, etc. Then you will be asked whether the Linux system should be brought up to date.

The 5 inch display will probably already work with the Raspberry Pi 3, but without the touch screen function. The correct drivers have to be installed for this to work. Here are the steps that need to be taken in order for the touchscreen to function properly:

  1. Install Raspberry Pi OS official mirror
  2. Clone repo from GitHub to your pi
    • sudo rm -rf LCD-show
    • git clone https://github.com/goodtft/LCD-show.git
    • chmod -R 755 LCD-show
    • cd LCD-show/
  3. Step3, According to your LCD’s type, excute:
    • In case of 5″ LCD
      • sudo ./LCD5-show
    • If you need to switch back to the traditional HDMI display
      • sudo ./LCD-hdmi
  4. Wait a few minutes,the system will restart automatically, enjoy with your LCD
  5. Rotate LCD display
    • ./rotate.sh 270

Since the display is now running and rotated with the correct drivers, we can focus on the Chrome Kiosk mode. For this I found another blog that describes these steps really well and in great detail. Therefore I will save myself a new description. Here is an example code for the auto start:

# Mauszeiger Ausblenden
@unclutter

# Bildschirmschoner ausschalten
#@xscreensaver -no-splash  
@xset s off
@xset -dpms
@xset s noblank

# Startet im Vollbild und im Inkognito Modus, ohne Adressleiste und Knöpfe und ohne die Möglichkeit den Vollbildmodus mit F11 zu deaktivieren 
@chromium-browser --incognito --disable-notifications --kiosk http://homeassistant.local:8123/lovelace/0

# Oder (dementsprechend aus kommentieren) 

# Startet im Vollbildmodus, ohne Adressleiste und Knöpfe und im Inkognito Modus.
#@chromium-browser --incognito --start-fullscreen http://homeassistant.local:8123/lovelace/0


 

Software setup Home Assistant

After the repeated failure of Chrome to persistently write the login data for Home Assistant, I came across a page that says this is wanted. The only remedy is to specify the Raspberry Pi’s IP address as a trusted network under /config/configuration.yaml. Here is a code snipped of my configuration.yaml:

# Beginning of configuration.yaml
homeassistant:
  name: homeAssistant
  auth_providers:
    - type: trusted_networks
      trusted_networks:
        - 192.168.178.XX
        - 127.0.0.1
        - ::1
      allow_bypass_login: true
    - type: homeassistant

# Configure a default setup of Home Assistant
...
...

Ready to start

Now everything should start automatically after the power supply is plugged in. If this is not the case, I have probably forgotten something in my description. If so, drop me a line.

I currently have my home automation running on a Raspberry Pi 4 with Home Assistant (hassio). My idea was to control the whole thing with a voice assistant. Since you can run the Mycroft in a Docker environment, I want to do the whole setup with only one Raspberry Pi. I don’t think that the Pi’s resources are sufficient, but it’s worth a try. The first attempts with a Raspberry Pi 3 show that it has to struggle with Mycroft via docker.

Required Hardware:

  • Raspberry Pi 3/4 + standard cables
  • Micro SD card min 8 GB
  • Jack to jack cable
  • Speaker with audio jack
  • USB Microphone
  • HMI cable and Monitor for first setup

Required Software

Raspberry Pi setup

Most will know how to create a boot image on an SD card. With belena.io, the whole thing works very quickly and is actually self-explanatory. After inserting the SD card and starting Debian, you have to make the standard settings (WiFi setup, language, …).

The next step should be to enable the ssh interface under Debian (Settings -> Interface -> Activate SSH). Now you no longer need the monitor and you can continue to set up everything via the SSH terminal. An SSH terminal connection can be established with the Macbook with the following command:

sudo ssh pi@192.168.178.xx

Now we are on the Raspberry Pi and can do the first installations. The first thing you should do is bring Debian up to date with the following command:

sudo apt-get update && sudo apt-get upgrade && sudo apt-get dist-upgrade

Docker on Raspberry Pi

I stuck to this website when installing Docker. Many thanks for the clear instructions.

Get Mycroft Docker Development Environment

I tried to get the whole thing to work with the instructions on Github but failed again and again in some places. Ultimately, I found my own way that is similar to the Github guide.

Pull mycroft respository from GitHub

git clone https://github.com/MycroftAI/docker-mycroft.git

Build the docker image in the directory were you pulled the repository.

docker build -t mycroft .

Run the following command to start up mycroft:

docker run -d \
--name mycroft \
-v /home/pi/mycroft:/root/.mycroft \
-v /home/pi/mycroft_skills:/opt/mycroft/skills \
--device /dev/snd \
-e PULSE_SERVER=unix:${XDG_RUNTIME_DIR}/pulse/native \
-v ${XDG_RUNTIME_DIR}/pulse/native:${XDG_RUNTIME_DIR}/pulse/native \
-v ~/.config/pulse/cookie:/root/.config/pulse/cookie \
-p 8181:8181 \
mycroft mycroftai/docker-mycroft:latest

Check if the docker container is up and running by typing:

pi@raspberrypi:~ $ docker ps -a

If you want to remove the docker container you have to type in:

pi@raspberrypi:~ $ docker rm mycroft

Your Docker container is now set up and is just waiting to be started. With the command ” sudo systemctl enable docker “, which is described under ” Docker on Raspberry Pi “, Docker is started automatically when booting.

The best thing to do after restarting is to check whether the Docker container is already there ( docker ps -a ). The command to start mycroft Container is:

docker start [container_ID]

Enter container:

docker exec -it mycroft /bin/bash

After Mycroft is running, the device must still be connected to the MycroftAI. To do this, you first have to register at mycroft.ai. For the device connection you have to excecute the following command:

./startup.sh 

The speaker will let you know what to do ( register on mycroftAI ). A voice tell you to add the device ID. After that it will take a few moment until the terminal gui will appear.

By typing only ./start-mycroft.sh you will get an info which commands you can use. Now you can execute all the commands you want which are available, for example (simple audio test):

./start-mycroft.sh audiotest

With the command ./startup.sh cli the terminal cli will be opened like in the Picroft Image.

Mycroft CLI

Install nano to edit container file

To change a file directly in the terminal you need an Editor. In my case I will use nano. To install vi you have to paste the following commands:

apt-get update
apt-get install nano

While looking for new sensors, I came across the AZ-Envy from AZ-Delivery and was initially enthusiastic about the description of the sensor board. Of course, I ordered three of them. Anyone who has already dealt with the price issue for sensors knows that one sensor alone is quite expensive, but three or five in a pack usually only cost a few euros more. This is probably due to the fact that the free shipping costs and the processing fee which is also part of the price.

Now a few sentences about the board. I don’t understand why no data lines were added to the USB port. As a result, installing the firmware (for beginners as described so nicely in the ad) is extremely complicated. The standard ESP32 or ESP8266 can be flashed much more easily. Of course, once the first firmware is flashed, all other changes can be made via an Over The Air Update (OTA).

But what bothers me most about the board design is that the temperature sensor is right next to the heater of the gas sensor. Even if the sensor has been running for a while, the temperature sensor spits out a wide variety of values. Unfortunately, no offset helps to adjust the temperature. I haven’t compared the humidity with any other product so far, but from what I’ve read on the Internet, the Dev-Board doesn’t seem to work reliably either.

Hardware required for commissioning

Required software

3D printer housing

Download 3D-print Box

Creation of the firmware flash file

There are two ways to create the flash file. Here I am describing one of them.

  • Flash file created with ESPHome.io
  • Flash file created with HomeAssistant

Generate firmware with HomeAssistant

ESPHome HomeAssistant

Install ESPHome under HomeAssitant.

Configure and open ESPHome

Press the + button at the bottom of the page

Enter Projektnamens

Enter SSID (WLAN Name)

Enter WLAN Passworts

Press button “next”

Choose ESP8266

Press button”next”.

A congratulation logo should appear. In case of an error, simply press “next” again

The new project has been created and is not yet connected (therefore red).

Press Install and then Manual download

The firmware is compiled and then downloaded.

This file can then be installed via the terminal.

EZ-Envy-1.yaml

esphome:
  name: humidity
  platform: ESP8266
  board: nodemcuv2
  
i2c:
  - sda: GPIO4
    scl: GPIO5
    id: bus_a

sensor:
  #Temperatur und Luftfeuchtigkeit
  - platform: sht3xd
    i2c_id: bus_a
    address: 0x44
    
    temperature:
      name: "Temperatur"
      id: "temperature"
      filters:
      - offset: -10.0
    humidity:
      name: "Luftfeuchtigkeit"
      id: "humidity"
      filters:
      - offset: 8.0
    update_interval: 10s
    
  # MQ2 Smoke Gas Sensor
  - platform: adc
    pin: A0
    name: "Gassensor"
    update_interval: 10s
    #filters:
    #  - multiply: 100
        #unit_of_measurement: "%"
    filters:
     lambda: |- 
       return (x * 1024/5);
    unit_of_measurement: "ppm"  
    icon: "mdi:percent" 
    
    
# Enable logging
logger:

....
....

AZ-Envy Firmware flashing via Terminal

AZ-Envy

First you have to connect the FT232RL Flasher Board to the AZ-Envy. However, you only need three individual wires (jumper wire). Only the pins GND, RX, TX need to be connected.

Then the AZ-Envy must be supplied with voltage and the FT232RL USB cable is then connected to the PC. You can also connect both USB cables to a USB hub (with external power supply) and then go from there to the PC.

The following steps have to be taken:

  • Create Firmware flashfile with HomeAssistant or ESPHome.
  • Connect EZ-Envy to FT232RL
  • Connect the AZ-Envy and FT232RL to a USB hub with an external power supply
  • Connect the USB hub to the PC
  • Open Terminal and go to the ESPTool folder
  • Command: sudo python esptool.py –port / usbPort / write_flash 0x00000 yourFile.bin
sudo python esptool.py --port /dev/tty.usbserial-A50285BI write_flash 0x00000 ez-envy-1.bin

Bekannte Probleme beim flachen

If the device is not recognized correctly and the following output appears.

  1. Hold down the flash button on the EZ-Envy
  2. Unplug the EZ-Envy’s USB cable and plug it in again.
  3. Now the firmware should be flashed (see picture below)

My conclusion on the AZ Envy

As a development board, I think the board is really successful and it’s fun to work with. If you print out the corresponding case, the price is still reasonably reasonable. The housing also shields the temperature sensor a little from the heating of the gas sensor. Unfortunately, this does not make the temperature values more accurate either.

I will now use my sensor as a gas sensor in the boiler room.

Mit der Hilfe eines ESP8266 und eines einfachen IR Modules kann am Stromzähler der aktuelle Stromverbrauch ausgelesen werden ohne das man den Stromzähler PIN benötigt. Die ausgelesenen Werte können dann mittels Home Assistant HASSIO grafisch dargestellt werden.

Benötigte Hardware

Benötigte Software

Aufbau

eHz Elektronischer Haushaltszähler

eHz Digitaler Stromzähler (ESP8266)

Das Gehäuse aus dem 3D Drucker passt beim eHz Elektronischen Haushaltszähler. Mit zwei Magneten wird das Gehäuse am Zähler befestigt da der Stromzähler Eigentum des Netzbetreibers ist!

Die rechten beiden IR Dioden werden beim IR Lese-Schreibekopf verwendet (Volkszähler). Dabei wird permanent zwischen den Unterschiedlichen zur verfügung stehenden Zählerständen geschalten und diese ausgelesen (PIN muss beim jeweiligen Energiekonzern angefragt werden).

In unserem Fall benutzen wir die mittlere IR-Diode zum auslesen des aktuellen Stromverbrauchs am Zähler.

ESP Home config.yaml

esphome:
  name: strom
  platform: ESP8266
  board: nodemcuv2
  
# Sensor configuration
sensor:
  - platform: pulse_counter
    pin: D5
    name: "Energieverbrauch"
    unit_of_measurement: 'W'
    update_interval: 60s
    filters:
      - multiply: 6
    accuracy_decimals: 0
    icon: 'mdi:flash'
    id: energieverbrauch_w
    
  - platform: total_daily_energy
     name: "Tagesverbrauch"
     power_id: energieverbrauch_w

time:
  - platform: sntp
    id: my_time

# Enable logging
logger:

# Enable Home Assistant API
api:

ota:
  password: „xxxxxxxxxx“

wifi:
  ssid: „xxxxxxxxxx“
  password: „xxxxxxxxxx“

captive_portal:

Home Assistant grafische Darstellung

ESP Home Logs

INFO Reading configuration /config/esphome/strom.yaml...
INFO Detected timezone 'CET' with UTC offset 1 and daylight saving time from 27 March 02:00:00 to 30 October 03:00:00
INFO Starting log output from strom.local using esphome API
INFO Successfully connected to strom.local
[19:32:31][I][app:102]: ESPHome version 2021.9.3 compiled on Oct 10 2021, 21:35:03
[19:32:31][C][wifi:501]: WiFi:
[19:32:31][C][wifi:361]:   SSID: 'xxxxxxxxxxxxxxx'[redacted]
[19:32:31][C][wifi:362]:   IP Address: xxx.xxx.xxx.xx
[19:32:31][C][wifi:364]:   BSSID: xx:xx:xx:xx:xx:xx[redacted]
[19:32:31][C][wifi:365]:   Hostname: 'strom'
[19:32:31][C][wifi:369]:   Signal strength: -51 dB ▂▄▆█
[19:32:31][C][wifi:373]:   Channel: 6
[19:32:31][C][wifi:374]:   Subnet: 255.255.255.0
[19:32:31][C][wifi:375]:   Gateway: xxx.xxx.xxx.x
[19:32:31][C][wifi:376]:   DNS1: xxx.xxx.xxx.x
[19:32:31][C][wifi:377]:   DNS2: (IP unset)
[19:32:31][C][logger:193]: Logger:
[19:32:31][C][logger:194]:   Level: DEBUG
[19:32:31][C][logger:195]:   Log Baud Rate: 115200
[19:32:31][C][logger:196]:   Hardware UART: UART0
[19:32:31][C][pulse_counter:147]: Pulse Counter 'Energieverbrauch'
[19:32:31][C][pulse_counter:147]:   State Class: 'measurement'
[19:32:31][C][pulse_counter:147]:   Unit of Measurement: 'W'
[19:32:31][C][pulse_counter:147]:   Accuracy Decimals: 0
[19:32:31][C][pulse_counter:147]:   Icon: 'mdi:flash'
[19:32:31][C][pulse_counter:148]:   Pin: GPIO14 (Mode: INPUT)
[19:32:31][C][pulse_counter:149]:   Rising Edge: INCREMENT
[19:32:31][C][pulse_counter:150]:   Falling Edge: DISABLE
[19:32:31][C][pulse_counter:151]:   Filtering pulses shorter than 13 µs
[19:32:31][C][pulse_counter:152]:   Update Interval: 60.0s
[19:32:31][C][total_daily_energy:024]: Total Daily Energy 'Tagesverbrauch'
[19:32:31][C][total_daily_energy:024]:   Device Class: 'energy'
[19:32:31][C][total_daily_energy:024]:   State Class: 'total_increasing'
[19:32:31][C][total_daily_energy:024]:   Unit of Measurement: 'Wh'
[19:32:31][C][total_daily_energy:024]:   Accuracy Decimals: 2
[19:32:31][C][total_daily_energy:024]:   Icon: 'mdi:flash'
[19:32:31][C][captive_portal:148]: Captive Portal:
[19:32:31][C][ota:029]: Over-The-Air Updates:
[19:32:31][C][ota:030]:   Address: strom.local:8266
[19:32:31][C][ota:032]:   Using Password.
[19:32:31][C][api:135]: API Server:
[19:32:31][C][api:136]:   Address: strom.local:6053
[19:32:31][C][api:140]:   Using noise encryption: NO
[19:32:31][C][sntp:044]: SNTP Time:
[19:32:31][C][sntp:045]:   Server 1: '0.pool.ntp.org'
[19:32:31][C][sntp:046]:   Server 2: '1.pool.ntp.org'
[19:32:31][C][sntp:047]:   Server 3: '2.pool.ntp.org'
[19:32:31][C][sntp:048]:   Timezone: 'CET-1CEST-2,M3.4.0/2,M10.5.0/3'
[19:32:32][D][pulse_counter:159]: 'Energieverbrauch': Retrieved counter: 68.00 pulses/min
[19:32:32][D][sensor:121]: 'Energieverbrauch': Sending state 408.00000 W with 0 decimals of accuracy
[19:32:32][D][sensor:121]: 'Tagesverbrauch': Sending state 6002.70361 Wh with 2 decimals of accuracy
[19:32:32][D][pulse_counter:159]: 'Energieverbrauch': Retrieved counter: 68.00 pulses/min
[19:32:32][D][sensor:121]: 'Energieverbrauch': Sending state 408.00000 W with 0 decimals of accuracy
[19:32:32][D][sensor:121]: 'Tagesverbrauch': Sending state 6002.70361 Wh with 2 decimals of accuracy
[19:33:32][D][pulse_counter:159]: 'Energieverbrauch': Retrieved counter: 67.00 pulses/min
[19:33:32][D][sensor:121]: 'Energieverbrauch': Sending state 402.00000 W with 0 decimals of accuracy
[19:33:32][D][sensor:121]: 'Tagesverbrauch': Sending state 6009.40381 Wh with 2 decimals of accuracy
[19:34:32][D][pulse_counter:159]: 'Energieverbrauch': Retrieved counter: 68.00 pulses/min
[19:34:32][D][sensor:121]: 'Energieverbrauch': Sending state 408.00000 W with 0 decimals of accuracy
[19:34:32][D][sensor:121]: 'Tagesverbrauch': Sending state 6016.20361 Wh with 2 decimals of accuracy
[19:35:32][D][pulse_counter:159]: 'Energieverbrauch': Retrieved counter: 70.00 pulses/min
[19:35:32][D][sensor:121]: 'Energieverbrauch': Sending state 420.00000 W with 0 decimals of accuracy
[19:35:32][D][sensor:121]: 'Tagesverbrauch': Sending state 6023.20361 Wh with 2 decimals of accuracy
[19:36:32][D][pulse_counter:159]: 'Energieverbrauch': Retrieved counter: 75.00 pulses/min
[19:36:32][D][sensor:121]: 'Energieverbrauch': Sending state 450.00000 W with 0 decimals of accuracy
[19:36:32][D][sensor:121]: 'Tagesverbrauch': Sending state 6030.70459 Wh with 2 decimals of accuracy
[19:37:32][D][pulse_counter:159]: 'Energieverbrauch': Retrieved counter: 70.00 pulses/min
[19:37:32][D][sensor:121]: 'Energieverbrauch': Sending state 420.00000 W with 0 decimals of accuracy
[19:37:32][D][sensor:121]: 'Tagesverbrauch': Sending state 6037.70361 Wh with 2 decimals of accuracy

Mycroft / PiCroft is an open source voice assistant.

Hardware required

  • Raspberry Pi
  • Display (in my case 5″Display)
  • JBL GO Bluetooth Speaker
  • Keyboard for setup

PiCroft first setup

PiCroft Setup

Connect JBL Go Bluetooth speaker

Install Pulseaudio-module-bluetooth

sudo apt-get install pulseaudio-module-bluetooth

Setup for setting bluetooth connection every startup at: /sudo nano /etc/rc.local

# Connect Bluetooth Speaker JBL Go
printf "### Connect Bluetooth Speaker ###"
echo "power on \nagent on \ndefault-agent \nconnect XX:XX:XX:XX:XX:XX \nquit" | bluetoothctl

This file needs to be edited at to get audio output: sudo nano /etc/mycroft/mycroft.conf

{
  "play_wav_cmdline": "aplay %1",
  "play_mp3_cmdline": "mpg123 %1",
  [...]
}

Short description

SodaStream Oled Display

Everyone who owns a SodaStream has probably asked themselves how full my CO2 cylinder is. In most cases the cylinder is empty once you have been shopping. Most SodaStream users have a second cylinder, but it still sparked my creativity to come up with a simple solution.

The small software program is currently used to determine the number of impacts pressed and shown on the display (line 2). In line 3 is the added time of the duration / length of the pushed pushes. These values can be used to roughly estimate how much Co2 is still in the cylinder. What is shown graphically in line 4 by means of a progress indicator.

Hardware required

  • Wemos D1 mini (ESP8266)
  • Limit switch Ender 3 Pro
  • OLED Display I2C 0,96 Zoll
  • Cable / single wires
  • 3D Printer + Filament
  • Soldering iron with equipment

Software required

  • Arduino IDE
  • Tinkercad
  • Ultimaker Cura / Prusa Slicer

3D Printer settings

Ender 3 Pro

Print Settings

3D Printer Tinkercad STL File

Tinkercad SodaStream

Arduino IDE Software Code

I have to adapt to publish (currently code excerpt).

#include <SPI.h>
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#include <ESP8266WiFi.h>

#define SCREEN_WIDTH 128 // display width, (pixels)
#define SCREEN_HEIGHT 64 // display height, (pixels)

// I2C connected display SSD1306 
#define OLED_RESET     0 // Reset pin # (or -1 if sharing Arduino reset pin)
Adafruit_SSD1306 display(SCREEN_WIDTH, SCREEN_HEIGHT, &Wire, OLED_RESET);

#define NUMFLAKES     10 // Number of snowflakes in the animation example

#define LOGO_HEIGHT   16
#define LOGO_WIDTH    16
static const unsigned char PROGMEM logo_bmp[] =
{ B00000000, B11000000,
  B00000001, B11000000,
  B00000001, B11000000,
  B00000011, B11100000,
  B11110011, B11100000,
  B11111110, B11111000,
  B01111110, B11111111,
  B00110011, B10011111,
  B00011111, B11111100,
  B00001101, B01110000,
  B00011011, B10100000,
  B00111111, B11100000,
  B00111111, B11110000,
  B01111100, B11110000,
  B01110000, B01110000,
  B00000000, B00110000 };

Result Pictures

ToDo

  • Wemos D1 Mini ESP.deepSleep
  • One Case for alle the stuff
  • Smaler Display Case
  • Battery shield + display battery status
  • Change Wemos D1 Mini to ESP8266 BLE + IOS App

Control of a relay module using an Arduino Nano v3

Since I have to reset my work hardware or switch the voltage several times a day from home office, I built a small circuit from an old Arduino Nano v3 and a relay module that enables me to do this. Since I found it awkward to start the relay every time via the Arduino IDE with the serial monitor, I also wrote a GUI that can be executed using JAVA JDK for easy handling.

Hardware required

  • Arduino Nano v3
  • Relais Modul
  • RGB LED (not needed)
  • Single Wires
  • Solder stuff
  • 3D Printed case (not needed)

Schematics

Tinkercad circuits Arduino Nano

Code

Code for Arduino IDE which worked with the attached GUI.

#define LEDR 8     // red
#define LEDG 9     // green
#define LEDB 10    // blue
#define RELAIS 11  // relais

void setup() {

  // set LED's pin to output mode
  pinMode(LEDR, OUTPUT);
  pinMode(LEDG, OUTPUT);
  pinMode(LEDB, OUTPUT);
  pinMode(RELAIS, OUTPUT);
  
  Serial.begin(9600);          //start serial communication @9600 bps
}

void loop(){
  
  if(Serial.available()){      //id data is available to read

    char val = Serial.read();

    if(val == 'b'){             //if b received
      digitalWrite(11, HIGH);   //turn on relais
      digitalWrite(10, HIGH);   //turn on green led
    }
    if(val == 'f'){            //if f received
      digitalWrite(11, LOW);    //turn off all led
      digitalWrite(10, LOW);
    }      
  }
}

Processing IDE GUI for MacOS

With Processing IDE it is easy to create a JAVA GUI for Arduino which is running on MAC OS X and Windows. The only think what you have to install additional is the latest JAVA SDK.

3D Printer Settings

Print Settings

Result

Home Assistant Einstellungen zum senden einer Telegram Nachricht durch drücken des Ikea Shortcut Knopfes

Mit der IKEA Tradfri Serie hat es das schwedische Unternehmen in den Smart Home-Markt geschafft. Damit ist es für jedermann auf einfachste Weise möglich Lampen, Steckdose, Rollos oder Lautsprecher via App zu steuern oder sogar zu automatisieren. Laut Ikea ist die aktuellen Serie auch noch nicht am Ende seiner Entwicklung und wird stetig weiterentwickelt. Das Home Smart System soll im kommenden Jahr noch durch weitere Produkte ergänzt werden.

Was benötige ich alles für den Shortcut Button Telegram Alarm

Raspberry Pi einrichten

Wie man die SD Karte mit dem Home Assistant Operating System flashed findet man hier.
Nachdem die SD Karte geflashed, eingesteckt und der Raspberry Pi angeschaltet ist sollte die Weboberfläche des Home Assistant nach wenigen Minuten erreichbar sein. Das Einrichten und eine kurze Einleitung ist hier zu finden.

IKEA TRÅDFRI und Shortcut-Button einrichten

Das einrichten des IKEA Gateways und Shortcut-Buttons findet man im Netz und auf der Ikea Homepage zu genüge dadurch werde ich nicht genauer darauf eingehen. Falls Nachfragen bestehen dann einfach in die Kommentare schreiben.

Einrichten von Telegram unter Home Assistant

Um den Telegram Messenger in den Home Assistant einzubinden muss ein File auf dem Raspberry Pi angepasst werden. Das Anpassen des Files ist deutlich einfacher wenn man das Add-On “File Editor” installiert. Anschließend muss im “/config” Ordner die “configuration.yaml” Datei angepasst werden. Nach dem Anpassen einfach Speichern drücken. Wie man an den API_KEY und die eigene Chat ID kommt findet man hier.

# Beispiel configuration.yaml für den Telegram Bot
telegram_bot:
  - platform: polling 
    api_key: INSERTKEYHERE
    allowed_chat_ids: 
      - FIRSTCHATID 
      - SECONDCHATID 

# Beispiel configuration.yaml für den zu Benachrichtigten
notify:
   - name: SE_Message
     platform: telegram
     chat_id: FIRSTCHATID

# Wenn benötigt für den zweiten zu Benachrichtigten
   - name: ME_Message
     platform: telegram
     chat_id: SECONDCHATID 

Home Assistant Automatisierung

Unter Einstellungen -> Automatisierungen kann mittels “+ Automatisierung hinzufügen” eine neue Automation hinzugefügt werden. Einfach auf “Erstellen” und beim nächsten Fenster auf “Überspringen” drücken. Die einstellungen die ich Vorgenommen habe sind auf den nachfolgenden Bildern am besten zu sehen.

IKEA TRÅDFRI Setup
IKEA TRÅDFRI Setup
IKEA TRÅDFRI Setup

Jetzt nur noch speichern und nach dem drücken sollten die ersten Nachrichten aufm dem Handy eintreffen.

Nachträglich eine Anleitung zu schreiben ist immer schwer weil man meistens doch noch etwas vergisst zu notieren. Im falle von Fehlenden Informationen einfach eine Nachricht schreiben, ich versuche sie dann so schnell es geht zu beantworten. Vielleicht finde ich noch eine Möglichkeit einer Home Assistant Widget Darstellung via Scriptable.

WordPress as a data source with .json for Scriptable IOS App

Creating a WordPress site is no longer a specialty with the provided themes. The idea of using WordPress not only as a standard website, but also as a data source / database can be implemented by using a two-line PHP script. We need this script to upload a .json file in WP under media which is normally blocked.

<?php
function cc_mime_types($mimes) {
    $mimes['json'] = 'application/json';
    $mimes['svg'] = 'image/svg+xml';

    return $mimes;
}
add_filter('upload_mimes', 'cc_mime_types');

https://github.com/SmonSE/englishForIT/blob/main/wpJson.zip

Installation of your own WordPress plugin

After creating the plugin (ZIP file which includes the php script) it can be installed via the dashboard.

  1. First click on > Plugins > Add new.
  2. Then click on the “Upload plugin” button at the top.
  3. Now select the ZIP file and confirm the “Install now” button.
  4. After the file has been uploaded, you can activate the plugin.

Create your own .json file

Code excerpt from the json file.

// example
{
  "englishIt": "Vocabulary for IT english",
  "createdAt":"2021-03-18 11:43:00.000000",
  "vocabulary":[
    {
      "pos:": "000",
      "english": "Avatar",
      "german": "Benutzerbild",
      "meaning": "An icon or figure that represents .... ."
    },
    {
      "pos:": "001",
      "english": "Bug",
      "german": "Fehler",
      "meaning": "A defect or fault in a program ... ."
    }
  ]
}

Get data source by Scriptable Widget

Collecting data source from .json file which is uploaded on WordPress media.

// example
async function getNewCasesData(){
  let url = "https://../../../englishForItVocs.json";
  let req = new Request(url);
  let apiResult = await req.loadJSON();

return apiResult;
}

Read out values from .json file.

// example
async function createWidget() {
  const list = new ListWidget();
  const vocEng = list.addText(apiData.vocs[0].english);
  const meaning = list.addText(apiData.vocs[0].meaning);

return list;
}

Funny things that I wrote directly on the iPhone while waiting for ….

Some play games on their mobile phones in the waiting room, others read magazines. I discovered this great Widget IOS app called Scriptable for myself to bridge my boredom while waiting.

Although JacaScript is not my usual programming language, you get used to it quickly. This is of course also due to the fact that at the beginning you can always copy and paste a lot from other developers. But some parts of my code are also completely rewritten.

Strava – Last Ride – Current Month

With the scriptable widget, the last Stava training data can be called up as well as an overview of the last month. A nice feature is scrolling through friends’ training sessions like in the short video. All you have to do is set up several Strava widgets and slide them on top of each other. To get more Informations about that nice Scriptable Widget, check my blog entry about Strava Scriptable Widget. A similar Widget I have also created for Komoot.

How to add the scriptable code to your phone, check the end of this page 🙂

English for IT Vocabulary

Honestly, how often do we check our cell phones every day to check the news or other things. Many even unlock their cell phones every minute out of boredom. Why shouldn’t you learn something from it?
With the Scriptable widget, vocabulary from the IT area is displayed at a predetermined time interval.

Source Code can be downloaded here:
https://github.com/SmonSE/englishForIT

Chuck Norris Facts

At the beginning I looked for free Json Api’s with the following result: chucknorris.io is a free JSON API for hand curated Chuck Norris facts.

Chuck Norris Widget

Source Code can be downloaded here:
https://github.com/SmonSE/chucknorris.io

WordPress Latest Blog Post

Do you not feel like opening the page of your favorite blog every day to see if there is a new article. Then you can simply configure the wordpress blog script as a widget on your iPhone.

Source Code can be downloaded here:
https://github.com/SmonSE/IOS-Widget_load_JSON

How to add scriptable widget to the home screen

Regardless of which widget you have chosen, the setting procedure in iOS is always the same:

  1. First, add the copied code to a new script.
  2. With a tip on the controller icon at the very bottom in the left corner of the screen, you can give the script a meaningful name and select a suitable icon (glyph) for it.
  3. After that, switch to the widget screen by scrolling left on your home screens as long as possible.
  4. Tap and hold on this screen until the preset widgets start to wobble. You are now in edit mode. In this mode, tap on the plus sign in the upper left corner and scroll down to „Scriptable“ in the list that appears.
  5. Here you can still select the appearance and add the widget.
  6. Tap the Scriptable widget again while the icons are wobbling. Here you have the opportunity to select the appropriate script.
  7. To do this, tap on „Select“ in the „Script“ line, the app will show you all the scripts that have been created so far, which can now be selected. Then drag the widget to a location on the screen of your choice and exit edit mode.