『瀚思彼岸』» 智能家居技术论坛

 找回密码
 立即注册
12
返回列表 发新帖
楼主: 402096806

[技术探讨] 智能电表通过rs485走modbus协议接入ha

[复制链接]

8

主题

41

帖子

269

积分

中级会员

Rank: 3Rank: 3

积分
269
金钱
228
HASS币
0
发表于 2025-2-18 15:02:51 | 显示全部楼层
本帖最后由 jimmy802 于 2025-2-18 15:07 编辑
sorrypqa 发表于 2025-2-17 12:56
好像使用这种方式接入HA,不是显示为单个设备,而是多个零散的实体,很不爽 ...

可以显示单个设备的。
modbus:
  - type: tcp
    host: 192.168.1.15
    port: 502
    name: "ddsu666"
    sensors:
      - name: "A相电压"
        address: 0x0046
        scale: 0.1
        slave: 2
        precision: 2
        unit_of_measurement: V
        data_type: int16
        unique_id: "2023062821"
        device_class: voltage
        device:
          identifiers: "yn20e_23OK72"
          name: "永诺yn20e智能电表"
          manufacturer: "永诺"
          model: "yn20e"
          serial_number: "23OK72"
      - name: "A相电流"
        address: 0x004C
        slave: 2
        precision: 2
        scale: 0.01
        unit_of_measurement: A
        data_type: int16
        unique_id: "2023062822"
        device_class: current
        device:
          identifiers: "yn20e_23OK72"
      - name: "A相有功 功率"
        address: 0x004F
        slave: 2
        precision: 2
        scale: 1
        unit_of_measurement: W
        state_class: total
        data_type: int16
        unique_id: "2023062823"
        device_class: energy
        device:
          identifiers: "yn20e_23OK72"

第一个传感器增加device信息,后面传感器使用同一个设备id, 就是同一个设备。  MQTT我是这么用的,modbus没测试过。

评分

参与人数 1金钱 +16 收起 理由
sorrypqa + 16 高手,这是高手!

查看全部评分

回复

使用道具 举报

55

主题

1441

帖子

6172

积分

论坛DIY达人

积分
6172
金钱
4731
HASS币
30
发表于 2025-2-18 17:19:21 | 显示全部楼层
jimmy802 发表于 2025-2-18 15:02
可以显示单个设备的。
第一个传感器增加device信息,后面传感器使用同一个设备id, 就是同一个设备。  MQTT ...

太好了,下次有机会试试,谢谢!
回复

使用道具 举报

2

主题

17

帖子

78

积分

注册会员

Rank: 2

积分
78
金钱
61
HASS币
0
 楼主| 发表于 4 天前 | 显示全部楼层
jimmy802 发表于 2025-2-18 15:02
可以显示单个设备的。
第一个传感器增加device信息,后面传感器使用同一个设备id, 就是同一个设备。  MQTT ...

Invalid config for 'modbus' at configuration.yaml, line 128: 'device' is an invalid option for 'modbus', check: modbus->
我试了一下不行啊
回复

使用道具 举报

8

主题

41

帖子

269

积分

中级会员

Rank: 3Rank: 3

积分
269
金钱
228
HASS币
0
发表于 3 天前 | 显示全部楼层
mqtt:
  sensor:
    - name: "NT59_1_温度"                           #    "RE59无线温度采集模块"
      state_topic: "homeassistant/sensor/RE59/1"
      value_template: "{{ value_json.temp }}"
      device_class: temperature
      unit_of_measurement: "°C"
      unique_id: "NT59_1_temperature"
      expire_after: 120
      device:
        identifiers: "IOTBOX_RE59"
        name: "RE59无线温度采集模块"
        manufacturer: "维恩电子科技"
        model: "RE59"
        serial_number: "CA26_2104"
  
    - name: "NT59_1_电池电量"
      state_topic: "homeassistant/sensor/RE59/1"
      value_template: "{{ value_json.battery }}"
      device_class: battery
      unit_of_measurement: "%"
      unique_id: "NT59_1_battery_level"
      expire_after: 120
      device:
        identifiers: "IOTBOX_RE59"
  
    # 第二组传感器 (编号 2)
    - name: "NT59_2_温度"
      state_topic: "homeassistant/sensor/RE59/2"
      value_template: "{{ value_json.temp }}"
      device_class: temperature
      unit_of_measurement: "°C"
      unique_id: "NT59_2_temperature"
      expire_after: 120
      device:
        identifiers: "IOTBOX_RE59"
  
    - name: "NT59_2_电池电量"
      state_topic: "homeassistant/sensor/RE59/2"
      value_template: "{{ value_json.battery }}"
      device_class: battery
      unit_of_measurement: "%"
      unique_id: "NT59_2_battery_level"
      expire_after: 120
      device:
        identifiers: "IOTBOX_RE59"
  
    # 第三组传感器 (编号 3)
    - name: "NT59_3_温度"
      state_topic: "homeassistant/sensor/RE59/3"
      value_template: "{{ value_json.temp }}"
      device_class: temperature
      unit_of_measurement: "°C"
      unique_id: "NT59_3_temperature"
      expire_after: 120
      device:
        identifiers: "IOTBOX_RE59"
  
    - name: "NT59_3_电池电量"
      state_topic: "homeassistant/sensor/RE59/3"
      value_template: "{{ value_json.battery }}"
      device_class: battery
      unit_of_measurement: "%"
      unique_id: "NT59_3_battery_level"
      expire_after: 120
      device:
        identifiers: "IOTBOX_RE59"
  
    # 第四组传感器 (编号 4)
    - name: "NT59_4_温度"
      state_topic: "homeassistant/sensor/RE59/4"
      value_template: "{{ value_json.temp }}"
      device_class: temperature
      unit_of_measurement: "°C"
      unique_id: "NT59_4_temperature"
      expire_after: 120
      device:
        identifiers: "IOTBOX_RE59"
  
    - name: "NT59_4_电池电量"
      state_topic: "homeassistant/sensor/RE59/4"
      value_template: "{{ value_json.battery }}"
      device_class: battery
      unit_of_measurement: "%"
      unique_id: "NT59_4_battery_level"
      expire_after: 120
      device:
        identifiers: "IOTBOX_RE59"

MQTT肯定支持我有在用,可以去ha的github提modbus这个需求
回复

使用道具 举报

2

主题

17

帖子

78

积分

注册会员

Rank: 2

积分
78
金钱
61
HASS币
0
 楼主| 发表于 3 天前 | 显示全部楼层
jimmy802 发表于 2025-3-1 13:23
MQTT肯定支持我有在用,可以去ha的github提modbus这个需求

这个上面不用配置mqtt服务器
的地址吗
回复

使用道具 举报

8

主题

41

帖子

269

积分

中级会员

Rank: 3Rank: 3

积分
269
金钱
228
HASS币
0
发表于 3 天前 | 显示全部楼层
402096806 发表于 2025-3-1 17:44
这个上面不用配置mqtt服务器
的地址吗

haos中安装的mqtt加载项,再安装mqtt集成,在集成中配置好。
回复

使用道具 举报

8

主题

41

帖子

269

积分

中级会员

Rank: 3Rank: 3

积分
269
金钱
228
HASS币
0
发表于 3 天前 | 显示全部楼层
效果图如下 QQ20250301-212732.png
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

Archiver|手机版|小黑屋|Hassbian

GMT+8, 2025-3-4 20:15 , Processed in 1.141163 second(s), 31 queries .

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表