homeassistant

Home Assistant ustreamer

Video Capture AV USB card (ARKMICRO 18ec:5555) / dmesg

[141319.682908] usb 1-1.4: New USB device found, idVendor=18ec, idProduct=5555, bcdDevice= 1.00
[141319.682941] usb 1-1.4: New USB device strings: Mfr=1, Product=2, SerialNumber=0
[141319.682955] usb 1-1.4: Product: USB2.0 PC CAMERA
[141319.682966] usb 1-1.4: Manufacturer: ARKMICRO
[141319.685776] usb 1-1.4: Found UVC 1.00 device USB2.0 PC CAMERA (18ec:5555)

TODO: Fix device permissions

chmod 0666 /dev/video0
 
# cat /etc/udev/rules.d/99-camera.rules
# DEVNAME="/dev/video0",MODE="0666"

Create container
https://hub.docker.com/r/mkuf/ustreamer

docker run -d \
  --name ustreamer \
  --restart always \
  -p 8080:8080 \
  --device /dev/video0:/dev/video0 \
  mkuf/ustreamer:latest

Stream
http://ha:8080/?action=stream

Debug

Install Home Assistant on Raspberry Pi

Install Home Assistant on Raspberry Pi
https://www.home-assistant.io/installation/raspberrypi/

# Install rpi-imager
sudo apt install rpi-imager
 
# Create Homeassistant SD-Card
# Other specific-purpose OS > Home assistants and home Automation > Home Assistant OS
 
# Connect to HA
http://YOUR_HOME_ASSISTANT_IP:8123/
 
# Create Home Assistant account
 
# Install SSH plugin in Add-on-Store
http://YOUR_HOME_ASSISTANT_IP:8123/hassio/addon/core_ssh/info
 
# Open SSH Web CLI
http://YOUR_HOME_ASSISTANT_IP:8123/hassio/ingress/core_ssh
 
# get wifi data from workstation
WIFI_SSID="$(nmcli dev wifi show-password | grep SSID | cut -d' ' -f2-)" 
WIFI_PASS="$(nmcli dev wifi show-password | grep Pass | cut -d' ' -f2-)"
echo ha network update wlan0 \
  --ipv4-method auto \
  --wifi-auth wpa-psk \
  --wifi-mode infrastructure \
  --wifi-ssid \'${WIFI_SSID}\' \
  --wifi-psk \'${WIFI_PASS}\'
 
# paste output to SSH online console 
 
# debug
ha network info

Enable SSH key to hypervisor (Raspberry Pi)
https://community.home-assistant.io/t/howto-how-to-access-the-home-assistant-os-host-itself-over-ssh/263352/6

Home Assistant MQTT

Install MQTT broker (server) on Anroid
https://apkpure.com/mqtt-broker-app/server.com.mqtt/download

Create MQTT sensor
https://www.home-assistant.io/integrations/sensor.mqtt/

# ~/.homeassistant/configuration.yam
# /mnt/data/supervisor/homeassistant/configuration.yaml (on Raspery PI)
...
mqtt: !include inverter.yaml
 
# inverter.yaml
  sensor:
    - name: "Inverter AC Power"
      unique_id: "inverter_ac"
      state_topic: "inverter/HM/ch0/P_AC"
      unit_of_measurement: "W"
      device_class: "energy"
      state_class: "measurement"
    - name: "Inverter DC Power"
      unique_id: "inverter_dc"
      state_topic: "inverter/HM/ch0/P_DC"
      unit_of_measurement: "W"
      device_class: "energy"
      state_class: "measurement"
    - name: "Inverter DC Power CH1"
      unique_id: "inverter_dc_ch1"
      state_topic: "inverter/HM/ch1/P_DC"
      unit_of_measurement: "W"
      device_class: "energy"
      state_class: "measurement"
    - name: "Inverter DC Power CH2"
      unique_id: "inverter_dc_ch2"
      state_topic: "inverter/HM/ch2/P_DC"
      unit_of_measurement: "W"
      device_class: "energy"
      state_class: "measurement"
    - name: "Inverter Yield Day"
      unique_id: "inverter_yield_day"
      state_topic: "inverter/HM/ch0/YieldDay"
      unit_of_measurement: "Wh"
    - name: "Inverter Yield Total"
      unique_id: "inverter_yield_total"
      state_topic: "inverter/HM/ch0/YieldTotal"
      unit_of_measurement: "kWh"
      device_class: "energy"
      state_class: "measurement"
    - name: "Inverter Temperature"
      unique_id: "inverter_temperature"
      state_topic: "inverter/HM/ch0/Temp"
      unit_of_measurement: "°C"
      icon: "mdi:thermometer"

Install mosquitto (MQTT broker) on Raspery PI OS as docker container

Home Assistant

Install Home Assistant as Docker container
https://www.home-assistant.io/installation/linux#platform-installation

docker run -d \
  --name homeassistant \
  --privileged \
  --restart=unless-stopped \
  -e TZ=Europe/Berlin \
  -v homeassistant:/config \
  --network=host \
  ghcr.io/home-assistant/home-assistant:stable
 
# volume path
# /var/lib/docker/volumes/homeassistant

Configure
http://127.0.0.1:8123

Install HACS

sudo docker exec -it homeassistant bash
wget -O - https://get.hacs.xyz | bash -

Addons / Plugins
LocaTuya: https://github.com/rospogrigio/localtuya/

custom_zha_quirks
https://smarthomescene.com/reviews/tuya-zigbee-single-clamp-energy-meter-review/