home-assistant / core

:house_with_garden: Open source home automation that puts local control and privacy first.
https://www.home-assistant.io
Apache License 2.0
74.18k stars 31.15k forks source link

Modbus-tcp swap not longer working #98999

Closed rainerbeck closed 1 year ago

rainerbeck commented 1 year ago

The problem

Loading of the configurations fails with error message Invalid config for [modbus]: Error in sensor BDC rated power swap(word) impossible because datatype(uint16) is too small @ data['modbus'][0]['sensors'][19]. Got {'name': 'BDC rated power', 'unique_id': 'sg_bdc_rated_power', 'slave': 1, 'address': 5627, 'input_type': 'input', 'count': 1, 'data_type': 'uint16', 'swap': 'word', 'unit_of_measurement': 'W', 'device_class': 'power', 'state_class': 'measurement', 'scale': 100, 'scan_interval': 600}

Therefore the modbus-Sensors are no longer working.

What version of Home Assistant Core has the issue?

Core-2023.8.3 and Core-2023.8.4

What was the last working version of Home Assistant Core?

Core-2023.8.2

What type of installation are you running?

Home Assistant OS

Integration causing the issue

ModBus

Link to integration documentation on our website

No response

Diagnostics information

No response

Example YAML snippet

sensors:
      - name: Sungrow device type code
        unique_id: sg_dev_code
        slave: !secret sungrow_modbus_slave
        address: 4999 # reg 5000
        input_type: input
        count: 1
        data_type: uint16
        swap: word
        scan_interval: 600

Anything in the logs that might be useful for us?

Logger: homeassistant.config
Source: config.py:878
First occurred: 05:41:43 (1 occurrences)
Last logged: 05:41:43

Invalid config for [modbus]: Error in sensor BDC rated power swap(word) impossible because datatype(uint16) is too small @ data['modbus'][0]['sensors'][19]. Got {'name': 'BDC rated power', 'unique_id': 'sg_bdc_rated_power', 'slave': 1, 'address': 5627, 'input_type': 'input', 'count': 1, 'data_type': 'uint16', 'swap': 'word', 'unit_of_measurement': 'W', 'device_class': 'power', 'state_class': 'measurement', 'scale': 100, 'scan_interval': 600} Error in sensor BMS max. charging current swap(word) impossible because datatype(uint16) is too small @ data['modbus'][0]['sensors'][20]. Got {'name': 'BMS max. charging current', 'unique_id': 'sg_bms_max_charging_current', 'slave': 1, 'address': 5634, 'input_type': 'input', 'count': 1, 'data_type': 'uint16', 'swap': 'word', 'precision': 0, 'unit_of_measurement': 'A', 'device_class': 'Current', 'scale': 1, 'scan_interval': 60} Error in sensor BMS max. discharging current swap(word) impossible because datatype(uint16) is too small @ data['modbus'][0]['sensors'][21]. Got {'name': 'BMS max. discharging current', 'unique_id': 'sg_bms_max_discharging_current', 'slave': 1, 'address': 5635, 'input_type': 'input', 'count': 1, 'data_type': 'uint16', 'swap': 'word', 'precision': 0, 'unit_of_measurement': 'A', 'device_class': 'Current', 'scale': 1, 'scan_interval': 60} Error in sensor Backup phase A power swap(word) impossible because datatype(int16) is too small @ data['modbus'][0]['sensors'][23]. Got {'name': 'Backup phase A power', 'unique_id': 'sg_backup_phase_a_power', 'slave': 1, 'address': 5722, 'input_type': 'input', 'count': 1, 'data_type': 'int16', 'swap': 'word', 'precision': 0, 'unit_of_measurement': 'W', 'device_class': 'power', 'state_class': 'measurement', 'scale': 1, 'scan_interval': 10} Error in sensor Backup phase B power swap(word) impossible because datatype(int16) is too small @ data['modbus'][0]['sensors'][24]. Got {'name': 'Backup phase B power', 'unique_id': 'sg_backup_phase_b_power', 'slave': 1, 'address': 5723, 'input_type': 'input', 'count': 1, 'data_type': 'int16', 'swap': 'word', 'precision': 0, 'unit_of_measurement': 'W', 'device_class': 'power', 'state_class': 'measurement', 'scale': 1, 'scan_interval': 10} Error in sensor Backup phase C power swap(word) impossible because datatype(int16) is too small @ data['modbus'][0]['sensors'][25]. Got {'name': 'Backup phase C power', 'unique_id': 'sg_backup_phase_c_power', 'slave': 1, 'address': 5724, 'input_type': 'input', 'count': 1, 'data_type': 'int16', 'swap': 'word', 'precision': 0, 'unit_of_measurement': 'W', 'device_class': 'power', 'state_class': 'measurement', 'scale': 1, 'scan_interval': 10} Error in sensor Battery capacity swap(word) impossible because datatype(uint16) is too small @ data['modbus'][0]['sensors'][110]. Got {'name': 'Battery capacity', 'unique_id': 'sg_battery_capacity', 'slave': 1, 'address': 33048, 'input_type': 'holding', 'count': 1, 'data_type': 'uint16', 'swap': 'word', 'unit_of_measurement': 'kWh', 'device_class': 'energy', 'scale': 0.01, 'scan_interval': 600} Error in sensor Battery charging start power swap(word) impossible because datatype(uint16) is too small @ data['modbus'][0]['sensors'][111]. Got {'name': 'Battery charging start power', 'unique_id': 'sg_battery_charging_start_power', 'slave': 1, 'address': 33148, 'input_type': 'holding', 'count': 1, 'data_type': 'uint16', 'swap': 'word', 'precision': 0, 'unit_of_measurement': 'W', 'device_class': 'power', 'state_class': 'measurement', 'scale': 10, 'scan_interval': 10} Error in sensor Battery current swap(word) impossible because datatype(uint16) is too small @ data['modbus'][0]['sensors'][84]. Got {'name': 'Battery current', 'unique_id': 'sg_battery_current', 'slave': 1, 'address': 13020, 'input_type': 'input', 'count': 1, 'data_type': 'uint16', 'swap': 'word', 'precision': 1, 'unit_of_measurement': 'A', 'device_class': 'Current', 'scale': 0.1, 'scan_interval': 10} Error in sensor Battery discharging start power swap(word) impossible because datatype(uint16) is too small @ data['modbus'][0]['sensors'][112]. Got {'name': 'Battery discharging start power', 'unique_id': 'sg_battery_discharging_start_power', 'slave': 1, 'address': 33149, 'input_type': 'holding', 'count': 1, 'data_type': 'uint16', 'swap': 'word', 'precision': 0, 'unit_of_measurement': 'W', 'device_class': 'power', 'state_class': 'measurement', 'scale': 10, 'scan_interval': 10} Error in sensor Battery forced charge discharge cmd raw swap(word) impossible because datatype(uint16) is too small @ data['modbus'][0]['sensors'][103]. Got {'name': 'Battery forced charge discharge cmd raw', 'unique_id': 'sg_battery_forced_charge_discharge_cmd_raw', 'slave': 1, 'address': 13050, 'input_type': 'holding', 'count': 1, 'data_type': 'uint16', 'swap': 'word', 'precision': 0, 'scan_interval': 10} Error in sensor Battery forced charge discharge power swap(word) impossible because datatype(uint16) is too small @ data['modbus'][0]['sensors'][104]. Got {'name': 'Battery forced charge discharge power', 'unique_id': 'sg_battery_forced_charge_discharge_power', 'slave': 1, 'address': 13051, 'input_type': 'holding', 'count': 1, 'data_type': 'uint16', 'swap': 'word', 'precision': 0, 'unit_of_measurement': 'W', 'device_class': 'power', 'state_class': 'measurement', 'scan_interval': 10} Error in sensor Battery level swap(word) impossible because datatype(uint16) is too small @ data['modbus'][0]['sensors'][86]. Got {'name': 'Battery level', 'unique_id': 'sg_battery_level', 'slave': 1, 'address': 13022, 'input_type': 'input', 'count': 1, 'data_type': 'uint16', 'swap': 'word', 'precision': 1, 'unit_of_measurement': '%', 'device_class': 'battery', 'state_class': 'measurement', 'scale': 0.1, 'scan_interval': 60} Error in sensor Battery max charge power swap(word) impossible because datatype(uint16) is too small @ data['modbus'][0]['sensors'][108]. Got {'name': 'Battery max charge power', 'unique_id': 'sg_battery_max_charge_power', 'slave': 1, 'address': 33046, 'input_type': 'holding', 'count': 1, 'data_type': 'uint16', 'swap': 'word', 'precision': 0, 'unit_of_measurement': 'W', 'device_class': 'power', 'state_class': 'measurement', 'scale': 10, 'scan_interval': 10} Error in sensor Battery max discharge power swap(word) impossible because datatype(uint16) is too small @ data['modbus'][0]['sensors'][109]. Got {'name': 'Battery max discharge power', 'unique_id': 'sg_battery_max_discharge_power', 'slave': 1, 'address': 33047, 'input_type': 'holding', 'count': 1, 'data_type': 'uint16', 'swap': 'word', 'precision': 0, 'unit_of_measurement': 'W', 'device_class': 'power', 'state_class': 'measurement', 'scale': 10, 'scan_interval': 10} Error in sensor Battery power raw swap(word) impossible because datatype(uint16) is too small @ data['modbus'][0]['sensors'][85]. Got {'name': 'Battery power raw', 'unique_id': 'sg_battery_power_raw', 'slave': 1, 'address': 13021, 'input_type': 'input', 'count': 1, 'data_type': 'uint16', 'swap': 'word', 'precision': 0, 'unit_of_measurement': 'W', 'device_class': 'power', 'state_class': 'measurement', 'scale': 1, 'scan_interval': 10} Error in sensor Battery state of health swap(word) impossible because datatype(uint16) is too small @ data['modbus'][0]['sensors'][87]. Got {'name': 'Battery state of health', 'unique_id': 'sg_battery_state_of_health', 'slave': 1, 'address': 13023, 'input_type': 'input', 'count': 1, 'data_type': 'uint16', 'swap': 'word', 'precision': 0, 'unit_of_measurement': '%', 'state_class': 'measurement', 'scale': 0.1, 'scan_interval': 600} Error in sensor Battery voltage swap(word) impossible because datatype(uint16) is too small @ data['modbus'][0]['sensors'][83]. Got {'name': 'Battery voltage', 'unique_id': 'sg_battery_voltage', 'slave': 1, 'address': 13019, 'input_type': 'input', 'count': 1, 'data_type': 'uint16', 'swap': 'word', 'precision': 0, 'unit_of_measurement': 'V', 'device_class': 'Voltage', 'scale': 0.1, 'scan_interval': 10} Error in sensor Daily PV generation & battery discharge swap(word) impossible because datatype(uint16) is too small @ data['modbus'][0]['sensors'][1]. Got {'name': 'Daily PV generation & battery discharge', 'unique_id': 'sg_daily_pv_gen_battery_discharge', 'slave': 1, 'address': 5002, 'input_type': 'input', 'count': 1, 'data_type': 'uint16', 'swap': 'word', 'precision': 1, 'unit_of_measurement': 'kWh', 'device_class': 'energy', 'state_class': 'total_increasing', 'scale': 0.1, 'scan_interval': 600} Error in sensor Daily PV generation swap(word) impossible because datatype(uint16) is too small @ data['modbus'][0]['sensors'][73]. Got {'name': 'Daily PV generation', 'unique_id': 'sg_daily_pv_generation', 'slave': 1, 'address': 13001, 'input_type': 'input', 'count': 1, 'data_type': 'uint16', 'swap': 'word', 'precision': 1, 'unit_of_measurement': 'kWh', 'device_class': 'energy', 'state_class': 'total_increasing', 'scale': 0.1, 'scan_interval': 600} Error in sensor Daily battery charge from PV swap(word) impossible because datatype(uint16) is too small @ data['modbus'][0]['sensors'][79]. Got {'name': 'Daily battery charge from PV', 'unique_id': 'sg_daily_battery_charge_from_pv', 'slave': 1, 'address': 13011, 'input_type': 'input', 'count': 1, 'data_type': 'uint16', 'swap': 'word', 'precision': 1, 'unit_of_measurement': 'kWh', 'device_class': 'energy', 'state_class': 'total_increasing', 'scale': 0.1, 'scan_interval': 600} Error in sensor Daily battery charge swap(word) impossible because datatype(uint16) is too small @ data['modbus'][0]['sensors'][97]. Got {'name': 'Daily battery charge', 'unique_id': 'sg_daily_battery_charge', 'slave': 1, 'address': 13039, 'input_type': 'input', 'count': 1, 'data_type': 'uint16', 'swap': 'word', 'precision': 1, 'unit_of_measurement': 'kWh', 'device_class': 'energy', 'state_class': 'total_increasing', 'scale': 0.1, 'scan_interval': 600} Error in sensor Daily battery discharge swap(word) impossible because datatype(uint16) is too small @ data['modbus'][0]['sensors'][89]. Got {'name': 'Daily battery discharge', 'unique_id': 'sg_daily_battery_discharge', 'slave': 1, 'address': 13025, 'input_type': 'input', 'count': 1, 'data_type': 'uint16', 'swap': 'word', 'precision': 1, 'unit_of_measurement': 'kWh', 'device_class': 'energy', 'state_class': 'total_increasing', 'scale': 0.1, 'scan_interval': 600} Error in sensor Daily direct energy consumption swap(word) impossible because datatype(uint16) is too small @ data['modbus'][0]['sensors'][81]. Got {'name': 'Daily direct energy consumption', 'unique_id': 'sg_daily_direct_energy_consumption', 'slave': 1, 'address': 13016, 'input_type': 'input', 'count': 1, 'data_type': 'uint16', 'swap': 'word', 'precision': 1, 'unit_of_measurement': 'kWh', 'device_class': 'energy', 'state_class': 'total_increasing', 'scale': 0.1, 'scan_interval': 600} Error in sensor Daily exported energy from PV swap(word) impossible because datatype(uint16) is too small @ data['modbus'][0]['sensors'][75]. Got {'name': 'Daily exported energy from PV', 'unique_id': 'sg_daily_exported_energy_from_PV', 'slave': 1, 'address': 13004, 'input_type': 'input', 'count': 1, 'data_type': 'uint16', 'swap': 'word', 'precision': 1, 'unit_of_measurement': 'kWh', 'device_class': 'energy', 'state_class': 'total_increasing', 'scale': 0.1, 'scan_interval': 600} Error in sensor Daily exported energy swap(word) impossible because datatype(uint16) is too small @ data['modbus'][0]['sensors'][99]. Got {'name': 'Daily exported energy', 'unique_id': 'sg_daily_exported_energy', 'slave': 1, 'address': 13044, 'input_type': 'input', 'count': 1, 'data_type': 'uint16', 'swap': 'word', 'precision': 1, 'unit_of_measurement': 'kWh', 'device_class': 'energy', 'state_class': 'total_increasing', 'scale': 0.1, 'scan_interval': 600} Error in sensor Daily imported energy swap(word) impossible because datatype(uint16) is too small @ data['modbus'][0]['sensors'][95]. Got {'name': 'Daily imported energy', 'unique_id': 'sg_daily_imported_energy', 'slave': 1, 'address': 13035, 'input_type': 'input', 'count': 1, 'data_type': 'uint16', 'swap': 'word', 'precision': 1, 'unit_of_measurement': 'kWh', 'device_class': 'energy', 'state_class': 'total_increasing', 'scale': 0.1, 'scan_interval': 600} Error in sensor EMS mode selection raw swap(word) impossible because datatype(uint16) is too small @ data['modbus'][0]['sensors'][102]. Got {'name': 'EMS mode selection raw', 'unique_id': 'sg_ems_mode_selection_raw', 'slave': 1, 'address': 13049, 'input_type': 'holding', 'count': 1, 'data_type': 'uint16', 'swap': 'word', 'scan_interval': 10} Error in sensor Grid frequency swap(word) impossible because datatype(uint16) is too small @ data['modbus'][0]['sensors'][12]. Got {'name': 'Grid frequency', 'unique_id': 'sg_grid_frequency', 'slave': 1, 'address': 5035, 'input_type': 'input', 'count': 1, 'data_type': 'uint16', 'swap': 'word', 'precision': 2, 'unit_of_measurement': 'Hz', 'device_class': 'frequency', 'state_class': 'measurement', 'scale': 0.1, 'scan_interval': 10} Error in sensor Inverter start stop swap(word) impossible because datatype(uint16) is too small @ data['modbus'][0]['sensors'][101]. Got {'name': 'Inverter start stop', 'unique_id': 'sg_inverter_start_stop', 'slave': 1, 'address': 12999, 'input_type': 'holding', 'count': 1, 'data_type': 'uint16', 'swap': 'word', 'precision': 0, 'scan_interval': 10} Error in sensor MPPT1 current swap(word) impossible because datatype(uint16) is too small @ data['modbus'][0]['sensors'][5]. Got {'name': 'MPPT1 current', 'unique_id': 'sg_mppt1_current', 'slave': 1, 'address': 5011, 'input_type': 'input', 'count': 1, 'data_type': 'uint16', 'swap': 'word', 'precision': 2, 'unit_of_measurement': 'A', 'device_class': 'Current', 'scale': 0.1, 'scan_interval': 10} Error in sensor MPPT1 voltage swap(word) impossible because datatype(uint16) is too small @ data['modbus'][0]['sensors'][4]. Got {'name': 'MPPT1 voltage', 'unique_id': 'sg_mppt1_voltage', 'slave': 1, 'address': 5010, 'input_type': 'input', 'count': 1, 'data_type': 'uint16', 'swap': 'word', 'precision': 1, 'unit_of_measurement': 'V', 'device_class': 'Voltage', 'scale': 0.1, 'scan_interval': 10} Error in sensor MPPT2 current swap(word) impossible because datatype(uint16) is too small @ data['modbus'][0]['sensors'][7]. Got {'name': 'MPPT2 current', 'unique_id': 'sg_mppt2_current', 'slave': 1, 'address': 5013, 'input_type': 'input', 'count': 1, 'data_type': 'uint16', 'swap': 'word', 'precision': 2, 'unit_of_measurement': 'A', 'device_class': 'Current', 'scale': 0.1, 'scan_interval': 10} Error in sensor MPPT2 voltage swap(word) impossible because datatype(uint16) is too small @ data['modbus'][0]['sensors'][6]. Got {'name': 'MPPT2 voltage', 'unique_id': 'sg_mppt2_voltage', 'slave': 1, 'address': 5012, 'input_type': 'input', 'count': 1, 'data_type': 'uint16', 'swap': 'word', 'precision': 1, 'unit_of_measurement': 'V', 'device_class': 'Voltage', 'scale': 0.1, 'scan_interval': 10} Error in sensor Max SoC swap(word) impossible because datatype(uint16) is too small @ data['modbus'][0]['sensors'][105]. Got {'name': 'Max SoC', 'unique_id': 'sg_max_soc', 'slave': 1, 'address': 13057, 'input_type': 'holding', 'count': 1, 'data_type': 'uint16', 'swap': 'word', 'precision': 1, 'unit_of_measurement': '%', 'device_class': 'battery', 'state_class': 'measurement', 'scale': 0.1, 'scan_interval': 10} Error in sensor Min SoC swap(word) impossible because datatype(uint16) is too small @ data['modbus'][0]['sensors'][106]. Got {'name': 'Min SoC', 'unique_id': 'sg_min_soc', 'slave': 1, 'address': 13058, 'input_type': 'holding', 'count': 1, 'data_type': 'uint16', 'swap': 'word', 'precision': 1, 'unit_of_measurement': '%', 'device_class': 'battery', 'state_class': 'measurement', 'scale': 0.1, 'scan_interval': 10} Error in sensor Monthly PV generation (01 January) swap(word) impossible because datatype(uint16) is too small @ data['modbus'][0]['sensors'][26]. Got {'name': 'Monthly PV generation (01 January)', 'unique_id': 'sg_monthly_pv_generation_01_january', 'slave': 1, 'address': 6226, 'input_type': 'input', 'count': 1, 'data_type': 'uint16', 'swap': 'word', 'precision': 1, 'unit_of_measurement': 'kWh', 'device_class': 'energy', 'state_class': 'total_increasing', 'scale': 0.1, 'scan_interval': 600} Error in sensor Monthly PV generation (02 February) swap(word) impossible because datatype(uint16) is too small @ data['modbus'][0]['sensors'][27]. Got {'name': 'Monthly PV generation (02 February)', 'unique_id': 'sg_monthly_pv_generation_02_february', 'slave': 1, 'address': 6227, 'input_type': 'input', 'count': 1, 'data_type': 'uint16', 'swap': 'word', 'precision': 1, 'unit_of_measurement': 'kWh', 'device_class': 'energy', 'state_class': 'total_increasing', 'scale': 0.1, 'scan_interval': 600} Error in sensor Monthly PV generation (03 March) swap(word) impossible because datatype(uint16) is too small @ data['modbus'][0]['sensors'][28]. Got {'name': 'Monthly PV generation (03 March)', 'unique_id': 'sg_monthly_pv_generation_03_march', 'slave': 1, 'address': 6228, 'input_type': 'input', 'count': 1, 'data_type': 'uint16', 'swap': 'word', 'precision': 1, 'unit_of_measurement': 'kWh', 'device_class': 'energy', 'state_class': 'total_increasing', 'scale': 0.1, 'scan_interval': 600} Error in sensor Monthly PV generation (04 April) swap(word) impossible because datatype(uint16) is too small @ data['modbus'][0]['sensors'][29]. Got {'name': 'Monthly PV generation (04 April)', 'unique_id': 'sg_monthly_pv_generation_04_april', 'slave': 1, 'address': 6229, 'input_type': 'input', 'count': 1, 'data_type': 'uint16', 'swap': 'word', 'precision': 1, 'unit_of_measurement': 'kWh', 'device_class': 'energy', 'state_class': 'total_increasing', 'scale': 0.1, 'scan_interval': 600} Error in sensor Monthly PV generation (05 May) swap(word) impossible because datatype(uint16) is too small @ data['modbus'][0]['sensors'][30]. Got {'name': 'Monthly PV generation (05 May)', 'unique_id': 'sg_monthly_pv_generation_05_may', 'slave': 1, 'address': 6230, 'input_type': 'input', 'count': 1, 'data_type': 'uint16', 'swap': 'word', 'precision': 1, 'unit_of_measurement': 'kWh', 'device_class': 'energy', 'state_class': 'total_increasing', 'scale': 0.1, 'scan_interval': 600} Error in sensor Monthly PV generation (06 June) swap(word) impossible because datatype(uint16) is too small @ data['modbus'][0]['sensors'][31]. Got {'name': 'Monthly PV generation (06 June)', 'unique_id': 'sg_monthly_pv_generation_06_june', 'slave': 1, 'address': 6231, 'input_type': 'input', 'count': 1, 'data_type': 'uint16', 'swap': 'word', 'precision': 1, 'unit_of_measurement': 'kWh', 'device_class': 'energy', 'state_class': 'total_increasing', 'scale': 0.1, 'scan_interval': 600} Error in sensor Monthly PV generation (07 July) swap(word) impossible because datatype(uint16) is too small @ data['modbus'][0]['sensors'][32]. Got {'name': 'Monthly PV generation (07 July)', 'unique_id': 'sg_monthly_pv_generation_07_july', 'slave': 1, 'address': 6232, 'input_type': 'input', 'count': 1, 'data_type': 'uint16', 'swap': 'word', 'precision': 1, 'unit_of_measurement': 'kWh', 'device_class': 'energy', 'state_class': 'total_increasing', 'scale': 0.1, 'scan_interval': 600} Error in sensor Monthly PV generation (08 August) swap(word) impossible because datatype(uint16) is too small @ data['modbus'][0]['sensors'][33]. Got {'name': 'Monthly PV generation (08 August)', 'unique_id': 'sg_monthly_pv_generation_08_august', 'slave': 1, 'address': 6233, 'input_type': 'input', 'count': 1, 'data_type': 'uint16', 'swap': 'word', 'precision': 1, 'unit_of_measurement': 'kWh', 'device_class': 'energy', 'state_class': 'total_increasing', 'scale': 0.1, 'scan_interval': 600} Error in sensor Monthly PV generation (09 September) swap(word) impossible because datatype(uint16) is too small @ data['modbus'][0]['sensors'][34]. Got {'name': 'Monthly PV generation (09 September)', 'unique_id': 'sg_monthly_pv_generation_09_september', 'slave': 1, 'address': 6234, 'input_type': 'input', 'count': 1, 'data_type': 'uint16', 'swap': 'word', 'precision': 1, 'unit_of_measurement': 'kWh', 'device_class': 'energy', 'state_class': 'total_increasing', 'scale': 0.1, 'scan_interval': 600} Error in sensor Monthly PV generation (10 October) swap(word) impossible because datatype(uint16) is too small @ data['modbus'][0]['sensors'][35]. Got {'name': 'Monthly PV generation (10 October)', 'unique_id': 'sg_monthly_pv_generation_10_october', 'slave': 1, 'address': 6235, 'input_type': 'input', 'count': 1, 'data_type': 'uint16', 'swap': 'word', 'precision': 1, 'unit_of_measurement': 'kWh', 'device_class': 'energy', 'state_class': 'total_increasing', 'scale': 0.1, 'scan_interval': 600} Error in sensor Monthly PV generation (11 November) swap(word) impossible because datatype(uint16) is too small @ data['modbus'][0]['sensors'][36]. Got {'name': 'Monthly PV generation (11 November)', 'unique_id': 'sg_monthly_pv_generation_11_november', 'slave': 1, 'address': 6236, 'input_type': 'input', 'count': 1, 'data_type': 'uint16', 'swap': 'word', 'precision': 1, 'unit_of_measurement': 'kWh', 'device_class': 'energy', 'state_class': 'total_increasing', 'scale': 0.1, 'scan_interval': 600} Error in sensor Monthly PV generation (12 December) swap(word) impossible because datatype(uint16) is too small @ data['modbus'][0]['sensors'][37]. Got {'name': 'Monthly PV generation (12 December)', 'unique_id': 'sg_monthly_pv_generation_12_december', 'slave': 1, 'address': 6237, 'input_type': 'input', 'count': 1, 'data_type': 'uint16', 'swap': 'word', 'precision': 1, 'unit_of_measurement': 'kWh', 'device_class': 'energy', 'state_class': 'total_increasing', 'scale': 0.1, 'scan_interval': 600} Error in sensor Monthly export (01 January) swap(word) impossible because datatype(uint16) is too small @ data['modbus'][0]['sensors'][49]. Got {'name': 'Monthly export (01 January)', 'unique_id': 'sg_monthly_export_01_january', 'slave': 1, 'address': 6595, 'input_type': 'input', 'count': 1, 'data_type': 'uint16', 'swap': 'word', 'precision': 1, 'unit_of_measurement': 'kWh', 'device_class': 'energy', 'state_class': 'total_increasing', 'scale': 0.1, 'scan_interval': 600} Error in sensor Monthly export (02 February) swap(word) impossible because datatype(uint16) is too small @ data['modbus'][0]['sensors'][50]. Got {'name': 'Monthly export (02 February)', 'unique_id': 'sg_monthly_export_02_february', 'slave': 1, 'address': 6596, 'input_type': 'input', 'count': 1, 'data_type': 'uint16', 'swap': 'word', 'precision': 1, 'unit_of_measurement': 'kWh', 'device_class': 'energy', 'state_class': 'total_increasing', 'scale': 0.1, 'scan_interval': 600} Error in sensor Monthly export (03 March) swap(word) impossible because datatype(uint16) is too small @ data['modbus'][0]['sensors'][51]. Got {'name': 'Monthly export (03 March)', 'unique_id': 'sg_monthly_export_03_march', 'slave': 1, 'address': 6597, 'input_type': 'input', 'count': 1, 'data_type': 'uint16', 'swap': 'word', 'precision': 1, 'unit_of_measurement': 'kWh', 'device_class': 'energy', 'state_class': 'total_increasing', 'scale': 0.1, 'scan_interval': 600} Error in sensor Monthly export (04 April) swap(word) impossible because datatype(uint16) is too small @ data['modbus'][0]['sensors'][52]. Got {'name': 'Monthly export (04 April)', 'unique_id': 'sg_monthly_export_04_april', 'slave': 1, 'address': 6598, 'input_type': 'input', 'count': 1, 'data_type': 'uint16', 'swap': 'word', 'precision': 1, 'unit_of_measurement': 'kWh', 'device_class': 'energy', 'state_class': 'total_increasing', 'scale': 0.1, 'scan_interval': 600} Error in sensor Monthly export (05 May) swap(word) impossible because datatype(uint16) is too small @ data['modbus'][0]['sensors'][53]. Got {'name': 'Monthly export (05 May)', 'unique_id': 'sg_monthly_export_05_may', 'slave': 1, 'address': 6599, 'input_type': 'input', 'count': 1, 'data_type': 'uint16', 'swap': 'word', 'precision': 1, 'unit_of_measurement': 'kWh', 'device_class': 'energy', 'state_class': 'total_increasing', 'scale': 0.1, 'scan_interval': 600} Error in sensor Monthly export (06 June) swap(word) impossible because datatype(uint16) is too small @ data['modbus'][0]['sensors'][54]. Got {'name': 'Monthly export (06 June)', 'unique_id': 'sg_monthly_export_06_june', 'slave': 1, 'address': 6600, 'input_type': 'input', 'count': 1, 'data_type': 'uint16', 'swap': 'word', 'precision': 1, 'unit_of_measurement': 'kWh', 'device_class': 'energy', 'state_class': 'total_increasing', 'scale': 0.1, 'scan_interval': 600} Error in sensor Monthly export (07 July) swap(word) impossible because datatype(uint16) is too small @ data['modbus'][0]['sensors'][55]. Got {'name': 'Monthly export (07 July)', 'unique_id': 'sg_monthly_export_07_july', 'slave': 1, 'address': 6601, 'input_type': 'input', 'count': 1, 'data_type': 'uint16', 'swap': 'word', 'precision': 1, 'unit_of_measurement': 'kWh', 'device_class': 'energy', 'state_class': 'total_increasing', 'scale': 0.1, 'scan_interval': 600} Error in sensor Monthly export (08 August) swap(word) impossible because datatype(uint16) is too small @ data['modbus'][0]['sensors'][56]. Got {'name': 'Monthly export (08 August)', 'unique_id': 'sg_monthly_export_08_august', 'slave': 1, 'address': 6602, 'input_type': 'input', 'count': 1, 'data_type': 'uint16', 'swap': 'word', 'precision': 1, 'unit_of_measurement': 'kWh', 'device_class': 'energy', 'state_class': 'total_increasing', 'scale': 0.1, 'scan_interval': 600} Error in sensor Monthly export (09 September) swap(word) impossible because datatype(uint16) is too small @ data['modbus'][0]['sensors'][57]. Got {'name': 'Monthly export (09 September)', 'unique_id': 'sg_monthly_export_09_september', 'slave': 1, 'address': 6603, 'input_type': 'input', 'count': 1, 'data_type': 'uint16', 'swap': 'word', 'precision': 1, 'unit_of_measurement': 'kWh', 'device_class': 'energy', 'state_class': 'total_increasing', 'scale': 0.1, 'scan_interval': 600} Error in sensor Monthly export (10 October) swap(word) impossible because datatype(uint16) is too small @ data['modbus'][0]['sensors'][58]. Got {'name': 'Monthly export (10 October)', 'unique_id': 'sg_monthly_export_10_october', 'slave': 1, 'address': 6604, 'input_type': 'input', 'count': 1, 'data_type': 'uint16', 'swap': 'word', 'precision': 1, 'unit_of_measurement': 'kWh', 'device_class': 'energy', 'state_class': 'total_increasing', 'scale': 0.1, 'scan_interval': 600} Error in sensor Monthly export (11 November) swap(word) impossible because datatype(uint16) is too small @ data['modbus'][0]['sensors'][59]. Got {'name': 'Monthly export (11 November)', 'unique_id': 'sg_monthly_export_11_november', 'slave': 1, 'address': 6605, 'input_type': 'input', 'count': 1, 'data_type': 'uint16', 'swap': 'word', 'precision': 1, 'unit_of_measurement': 'kWh', 'device_class': 'energy', 'state_class': 'total_increasing', 'scale': 0.1, 'scan_interval': 600} Error in sensor Monthly export (12 December) swap(word) impossible because datatype(uint16) is too small @ data['modbus'][0]['sensors'][60]. Got {'name': 'Monthly export (12 December)', 'unique_id': 'sg_monthly_export_12_december', 'slave': 1, 'address': 6606, 'input_type': 'input', 'count': 1, 'data_type': 'uint16', 'swap': 'word', 'precision': 1, 'unit_of_measurement': 'kWh', 'device_class': 'energy', 'state_class': 'total_increasing', 'scale': 0.1, 'scan_interval': 600} Error in sensor Phase A current swap(word) impossible because datatype(int16) is too small @ data['modbus'][0]['sensors'][91]. Got {'name': 'Phase A current', 'unique_id': 'sg_phase_a_current', 'slave': 1, 'address': 13030, 'input_type': 'input', 'count': 1, 'data_type': 'int16', 'swap': 'word', 'precision': 1, 'unit_of_measurement': 'A', 'device_class': 'current', 'state_class': 'measurement', 'scale': 0.1, 'scan_interval': 10} Error in sensor Phase A voltage swap(word) impossible because datatype(uint16) is too small @ data['modbus'][0]['sensors'][9]. Got {'name': 'Phase A voltage', 'unique_id': 'sg_phase_a_voltage', 'slave': 1, 'address': 5018, 'input_type': 'input', 'count': 1, 'data_type': 'uint16', 'swap': 'word', 'precision': 1, 'unit_of_measurement': 'V', 'device_class': 'Voltage', 'state_class': 'measurement', 'scale': 0.1, 'scan_interval': 10} Error in sensor Phase B current swap(word) impossible because datatype(int16) is too small @ data['modbus'][0]['sensors'][92]. Got {'name': 'Phase B current', 'unique_id': 'sg_phase_b_current', 'slave': 1, 'address': 13031, 'input_type': 'input', 'count': 1, 'data_type': 'int16', 'swap': 'word', 'precision': 1, 'unit_of_measurement': 'A', 'device_class': 'current', 'state_class': 'measurement', 'scale': 0.1, 'scan_interval': 10} Error in sensor Phase B voltage swap(word) impossible because datatype(uint16) is too small @ data['modbus'][0]['sensors'][10]. Got {'name': 'Phase B voltage', 'unique_id': 'sg_phase_b_voltage', 'slave': 1, 'address': 5019, 'input_type': 'input', 'count': 1, 'data_type': 'uint16', 'swap': 'word', 'precision': 1, 'unit_of_measurement': 'V', 'device_class': 'Voltage', 'state_class': 'measurement', 'scale': 0.1, 'scan_interval': 10} Error in sensor Phase C current swap(word) impossible because datatype(int16) is too small @ data['modbus'][0]['sensors'][93]. Got {'name': 'Phase C current', 'unique_id': 'sg_phase_c_current', 'slave': 1, 'address': 13032, 'input_type': 'input', 'count': 1, 'data_type': 'int16', 'swap': 'word', 'precision': 1, 'unit_of_measurement': 'A', 'device_class': 'current', 'state_class': 'measurement', 'scale': 0.1, 'scan_interval': 10} Error in sensor Phase C voltage swap(word) impossible because datatype(uint16) is too small @ data['modbus'][0]['sensors'][11]. Got {'name': 'Phase C voltage', 'unique_id': 'sg_phase_c_voltage', 'slave': 1, 'address': 5020, 'input_type': 'input', 'count': 1, 'data_type': 'uint16', 'swap': 'word', 'precision': 1, 'unit_of_measurement': 'V', 'device_class': 'Voltage', 'state_class': 'measurement', 'scale': 0.1, 'scan_interval': 10} Error in sensor Power factor swap(word) impossible because datatype(int16) is too small @ data['modbus'][0]['sensors'][14]. Got {'name': 'Power factor', 'unique_id': 'sg_power_factor', 'slave': 1, 'address': 5034, 'input_type': 'input', 'count': 1, 'data_type': 'int16', 'swap': 'word', 'precision': 3, 'unit_of_measurement': '%', 'device_class': 'power_factor', 'state_class': 'measurement', 'scale': 0.001, 'scan_interval': 10} Error in sensor Reserved SoC for backup swap(word) impossible because datatype(uint16) is too small @ data['modbus'][0]['sensors'][107]. Got {'name': 'Reserved SoC for backup', 'unique_id': 'sg_reserved_soc_for_backup', 'slave': 1, 'address': 13099, 'input_type': 'holding', 'count': 1, 'data_type': 'uint16', 'swap': 'word', 'unit_of_measurement': '%', 'device_class': 'battery', 'state_class': 'measurement', 'scale': 1, 'scan_interval': 10} Error in sensor Running state swap(word) impossible because datatype(uint16) is too small @ data['modbus'][0]['sensors'][72]. Got {'name': 'Running state', 'unique_id': 'sg_running_state', 'slave': 1, 'address': 13000, 'input_type': 'input', 'count': 1, 'data_type': 'uint16', 'swap': 'word', 'precision': 0, 'scale': 1, 'scan_interval': 10} Error in sensor Sungrow device type code swap(word) impossible because datatype(uint16) is too small @ data['modbus'][0]['sensors'][0]. Got {'name': 'Sungrow device type code', 'unique_id': 'sg_dev_code', 'slave': 1, 'address': 4999, 'input_type': 'input', 'count': 1, 'data_type': 'uint16', 'swap': 'word', 'scan_interval': 600} Error in sensor System state swap(word) impossible because datatype(uint16) is too small @ data['modbus'][0]['sensors'][71]. Got {'name': 'System state', 'unique_id': 'sg_system_state', 'slave': 1, 'address': 12999, 'input_type': 'input', 'count': 1, 'data_type': 'uint16', 'swap': 'word', 'precision': 0, 'scale': 1, 'scan_interval': 10} Error in sensor Total backup power swap(word) impossible because datatype(int16) is too small @ data['modbus'][0]['sensors'][22]. Got {'name': 'Total backup power', 'slave': 1, 'unique_id': 'sg_total_backup_power', 'address': 5725, 'input_type': 'input', 'count': 1, 'data_type': 'int16', 'swap': 'word', 'precision': 0, 'unit_of_measurement': 'W', 'device_class': 'power', 'state_class': 'measurement', 'scale': 1, 'scan_interval': 10}. (See ?, line ?). Please check the docs at https://www.home-assistant.io/integrations/modbus

Additional information

No response

home-assistant[bot] commented 1 year ago

Hey there @adamchengtkc, @janiversen, @vzahradnik, mind taking a look at this issue as it has been labeled with an integration (modbus) you are listed as a code owner for? Thanks!

Code owner commands Code owners of `modbus` can trigger bot actions by commenting: - `@home-assistant close` Closes the issue. - `@home-assistant rename Awesome new title` Renames the issue. - `@home-assistant reopen` Reopen the issue. - `@home-assistant unassign modbus` Removes the current integration label and assignees on the issue, add the integration domain after the command.

(message by CodeOwnersMention)


modbus documentation modbus source (message by IssueLinks)

janiversen commented 1 year ago

Read the error message (in .4), it never worked, but now we catch it instead of sometimes producing bad data.

rainerbeck commented 1 year ago

I did read the error message. It does not work with any larger datatype despite being 2 bytes registers the most. And it did work before and yielded usable and correct data. What would be the workaround?

janiversen commented 1 year ago

It does work with e.g. datatype int32. A word is 4 bytes.

Solution is to correct your configuration swap:word or datatype:

workaround is not upgrade

rainerbeck commented 1 year ago

Thank You for Your quick reply….

  - name: BDC rated power
    unique_id: sg_bdc_rated_power
    slave: !secret sungrow_modbus_slave
    address: 5627 # reg 5628
    input_type: input
    count: 1
    data_type: int32
    swap: word
    unit_of_measurement: "W"
    device_class: power
    state_class: measurement
    scale: 100
    scan_interval: 600

Gives

Error in sensor BDC rated power swap(word) impossible because datatype(int32) is too small @ data['modbus'][0]['sensors'][19]. Got {'name': 'BDC rated power', 'unique_id': 'sg_bdc_rated_power', 'slave': 1, 'address': 5627, 'input_type': 'input', 'count': 1, 'data_type': 'int32', 'swap': 'word', 'unit_of_measurement': 'W', 'device_class': 'power', 'state_class': 'measurement', 'scale': 100, 'scan_interval': 600}

So the change of the datatype does not fix it. Does not work with larger datatype as int64 (neither uint32 oder uint64), tried that before writing the bug….

janiversen commented 1 year ago

That must be .3, with .4 that should work but you have other problems, why have you configured count: 1, read the documentation it is calculated.

for int32 you need 2 registers, so count should be 2.

janiversen commented 1 year ago

Btw....how come you change datatype that easy, your device delivers only one datatype and that must be matched.

rainerbeck commented 1 year ago

You are completely right… The datatype delivered is different, but it shouldn‘t matter if I put a in16 in a int32. The error message might still be misleading as a swap: word should work with an int32….

Nevertheless, the configuration seems to be messed up and I will try to rewrite and adapt…

Thank You for Your feedback and Your effort!