Skip to content

Commit ee8a15b

Browse files
Fix incorrect sensor definition for Indevolt Gen-1 devices (home-assistant#168835)
Co-authored-by: Ariel Ebersberger <31776703+justanotherariel@users.noreply.github.com>
1 parent 7f92d88 commit ee8a15b

5 files changed

Lines changed: 57 additions & 65 deletions

File tree

homeassistant/components/indevolt/number.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ class IndevoltNumberEntityDescription(NumberEntityDescription):
4343
native_max_value=100,
4444
native_step=1,
4545
native_unit_of_measurement=PERCENTAGE,
46-
device_class=NumberDeviceClass.BATTERY,
4746
),
4847
IndevoltNumberEntityDescription(
4948
key="max_ac_output_power",

homeassistant/components/indevolt/sensor.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -69,10 +69,8 @@ class IndevoltSensorEntityDescription(SensorEntityDescription):
6969
IndevoltSensorEntityDescription(
7070
key="6105",
7171
generation=[1],
72-
translation_key="rated_capacity",
73-
native_unit_of_measurement=UnitOfEnergy.KILO_WATT_HOUR,
74-
device_class=SensorDeviceClass.ENERGY,
75-
state_class=SensorStateClass.TOTAL_INCREASING,
72+
translation_key="discharge_limit",
73+
native_unit_of_measurement=PERCENTAGE,
7674
),
7775
IndevoltSensorEntityDescription(
7876
key="2101",

homeassistant/components/indevolt/strings.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,9 @@
223223
"dc_output_power": {
224224
"name": "DC output power"
225225
},
226+
"discharge_limit": {
227+
"name": "[%key:component::indevolt::entity::number::discharge_limit::name%]"
228+
},
226229
"energy_mode": {
227230
"name": "Energy mode",
228231
"state": {

tests/components/indevolt/snapshots/test_number.ambr

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
'object_id_base': 'Discharge limit',
3030
'options': dict({
3131
}),
32-
'original_device_class': <NumberDeviceClass.BATTERY: 'battery'>,
32+
'original_device_class': None,
3333
'original_icon': None,
3434
'original_name': 'Discharge limit',
3535
'platform': 'indevolt',
@@ -44,7 +44,6 @@
4444
# name: test_number[2][number.cms_sf2000_discharge_limit-state]
4545
StateSnapshot({
4646
'attributes': ReadOnlyDict({
47-
'device_class': 'battery',
4847
'friendly_name': 'CMS-SF2000 Discharge limit',
4948
'max': 100,
5049
'min': 0,

tests/components/indevolt/snapshots/test_sensor.ambr

Lines changed: 51 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -645,6 +645,57 @@
645645
'state': 'main',
646646
})
647647
# ---
648+
# name: test_sensor[1][sensor.bk1600_discharge_limit-entry]
649+
EntityRegistryEntrySnapshot({
650+
'aliases': list([
651+
None,
652+
]),
653+
'area_id': None,
654+
'capabilities': None,
655+
'config_entry_id': <ANY>,
656+
'config_subentry_id': <ANY>,
657+
'device_class': None,
658+
'device_id': <ANY>,
659+
'disabled_by': None,
660+
'domain': 'sensor',
661+
'entity_category': None,
662+
'entity_id': 'sensor.bk1600_discharge_limit',
663+
'has_entity_name': True,
664+
'hidden_by': None,
665+
'icon': None,
666+
'id': <ANY>,
667+
'labels': set({
668+
}),
669+
'name': None,
670+
'object_id_base': 'Discharge limit',
671+
'options': dict({
672+
}),
673+
'original_device_class': None,
674+
'original_icon': None,
675+
'original_name': 'Discharge limit',
676+
'platform': 'indevolt',
677+
'previous_unique_id': None,
678+
'suggested_object_id': None,
679+
'supported_features': 0,
680+
'translation_key': 'discharge_limit',
681+
'unique_id': 'BK1600-12345678_6105',
682+
'unit_of_measurement': '%',
683+
})
684+
# ---
685+
# name: test_sensor[1][sensor.bk1600_discharge_limit-state]
686+
StateSnapshot({
687+
'attributes': ReadOnlyDict({
688+
'friendly_name': 'BK1600 Discharge limit',
689+
'unit_of_measurement': '%',
690+
}),
691+
'context': <ANY>,
692+
'entity_id': 'sensor.bk1600_discharge_limit',
693+
'last_changed': <ANY>,
694+
'last_reported': <ANY>,
695+
'last_updated': <ANY>,
696+
'state': '5',
697+
})
698+
# ---
648699
# name: test_sensor[1][sensor.bk1600_energy_mode-entry]
649700
EntityRegistryEntrySnapshot({
650701
'aliases': list([
@@ -767,64 +818,6 @@
767818
'state': '0',
768819
})
769820
# ---
770-
# name: test_sensor[1][sensor.bk1600_rated_capacity-entry]
771-
EntityRegistryEntrySnapshot({
772-
'aliases': list([
773-
None,
774-
]),
775-
'area_id': None,
776-
'capabilities': dict({
777-
'state_class': <SensorStateClass.TOTAL_INCREASING: 'total_increasing'>,
778-
}),
779-
'config_entry_id': <ANY>,
780-
'config_subentry_id': <ANY>,
781-
'device_class': None,
782-
'device_id': <ANY>,
783-
'disabled_by': None,
784-
'domain': 'sensor',
785-
'entity_category': None,
786-
'entity_id': 'sensor.bk1600_rated_capacity',
787-
'has_entity_name': True,
788-
'hidden_by': None,
789-
'icon': None,
790-
'id': <ANY>,
791-
'labels': set({
792-
}),
793-
'name': None,
794-
'object_id_base': 'Rated capacity',
795-
'options': dict({
796-
'sensor': dict({
797-
'suggested_display_precision': 2,
798-
}),
799-
}),
800-
'original_device_class': <SensorDeviceClass.ENERGY: 'energy'>,
801-
'original_icon': None,
802-
'original_name': 'Rated capacity',
803-
'platform': 'indevolt',
804-
'previous_unique_id': None,
805-
'suggested_object_id': None,
806-
'supported_features': 0,
807-
'translation_key': 'rated_capacity',
808-
'unique_id': 'BK1600-12345678_6105',
809-
'unit_of_measurement': <UnitOfEnergy.KILO_WATT_HOUR: 'kWh'>,
810-
})
811-
# ---
812-
# name: test_sensor[1][sensor.bk1600_rated_capacity-state]
813-
StateSnapshot({
814-
'attributes': ReadOnlyDict({
815-
'device_class': 'energy',
816-
'friendly_name': 'BK1600 Rated capacity',
817-
'state_class': <SensorStateClass.TOTAL_INCREASING: 'total_increasing'>,
818-
'unit_of_measurement': <UnitOfEnergy.KILO_WATT_HOUR: 'kWh'>,
819-
}),
820-
'context': <ANY>,
821-
'entity_id': 'sensor.bk1600_rated_capacity',
822-
'last_changed': <ANY>,
823-
'last_reported': <ANY>,
824-
'last_updated': <ANY>,
825-
'state': '5',
826-
})
827-
# ---
828821
# name: test_sensor[1][sensor.bk1600_total_ac_input_energy-entry]
829822
EntityRegistryEntrySnapshot({
830823
'aliases': list([

0 commit comments

Comments
 (0)