使用 modbus 将 Home Assistant 连接到 PLC

问题描述

我正在使用 Wago 的 PFC200 来自动化我的家。百叶窗和灯光工作正常,我在 PLC 中实现了很多场景。现在我想可视化灯的状态,并能够从 HA 打开/关闭它们。 HA 将只是一个可视化工具 - 其他一切都在 PLC 上。

我想使用 modbus 连接到我的 PLC,但我在配置方面遇到了很多问题。 首先,我总是收到以下错误

2021-05-19 08:23:41 ERROR (SyncWorker_1) [homeassistant.components.modbus.modbus] Pymodbus: Modbus Error: [Connection] ModbusTcpClient(192.168.10.60:502): Connection unexpectedly closed 0.000071 seconds into read of 8 bytes without response from unit before it closed connection

实际读取数据,但此错误始终存在垃圾邮件日志。

第二个问题是数据刷新时间。我正在调查 PLC,modbus 在那里工作正常,立即更新数据,但即使我有 scan_interval: 2,它也没有反映在 HA 中。

这是我的配置:

modbus:
  - name: PLC
    type: tcp
    host: 192.168.10.60
    port: 502

switch:
  - platform: modbus
    scan_interval: 2
    coils:
      - name: fake_switch
        hub: PLC
        slave: 1
        coil: 0
      - name: switch.bedroom_main_light
        hub: PLC
        slave: 1
        coil: 1
      - name: switch.bedroom_wardrobe_light
        hub: PLC
        slave: 1
        coil: 2
      - name: switch.bathroom_main_light
        hub: PLC
        slave: 1
        coil: 4
      - name: switch.bathroom_mirror_light
        hub: PLC
        slave: 1
        coil: 5

light:
  - platform: switch
    name: bedroom
    entity_id: switch.bedroom_main_light
  - platform: switch
    name: Wardrobe
    entity_id: switch.bedroom_wardrobe_light
  - platform: switch
    name: Bathroom
    entity_id: switch.bathroom_main_light
  - platform: switch
    name: Bathroom - Mirror
    entity_id: switch.bathroom_mirror_light

也许我应该使用注册表而不是线圈?有人可以分享他的工作配置吗?

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...