How to stop modbus interrogation

I use Modbus to get electrical data from 3 devices. the setup is HA connect to a TCP <=> Modbus converter. the 3 devices are connected via a RS485 bus to the converter.
In the configuration.yaml file the 3 devices are addressed via the Slave parameter and I use the Sensor platform to read the data.
so fa so good, this works fine, HA receives all the required information.
but
one of the devices is my Goodwe PV inverter. and for some obscure reason the inverter does not like being interrogated during bootup.
every morning when there is enough power from the PV panels the inverter boots. when HA sends a request to the inverter during this moment, the inverter resets all of its internal counters. Goodwe is not willing to seriously investigate the problem.
So what I want is to stop interrogating this slave from sunset to sunrise.
the 2 other slaves should continue to operate, so I can’t stop the whole modbus thing. I want only to stop the secified slave.
Any suggestions how to achieve this?

You’ll need to disable polling on the modbus integration and create an automation to do the polling. The automation in turn will make the decision of what to poll / not poll.

To disable polling go into the integration system options and turn polling off, then use this method call to poll when needed.

  action:
    - service: homeassistant.update_entity
      data: {}
      target:
        entity_id: sensor.r_generator_state

Actually for modbus you’ll want to set the scan_interval to zero

scan_interval integer (optional, default: 15)

Update interval in seconds. scan_interval = 0 for no polling. Entities are read shortly after startup and then according to scan_interval. Remark, when restarting HA the last known value is restored.

1 Like

thanks. this works like a charm.

Hi, I have the same problem. I have a Modbus TCP gateway that queries two Modbus 485 devices identified as slave 1 and slave 2. If both devices are on, there’s no issue, but if slave 1 is off, slave 2 stops working. This problem occurs only with Home Assistant; if I query them using a Modbus simulator, everything works fine.

How did you manage to modify the scan interval dynamically?

Thanks!

I have the same problem, were you able to solve it?

Hello, I don’t remember my solution, so I’m pasting my configuration as an example. When only Slave 2 is online, the system operates, but it’s not very speedy. However, when all slaves are online, the system runs at full speed without any delays.

We attempted to create a dynamic scan interval, but it isn’t a functional solution

  • name: fairland
    type: tcp
    host: 192.168.2.58
    port: 502
    delay: 5
    timeout: 2

    sensors:

    • name: “RPM Attuali Pompa”
      slave: 2
      address: 3140 # 0x0C44 in decimale
      input_type: holding # CORRETTO: Usa Holding Register (funzione 03)
      scan_interval: 10
      data_type: uint16
      unit_of_measurement: “RPM”

    • name: “Consumo Pompa Piscina”
      slave: 2
      address: 3141 # 0x0C45 in decimale
      input_type: holding # CORRETTO: Usa Holding Register (funzione 03)
      scan_interval: 10
      data_type: uint16
      unit_of_measurement: “W”

    • name: “PWP Speed Percentage”
      slave: 1
      address: 0
      input_type: input
      scan_interval: 0 #15
      data_type: uint16
      unit_of_measurement: “%”

    • name: “Voltage of PFC”
      slave: 1
      address: 2
      input_type: input
      scan_interval: 0 #15
      data_type: uint16
      unit_of_measurement: “V”

    • name: “PWP Inlet Water Temperature”
      slave: 1
      address: 3
      input_type: input
      scan_interval: 0 #15
      data_type: uint16
      unit_of_measurement: “°C”
      scale: 0.5
      offset: -30
      precision: 1

    • name: “PWP Outlet Water Temperature”
      slave: 1
      address: 4
      input_type: input
      scan_interval: 0 #15
      data_type: uint16
      unit_of_measurement: “°C”
      scale: 0.5
      offset: -30
      precision: 1

    • name: “PWP Ambient Air Temperature”
      slave: 1
      address: 5
      input_type: input
      scan_interval: 0 #15
      data_type: uint16
      unit_of_measurement: “°C”
      scale: 0.5
      offset: -30
      precision: 1

    • name: “PWP Compressor Current”
      slave: 1
      address: 11
      input_type: input
      scan_interval: 0 #15
      data_type: uint16
      unit_of_measurement: “A”
      scale: 0.1

    • name: “PWP Compressor Running Frequency”
      slave: 1
      address: 10
      input_type: input
      scan_interval: 0 #15
      data_type: uint16
      unit_of_measurement: “Hz”

    • name: “PWP Cooling Plate Temperature”
      slave: 1
      address: 12
      input_type: input
      scan_interval: 0 #15
      data_type: uint16
      unit_of_measurement: “°C”
      scale: 0.5
      offset: -30
      precision: 1

    • name: “PWP DC Fan Speed”
      slave: 1
      address: 14
      input_type: input
      scan_interval: 0 #15
      data_type: uint16
      unit_of_measurement: “RPM”

    • name: “Voltage of Power Supply”
      slave: 1
      address: 30
      input_type: input
      scan_interval: 0 #15
      data_type: uint16
      unit_of_measurement: “V”

    switches:

    • name: “PWP Power Switch”
      slave: 1
      address: 0
      write_type: coil

    binary_sensors:

    • name: “PWP Error E0”
      slave: 1
      address: 48
      input_type: discrete_input
      device_class: problem

    • name: “PWP Error E1 - High Pressure Protection”
      slave: 1
      address: 49
      input_type: discrete_input
      device_class: problem

    • name: “PWP Error E2 Low Pressure Protection”
      slave: 1
      address: 50
      input_type: discrete_input
      device_class: problem

    • name: “PWP Warning E3 No Water Protection”
      slave: 1
      address: 51
      input_type: discrete_input
      device_class: problem

    • name: “PWP Error E4 3 Phase Sequence Protection”
      slave: 1
      address: 52
      input_type: discrete_input
      device_class: problem

    • name: “PWP Warning E5 Power Supply Out of Range”
      slave: 1
      address: 53
      input_type: discrete_input
      device_class: problem