Raspberry Pi Homeassistant 接入 485通讯 电能表 搭建纪录,备忘
安装 Docker Homeassistant Esphome## 标题
sudo apt update && sudo apt install docker.io docker-compose -y
mkdir -p /home/docker/
cd /home/docker
vim docker-compose.yml
docker-compose up -d
docker-compose.yml
version: "3"
services:
homeassistant:
container_name: homeassistant
hostname: homeassistant
environment:
- LANG=C.UTF-8
- TZ=Asia/Shanghai
- PATH=/usr/local/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
image: homeassistant/home-assistant:latest
ports:
- 8123:8123/tcp
restart: unless-stopped
networks:
- host
volumes:
- /home/docker/data/HomeAssistant/config:/config:rw
- /sys/class/thermal/thermal_zone0/temp:/sys/class/thermal/thermal_zone0/temp:ro
working_dir: /config
esphome:
container_name: esphome
environment:
- USERNAME=
- PASSWORD=
- TZ=Asia/Shanghai
- LANG=C.UTF-8
- LC_ALL=C.UTF-8
hostname: esphome
image: esphome/esphome:latest
ports:
- 6052:6052/tcp
restart: unless-stopped
networks:
- host
volumes:
- /home/docker/data/esphome/config:/config:rw
- /home/docker/data/esphome/root:/root:rw
- /run/udev:/run/udev:rw
- /etc/localtime:/etc/localtime:ro
devices:
- /dev/ttyUSB0:/dev/ttyUSB0
working_dir: /config
networks:
host:
# external: true
使用 Esphome 对 esp8266 进行编程
cd /home/docker/data/esphome/config
vim ddsu666.yml
ddsu666.yml
#
#--|ADC0 |A0 |D0 |GPIO16 --#-# !-- AD0
#--|RESERVED |RSV |D1 |GPIO05 --#-#
#--|RESERVED |RSV |D2 |GPIO04 --#-#
#--|GPIO10 |SD3 |D3 |GPIO00 --#-# !运行时需保持高电平
#--|GPIO09 |SD2 |D4 |GPIO02 --#-# !--status_led 启动时不能连接低电平。
#--|MOSI |SD1 |3V3 |3V3 --#-# !
#--|CS |CMD |GND |GND --#-# !
#--|MISO |SD0 |D5 |GPIO14 --#-# -- DS118B20
#--|SCLK |CLK |D6 |GPIO12 --#-# -- Rtttl
#--|GND |GND |D7 |GPIO13 --#-#
#--|3V3 |3V3 |D8 |GPIO15 --#-# -- 运行时需保持低电平
#--|EN |EN |D9 |GPIO03 RX --#-# -- TX
#--|RST |RST |D10 |GPIO01 TX --#-# -- RX
#--|GND |GND |GND |GND --#-# !
#--|VIN |VIN |3V3 |3V3 --#-# !
#
substitutions:
device_name: ddssu666
status_led_pin: D4
uart_rx: D10
uart_tx: D9
ds118b20_pin: D5
wifi_ssid: #wifi_ssid
wifi_password: #wifi_password
rtttl_pin: D6
esphome:
name: ${
device_name}
friendly_name: ${
device_name}
platform: ESP8266
board: nodemcuv2
on_boot: # 开机提示音
then:
- rtttl.play: 'long:d=15,o=6,b=120:e,D,a,e,a,e,a,e,D,e,e'
ota:
password: ${
device_name}
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
# Enable fallback hotspot (captive portal) in case wifi connection fails
ap:
ssid: $