本章では、Station-Bat を Home Assistant に統合するための完全な手順を説明します。


CONTINUE をクリックします。
New Device Setup をクリックします。
NEXT をクリックします。
ESP32 を選択します。
SKIP をクリックしてウィザードをスキップします。
EDIT をクリックし、YAML ファイルでデバイスの機能をカスタマイズします。
以下は設定の主要部分です。対応する説明と参考リンクを併記しています。
esphome:
name: station-bat
friendly_name: station-bat
on_boot:
- priority: 600
then:
- bm8563.read_time: m5station_axp192 コンポーネントは Station-Bat に電源管理とバッテリー残量検出のサポートを提供します。external_components:
- source: github://m5stack/esphome-yaml/components
components: [m5station_axp192]
refresh: 0s i2c:
- id: i2c_bus
sda: GPIO21
scl: GPIO22 spi:
clk_pin: GPIO18
mosi_pin: GPIO23 m5station_axp192 センサーは前述の外部コンポーネントが提供するもので、バッテリー残量などの電源関連情報に使用します。sensor:
- platform: mpu6886
i2c_id: i2c_bus
accel_x:
name: "MPU6886 Accel X"
id: imu_ax
accel_y:
name: "MPU6886 Accel Y"
id: imu_ay
accel_z:
name: "MPU6886 Accel z"
id: imu_az
gyro_x:
name: "MPU6886 Gyro X"
gyro_y:
name: "MPU6886 Gyro Y"
gyro_z:
name: "MPU6886 Gyro z"
temperature:
name: "MPU6886 Temperature"
id: imu_temp
update_interval: 5s
- platform: m5station_axp192
id: pmu
i2c_id: i2c_bus
battery_level:
name: "M5Station Battery Level"
id: bat_level
update_interval: 60s
brightness: 0.8
- platform: ina3221
id: ina1
i2c_id: i2c_bus
address: 0x40
update_interval: 1s
channel_1:
shunt_resistance: 0.01
bus_voltage:
name: "P.A1 Bus Voltage"
id: v_a1
current:
name: "P.A1 Current"
id: i_a1
channel_2:
shunt_resistance: 0.01
bus_voltage:
name: "P.A2 Bus Voltage"
id: v_a2
current:
name: "P.A2 Current"
id: i_a2
channel_3:
shunt_resistance: 0.01
bus_voltage:
name: "P.B1 Bus Voltage"
id: v_b1
current:
name: "P.B1 Current"
id: i_b1
- platform: ina3221
id: ina2
i2c_id: i2c_bus
address: 0x41
update_interval: 1s
channel_1:
shunt_resistance: 0.01
bus_voltage:
name: "P.B2 Bus Voltage"
id: v_b2
current:
name: "P.B2 Current"
id: i_b2
channel_2:
shunt_resistance: 0.01
bus_voltage:
name: "P.C1 Bus Voltage"
id: v_c1
current:
name: "P.C1 Current"
id: i_c1
channel_3:
shunt_resistance: 0.01
bus_voltage:
name: "P.C2 Bus Voltage"
id: v_c2
current:
name: "P.C2 Current"
id: i_c2 binary_sensor:
- platform: gpio
name: "Button1"
pin:
number: GPIO37
inverted: true
- platform: gpio
name: "Button2"
pin:
number: GPIO38
inverted: true
- platform: gpio
name: "Button3"
pin:
number: GPIO39
inverted: true switch:
- platform: template
name: "LCD Backlight"
id: lcd_backlight
lambda: |-
return true;
restore_mode: ALWAYS_ON
turn_on_action:
- lambda: |-
id(pmu).set_backlight(true);
turn_off_action:
- lambda: |-
id(pmu).set_backlight(false);
- platform: gpio
name: "USB Power"
id: usb_power
pin: GPIO12 time:
- platform: bm8563
id: bm8563_time
update_interval: never
- platform: homeassistant
id: ha_time
on_time_sync:
then:
- bm8563.write_time: light:
- platform: esp32_rmt_led_strip
rgb_order: GRB
pin: GPIO4
num_leds: 7
chipset: ws2812
name: "My Light" lambda コードブロックには具体的な描画内容を定義します。完全なサンプルは下記リンクの設定ファイルをご参照ください。display:
- platform: st7789v
model: CUSTOM
width: 135
height: 240
offset_height: 52
offset_width: 40
cs_pin: GPIO5
dc_pin: GPIO19
reset_pin: GPIO15
rotation: 90
update_interval: 1s
lambda: |-
// Define your display content here
// See the complete example for a full implementation SAVE と INSTALL をクリックし、ダイアログで Manual Download を選択して手動ダウンロードを行います。
INSTALL をクリックし、ファームウェアのコンパイルが完了するまで待ちます。
Factory format (Previously Modern) 形式を選択してダウンロードします。
CONNECT をクリックしてデバイスに接続します。

INSTALL をクリックします。

Settings → Devices & Services をクリックし、デバイスリストを確認します。
Discovered(検出済み)エリアに対応するデバイスが表示されます。CONFIGURE をクリックして追加を完了します。


