本帖最后由 george65 于 2025-6-29 23:25 编辑
本來是用版上這位大哥的代碼
https://bbs.hassbian.com/thread-23740-1-1.html
後來esphome改版後一直無法更新
跟ChatGPT奮戰10幾次失敗
每次都是剛有苗頭就到達使用上限
然後就開始亂回答越用越糟
好在這次終於在到達使用上限前完成
分享給需要的版友使用
檔案解壓縮後放到 /config/esphome/
uart:
- id: uart_bus1
tx_pin: 1
rx_pin: 3
baud_rate: 9600
# 外部元件
external_components:
- source:
type: local
path: ./external_components
components: [tds_uart]
# 使用從外部元件加載的感測器
sensor:
- platform: tds_uart
uart_id: uart_bus1
id: tds_uart_component
tds1:
name: TDS1
icon: mdi:water-pump
unit_of_measurement: ppm
accuracy_decimals: 0
temperature1:
name: Temperature1
icon: mdi:thermometer-water
unit_of_measurement: °C
accuracy_decimals: 1
tds2:
name: TDS2
icon: mdi:air-filter
unit_of_measurement: ppm
accuracy_decimals: 0
temperature2:
name: Temperature2
icon: mdi:thermometer-water
unit_of_measurement: °C"
accuracy_decimals: 1
# 感測器更新時間
time:
- platform: homeassistant
id: ha_time
on_time:
- seconds: /10
then:
- uart.write: [0x55, 0x07, 0x05, 0x01, 0x00, 0x00, 0x00, 0x62]
- delay: 500ms
- uart.write: [0x55, 0x07, 0x05, 0x02, 0x00, 0x00, 0x00, 0x63]
external_components.rar
(1.68 KB, 下载次数: 3)
|