I’m using PFC200 from Wago to automate my home. The blinds and lights are working fine, I got a lot of scenes implemented in the PLC. Now I would like to visualize the state of lights and be able to turn them on/off from HA. HA will be just as a visualization tool - everything else is on the PLC.
I wanted to connect to my PLC using modbus but I’m having a lot of problems with configuration.
First of all, I’m always getting the following error:
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
Data are actually read but this error is always there spamming logs.
And the second problem is the data refresh time. I was investigating the PLC and the modbus is working fine there, updating the data immediately but it is not reflected in HA even I have scan_interval: 2
.
Here is my configuration:
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
Maybe I should go with the registry instead of the coil? Can someone share his working configuration?