esphome / issues

Issue Tracker for ESPHome
https://esphome.io/
292 stars 36 forks source link

Number component continuously transmits duplicate values. #5172

Open Alphaemef opened 11 months ago

Alphaemef commented 11 months ago

The problem

The base number component will transmit duplicate values on each update interval. This can be improved with lambda filter, however, if using the number modbus component, every update_interval all the numbers on the range will be updated, and lambda can not be used to filter out duplicate readings.

Which version of ESPHome has the issue?

2023.11.6

What type of installation are you using?

Home Assistant Add-on

Which version of Home Assistant has the issue?

2023.11

What platform are you using?

ESP32-IDF

Board

ESP32

Component causing the issue

Number

Example YAML snippet

- platform: modbus_controller
    use_write_multiple: true
    modbus_controller_id: ${modbus_controller_id}
    id: volt_Time_point_1_bc_limit
    name: "${name} Volt Time point 1 Batt Charge Limit"
    unit_of_measurement: "V"
    device_class: voltage
    address: 160
    min_value: 44
    max_value: 58
    mode: box
    step: 0.1
    value_type: U_WORD
    lambda: |-
      static float prev;
      if (x * 0.01 == prev) return {};
      return prev = x * 0.01;
    write_lambda: |-
      return x * 100;
    disabled_by_default: true
    skip_updates: ${skip_updates13}
    force_new_range: true

The above will report unfiltered modbus read (without the multiplication) on each update_interval.

Anything in the logs that might be useful for us?

[02:27:28][V][modbus_controller:509]: Command sent 3 0x94 12
[02:27:28][V][modbus_controller:078]: Modbus response queued
[02:27:28][V][modbus_controller:086]: Process modbus response for address 0x94 size: 24
[02:27:28][V][modbus_controller:121]: data for register address : 0x94 : 
[02:27:28][D][modbus.number:023]: Number new state : 0.00
[02:27:28][D][number:012]: 'slave0001 Time point 1 start': Sending state 0.000000
[02:27:28][D][modbus.number:023]: Number new state : 600.00
[02:27:28][D][number:012]: 'slave0001 Time point 2 start': Sending state 600.000000
[02:27:28][D][modbus.number:023]: Number new state : 1000.00
[02:27:28][D][number:012]: 'slave0001 Time point 3 start': Sending state 1000.000000
[02:27:28][D][modbus.number:023]: Number new state : 1300.00
[02:27:28][D][number:012]: 'slave0001 Time point 4 start': Sending state 1300.000000
[02:27:28][D][modbus.number:023]: Number new state : 1700.00
[02:27:28][D][number:012]: 'slave0001 Time point 5 start': Sending state 1700.000000
[02:27:28][D][modbus.number:023]: Number new state : 2100.00
[02:27:28][D][number:012]: 'slave0001 Time point 6 start': Sending state 2100.000000
[02:27:28][D][modbus.number:023]: Number new state : 12000.00
[02:27:28][D][number:012]: 'slave0001 Time point 1 power': Sending state 12000.000000
[02:27:28][D][modbus.number:023]: Number new state : 12000.00
[02:27:28][D][number:012]: 'slave0001 Time point 2 power': Sending state 12000.000000
[02:27:28][D][modbus.number:023]: Number new state : 12000.00
[02:27:28][D][number:012]: 'slave0001 Time point 3 power': Sending state 12000.000000
[02:27:28][D][modbus.number:023]: Number new state : 12000.00
[02:27:28][D][number:012]: 'slave0001 Time point 4 power': Sending state 12000.000000
[02:27:28][D][modbus.number:023]: Number new state : 12000.00
[02:27:28][D][number:012]: 'slave0001 Time point 5 power': Sending state 12000.000000
[02:27:29][D][modbus.number:023]: Number new state : 12000.00
[02:27:29][D][number:012]: 'slave0001 Time point 6 power': Sending state 12000.000000
[02:27:29][V][modbus_controller:047]: Sending next modbus command to device 1 register 0xA1 count 17
[02:27:29][V][modbus_controller:509]: Command sent 3 0xA1 17
[02:27:29][V][modbus_controller:078]: Modbus response queued
[02:27:29][V][modbus_controller:086]: Process modbus response for address 0xA1 size: 34
[02:27:29][V][modbus_controller:121]: data for register address : 0xA1 : 
[02:27:29][D][modbus.number:023]: Number new state : 5500.00
[02:27:29][D][number:012]: 'slave0001 Volt Time point 2 Batt Charge Limit': Sending state 5500.000000
[02:27:29][D][modbus.number:023]: Number new state : 5500.00
[02:27:29][D][number:012]: 'slave0001 Volt Time point 3 Batt Charge Limit': Sending state 5500.000000
[02:27:29][D][modbus.number:023]: Number new state : 5500.00
[02:27:29][D][number:012]: 'slave0001 Volt Time point 4 Batt Charge Limit': Sending state 5500.000000
[02:27:29][D][modbus.number:023]: Number new state : 5500.00
[02:27:29][D][number:012]: 'slave0001 Volt Time point 5 Batt Charge Limit': Sending state 5500.000000
[02:27:29][D][modbus.number:023]: Number new state : 5500.00

Additional information

No response

github-actions[bot] commented 7 months ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.