Blog

There are many articles and stories written from experiences and conveyed from various articles.

Add general JSON MQTT Sensor to Home Assistant

Add general JSON MQTT Sensor to Home Assistant

การเพิ่ม Sensor ทั่วไปที่ส่งข้อมูลผ่าน MQTT ในรูปแบบ JSON ให้ Home Assistant มองเห็นสามารถทำได้ด้วยการแก้ไข configuration.yaml

หาที่ตั้ง File configuration.yaml แล้วทำการแก้ไข

JSON attributes template configuration

  • Device msg.payload is
    • elec2rak/devices020 = {"voltage":220.20,"current":5.02,"power":925.20,"energy":3013.92,"frequency":50.00,"PF":0.84}
  • Code ที่เพิ่มเข้าไปใน configuration.yaml

# Example configuration.yaml entry
mqtt:
  sensor:
    - name: "SBBR_Temperature"
      state_topic: "elec2rak/devices001"
     # suggested_display_precision: 1
      unit_of_measurement: "°C"
      value_template: "{{ value_json.temperature }}"
    - name: "SBBR_Humidity"
      state_topic: "elec2rak/devices001"
      unit_of_measurement: "%"
      value_template: "{{ value_json.humidity }}"

ทำการ Check and Restart Configuration จากนั้นจึงเข้าไปตรวจสอบ Sensor ที่เพิ่มเข้าไปใหม่ใน Entities List ของ Home Assistant

เราสามารถตั้งให้  Home Assistant ตรวจหา Sensor แบบอัตโนมัติได้โดยกำหนด Topic ในการส่งเป็น homeassistant ถ้า Template ถูกต้อง ระบบก็จะนำไปแสดงใน Entities ให้เห็นเลย

14/3051 M14 Bangbuathong, Bangbuathong, Nonthaburi,Thailand 11110

Phone: +669 4004 5061
Line ID: elec2rak

Upcoming articles

  • เปิด Time-line การไล่ล่าตัวคนร้าย ก่อเหตุยิงพนักงานร้าน Cococraft สาขาพิมลราช
  • Articles View Hits 38575
  • Web Links 10

We have 131 guests and no members online