豪爵机战sf『瀚思彼岸』» 智能家居技术论坛

本帖最后由 hamlesme 于 2024-1-30 19:07 编辑

最近想更新下我几个dc1的esphome固件, 发现新版esphome编译过不了,看了下新版变化太多,加上platformio的更新, 即使用旧的esphome1.14也不能正常编译了.
看了下esphome现在的components里有另一个类似io芯片的代码, pca9554, 比较了cat9554和pca9554的datasheet, 都一样, 所以对照esphome pca9554页面改下yaml就行了.
要改的就是把cat9554全部替换成pca9554, 然后把#irq_pin: GPIO4注释掉就能编译了.
默认情况下的wifi led不能控制了, 看了下esphome文档,用status_led platform代替status_led component就可以,附件就不修改了, 帖子里代码修改过了.
wifi led之前是要inverted,之前没注意.yaml已改.


用几天后,发现有时候会出现dc1半死机状态, 需要断电后才正常,大家慎用,当然在yaml里加上如下代码也是可以实现定时重启的.

time: - platform: homeassistant on_time: - seconds: 0 minutes: 0 hours: 2 days_of_week: MON-SUN then: - switch.toggle: restart_switch switch: - platform: restart name: "Auto Restart" id: restart_switch

复制代码




测试正常使用.完整的yaml如下.

esphome: name: $device_name platform: ESP8266 board: esp01_1m esp8266_restore_from_flash: yes #---------------------------------------------------- build_path: build/$device_name #---------------------------------------------------- substitutions: config_version: 'v2019.12.26.001' device_name: dc1-api wifi_fast_connect: 'false' wifi_reboot_timeout: 0s api_reboot_timeout: 0s cse7766_update_interval: 1s wifi: ssid: !secret wifi_ssid password: !secret wifi_password domain: .local reboot_timeout: $wifi_reboot_timeout power_save_mode: none fast_connect: $wifi_fast_connect #use_address: ota.local ap: ssid: $device_name password: "1234567890" captive_portal: api: reboot_timeout: $api_reboot_timeout #---------------------------------------------------- ota: safe_mode: true password: !secret ota_password # port: 3286 web_server: port: 80 # css_url: https://esphome.io/_static/webserver-v1.min.css # js_url: https://esphome.io/_static/webserver-v1.min.js #---------------------------------------------------- i2c: sda: GPIO3 scl: GPIO12 scan: false #frequency: 20kHz pca9554: id: pca9554_hub #address: 0x20 #irq_pin: GPIO4 uart: rx_pin: GPIO13 baud_rate: 4800 #debug: logger: # NONE、ERROR、WARN、INFO、DEBUG、VERBOSE、VERY_VERBOSE level: INFO baud_rate: 0 # hardware_uart: UART1 sensor: - platform: cse7766 voltage: name: "${device_name} voltage" current: name: "${device_name} current" power: name: "${device_name} power" update_interval: $cse7766_update_interval - platform: uptime name: "${device_name} uptime" - platform: wifi_signal name: "${device_name} wifi_signal" binary_sensor: - platform: status name: "${device_name} status" internal: false - platform: gpio name: "${device_name} key1" internal: true pin: pca9554: pca9554_hub # Use pin number 0 number: 0 mode: INPUT filters: - invert: - delayed_on: 50ms - delayed_off: 50ms on_click: - min_length: 50ms max_length: 500ms then: - switch.toggle: switch1 - platform: gpio name: "${device_name} key2" internal: true pin: pca9554: pca9554_hub # Use pin number 1 number: 1 mode: INPUT filters: - invert: - delayed_on: 50ms - delayed_off: 50ms on_click: - min_length: 50ms max_length: 500ms then: - switch.toggle: switch2 - platform: gpio name: "${device_name} key3" internal: true pin: pca9554: pca9554_hub # Use pin number 2 number: 2 mode: INPUT filters: - invert: - delayed_on: 50ms - delayed_off: 50ms on_click: - min_length: 50ms max_length: 500ms then: - switch.toggle: switch3 - platform: gpio name: "${device_name} key0" id: key0 internal: true pin: number: GPIO16 mode: INPUT_PULLDOWN_16 filters: - invert: - delayed_on: 50ms - delayed_off: 50ms on_click: - min_length: 50ms max_length: 500ms then: - switch.toggle: switch0 - platform: template name: "shadow1" id: shadow1 internal: true - platform: template name: "shadow2" id: shadow2 internal: true - platform: template name: "shadow3" id: shadow3 internal: true #status_led: # pin: GPIO0 ## choose only one between light status_led platform and status_led component light: - platform: status_led name: "${device_name} wifi_light" pin: number: GPIO0 inverted: true text_sensor: - platform: template name: "${device_name} Config Version" lambda: |- return {"${config_version}"}; - platform: version name: "${device_name} esphome_version" icon: mdi:information-outline - platform: wifi_info ip_address: name: "${device_name} IP Address" ssid: name: "${device_name} Connected SSID" # bssid: # name: "${device_name} Connected BSSID" output: - platform: gpio id: realy3 setup_priority: 900 pin: pca9554: pca9554_hub # Use pin number 4 number: 4 mode: OUTPUT inverted: false - platform: gpio id: realy2 setup_priority: 900 pin: pca9554: pca9554_hub # Use pin number 5 number: 5 mode: OUTPUT inverted: false - platform: gpio id: realy1 setup_priority: 900 pin: pca9554: pca9554_hub # Use pin number 6 number: 6 mode: OUTPUT inverted: false - platform: gpio id: realy0 setup_priority: 900 pin: pca9554: pca9554_hub # Use pin number 7 number: 7 mode: OUTPUT inverted: false switch: - platform: output name: "${device_name} switch0" output: realy0 id: switch0 on_turn_on: - switch.turn_on: LOGO_light - lambda: |- if (id(shadow1).state) { id(switch1).turn_on(); id(shadow1).publish_state(false); } if (id(shadow2).state) { id(switch2).turn_on(); id(shadow2).publish_state(false); } if (id(shadow3).state) { id(switch3).turn_on(); id(shadow3).publish_state(false); } on_turn_off: - switch.turn_off: LOGO_light - lambda: |- if (id(switch1).state) { id(switch1).turn_off(); id(shadow1).publish_state(true); } if (id(switch2).state) { id(switch2).turn_off(); id(shadow2).publish_state(true); } if (id(switch3).state) { id(switch3).turn_off(); id(shadow3).publish_state(true); } - platform: output name: "${device_name} switch1" output: realy1 id: switch1 on_turn_on: - lambda: |- if (!id(switch0).state) { id(switch0).turn_on(); } - platform: output name: "${device_name} switch2" output: realy2 id: switch2 on_turn_on: - lambda: |- if (!id(switch0).state) { id(switch0).turn_on(); } - platform: output name: "${device_name} switch3" output: realy3 id: switch3 on_turn_on: - lambda: |- if (!id(switch0).state) { id(switch0).turn_on(); } - platform: gpio pin: GPIO14 name: "${device_name} LOGO_light" id: LOGO_light internal: false inverted: true

复制代码





 

 

dc1_homeassistant_api_pca9554.zip

2024-1-17 17:44 上传

点击文件名下载附件

2025-11-22 22:49 点击量:2