Dashboard icon state slowly updated

hello could anyone help me to fix the following issue?
I have a Modbus-Switch on my dashboard, with a slider to set the switch ON/OFF and the icon that show the switch state.
When I set the slider to ON, the hardware works immediately (the relay connected to the RS485 goes ON) but the icon shows that the switch is still OFF and after 12 sceconds (more or less) the icon shows that the switch is ON.
The same if I set the modbus switch OFF: in this case the icon shows that the switch is still ON and after 12 seconds (more or less) the icon shows OFF.
Following is part of the configuration.yaml interested:

Set ModBus

modbus:

  • name: modbus1
    type: serial
    port: /dev/ttyS0
    baudrate: 9600
    bytesize: 8
    method: rtu
    parity: N
    stopbits: 1

Set Slaves (Server) a6_exp1 switches

switches:
  - name: modbus-relay1
    command_on: 0xFF00
    command_off: 0x0000
    slave: 1
    address: 0  # 0:relay1  1:relay2 ......
    write_type: coil
    scan_interval: 1
    verify:
      address: 0 
      input_type: coil

My question is: there is something wrong in my yaml file? Could I improve it in order to have the icon on the dashboard updated in less than two or three seconds?

Hi welcome to the forum.

Please have a look on how to format your code properly: How to help us help you - or How to ask a good questionFormat it properly

Hi! I have this issue

Hardware Configuration Details

I am using HomeAssistantOS (HAOS) on a Raspberry Pi Compute Module 4 (CM4) mounted on the KC868-Server mini board (link to the board).

The board communicates with two peripheral boards KC868-A6 (link to the board). All three boards are on the same LAN and connected via the RS485 bus.

The UART has been enabled by uncommenting the appropriate line in the /boot/config.txt file:

enable_uart=1

Problem Description

When I control the relays of the peripheral boards via Wi-Fi from the HAOS graphical interface, everything works perfectly.

However, if I try to control the peripheral boards through the RS485 bus, bypassing Wi-Fi, the relays on the peripheral boards activate with a delay (ranging from a few seconds to over 30 seconds). Once triggered, the graphical interface is slow to update or temporarily shows them as unavailable (the frontend toggle switch appears grayed out and unclickable).

Meanwhile, the relays on the board with the CM4 continue to function perfectly.

Additional Software Configuration Details

  • The CM4 was flashed with the HAOS image haos_rpi4-64-7.4.img.xz and updated to version 12.4.

  • The system also runs HomeAssistantCore 2024.7.0.

  • The following configuration.yaml is used to setup the KC868-Server mini with HAOS:

# Loads default set of integrations. Do not remove.
default_config:

# Load frontend themes from the themes folder
frontend:
  themes: !include_dir_merge_named themes

automation: !include automations.yaml
script: !include scripts.yaml
scene: !include scenes.yaml

# Set ModBus
modbus:
  - name: modbus1
    type: serial
    port: /dev/ttyS0
    baudrate: 9600
    bytesize: 8
    method: rtu
    parity: N
    stopbits: 1
 
# Set Slaves (Server) switches (slave 1 = a6-exp1, slave 2 = a6-exp2)
    switches:
      - name: modbus-relay1.1
        slave: 1
        address: 0  # 0:relay1  1:relay2 ......
        write_type: coil
        scan_interval: 15
        verify:
          delay: 5
   
      - name: modbus-relay1.2
        slave: 1
        address: 1  # 0:relay1  1:relay2 ......
        write_type: coil
        scan_interval: 15
        verify:
          delay: 5     

      - name: modbus-relay1.3
        slave: 1
        address: 2  # 0:relay1  1:relay2 ......
        write_type: coil
        scan_interval: 15
        verify:
          delay: 5
   
      - name: modbus-relay1.4
        slave: 1
        address: 3  # 0:relay1  1:relay2 ......
        write_type: coil
        scan_interval: 15
        verify:
          delay: 5   

      - name: modbus-relay1.5
        slave: 1
        address: 4  # 0:relay1  1:relay2 ......
        write_type: coil
        scan_interval: 15
        verify:
          delay: 5
   
      - name: modbus-relay1.6
        slave: 1
        address: 5  # 0:relay1  1:relay2 ......
        write_type: coil
        scan_interval: 15
        verify:
          delay: 5   

      - name: modbus-relay2.1
        slave: 2
        address: 0  # 0:relay1  1:relay2 ......
        write_type: coil
        scan_interval: 15
        verify:
          delay: 5
   
      - name: modbus-relay2.2
        slave: 2
        address: 1  # 0:relay1  1:relay2 ......
        write_type: coil
        scan_interval: 15
        verify:
          delay: 5     

      - name: modbus-relay2.3
        slave: 2
        address: 2  # 0:relay1  1:relay2 ......
        write_type: coil
        scan_interval: 15
        verify:
          delay: 5
   
      - name: modbus-relay2.4
        slave: 2
        address: 3  # 0:relay1  1:relay2 ......
        write_type: coil
        scan_interval: 15
        verify:
          delay: 5   

      - name: modbus-relay2.5
        slave: 2
        address: 4  # 0:relay1  1:relay2 ......
        write_type: coil
        scan_interval: 15
        verify:
          delay: 5
   
      - name: modbus-relay2.6
        slave: 2
        address: 5  # 0:relay1  1:relay2 ......
        write_type: coil
        scan_interval: 15
        verify:
          delay: 5   


# Set Slaves (Server) binary_sensors (slave 1 = a6-exp1, slave 2 = a6-exp2)

    binary_sensors:
      - name: modbus-binary_sensor1.1
        slave: 1
        address: 0
        input_type: discrete_input
        scan_interval: 15
        unique_id: PT TAMPER
 
      - name: modbus-binary_sensor1.2
        slave: 1
        address: 1
        input_type: discrete_input
        scan_interval: 15
        unique_id: PT VOL CUCINA
 
      - name: modbus-binary_sensor1.3
        slave: 1
        address: 2
        input_type: discrete_input
        scan_interval: 15
        unique_id: PT VOL CAMINO
 
      - name: modbus-binary_sensor1.4
        slave: 1
        address: 3
        input_type: discrete_input
        scan_interval: 15
        unique_id: PT VOL PIANOFORTE
 
      - name: modbus-binary_sensor1.5
        slave: 1
        address: 4
        input_type: discrete_input
        scan_interval: 15
        unique_id: PT VOL SCALA
 
      - name: modbus-binary_sensor1.6
        slave: 1
        address: 5
        input_type: discrete_input
        scan_interval: 15

      - name: modbus-binary_sensor2.1
        slave: 2
        address: 0
        input_type: discrete_input
        scan_interval: 15
 
      - name: modbus-binary_sensor2.2
        slave: 2
        address: 1
        input_type: discrete_input
        scan_interval: 15
 
      - name: modbus-binary_sensor2.3
        slave: 2
        address: 2
        input_type: discrete_input
        scan_interval: 15
 
      - name: modbus-binary_sensor2.4
        slave: 2
        address: 3
        input_type: discrete_input
        scan_interval: 15
 
      - name: modbus-binary_sensor2.5
        slave: 2
        address: 4
        input_type: discrete_input
        scan_interval: 15
 
      - name: modbus-binary_sensor2.6
        slave: 2
        address: 5
        input_type: discrete_input
        scan_interval: 15

switch:
  - platform: gpiod
    switches:
      - name: "CM4_OUT1"
        port: 5
      - name: "CM4_OUT2"
        port: 22
      - name: "CM4_OUT3"
        port: 17
      - name: "CM4_OUT4"
        port: 4
      - name: "CM4_OUT5"
        port: 6
      - name: "CM4_OUT6"
        port: 13
      - name: "CM4_OUT7"
        port: 19
      - name: "CM4_OUT8"
        port: 26


binary_sensor:
  - platform: gpiod
    sensors:
      - name: "CM4_IN1"
        port: 18
      - name: "CM4_IN2"
        port: 23
      - name: "CM4_IN3"
        port: 24
      - name: "CM4_IN4"
        port: 25
      - name: "CM4_IN5"
        port: 12
      - name: "CM4_IN6"
        port: 16
      - name: "CM4_IN7"
        port: 20
      - name: "CM4_IN8"
        port: 21
  • The peripheral boards KC868-A6 were flashed and configured to enable Modbus using the firmware provided by the manufacturer available here, allowing them to act as slaves on the Modbus bus. (In the future, I intend to reflash these with ESPHome and use an appropriate YAML configuration.)