สำหรับวิธีการ integration อุปกรณ์ Sonoff เข้าระบบ Home Assistant สามารถทำได้หลายวิธี แต่วันนี้ผมจะมาแนะนำ Add-on: Sonoff LAN เหตุผลที่เลือกตัวนี้ เพราะว่าผมจะใช้ความสามารถ LAN Mode ของอุปกรณ์ Sonoff โดยไม่จำเป็นต้องผ่านระบบ Cloud
Sonoff S31 ปลั๊กไวไฟ สามารถวัดการใช้พลังงานได้
การติดตั้ง Add-on: Sonoff LAN สามารถติดตั้งได้ทาง HACS โดยเข้าไปเพิ่ม Custom repositories สามารถใช้ชื่อ Repo ข้างล่างได้เลย ตอนเพิ่มให้เลือก Category เป็น integration แล้ว restart HA
AlexxIT/SonoffLAN
เริ่มต้น Config Home Assistant
ทำการแก้ไขไฟล์ configuration.yaml
sonoff: username: !secret sonoff_username password: !secret sonoff_password
username, password สำหรับใช้งานบน APP Ewelink จากนั้นทำการ restart HA
เข้าไปที่โฟลเดอร์ config/ เราจะมองเห็นไฟล์ .sonoff.json ให้ทำการเปิดไฟล์ดังกล่าว แล้วค้นหา deviceid, devicekey
จากนั้นทำการแก้ไขไฟล์ configuration.yaml อีกครั้ง
sonoff: #username: !secret sonoff_username #password: !secret sonoff_password mode: local sensors: [power, current, voltage] devices: 10012eed24: # deviceid devicekey: xxxxxxxx-4e49-4534-a3de-xxxxxxxxxxxxxx # devicekey name: Sonoff S31 force_update: True
ทำการ comment ส่วนของ username, password ไปได้เลยครับ เมื่อไหร่เรามีอุปกรณ์เพิ่มมาใหม่ ค่อยทำการเปิด comment เพื่อ reload อุปกรณ์จาก Cloud จากนั้น restart HA
เข้าไปส่วนของ entities แล้วทำการค้นหา “sonoff_10012eed24” เราก็จะเขา switch 1 ตัว และก็มี sensor 3 ตัว