Handle step size correctly in myuplink number platform (#133016)

This commit is contained in:
Åke Strandberg 2024-12-13 08:55:44 +01:00 committed by GitHub
parent de89be0512
commit 53439d6e2a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 177 additions and 13 deletions

View File

@ -110,13 +110,16 @@ class MyUplinkNumber(MyUplinkEntity, NumberEntity):
# Internal properties
self.point_id = device_point.parameter_id
self._attr_name = device_point.parameter_name
_scale = float(device_point.scale_value if device_point.scale_value else 1.0)
self._attr_native_min_value = (
device_point.raw["minValue"] if device_point.raw["minValue"] else -30000
) * float(device_point.raw.get("scaleValue", 1))
device_point.min_value if device_point.min_value else -30000
) * _scale
self._attr_native_max_value = (
device_point.raw["maxValue"] if device_point.raw["maxValue"] else 30000
) * float(device_point.raw.get("scaleValue", 1))
self._attr_step_value = device_point.raw.get("stepValue", 20)
device_point.max_value if device_point.max_value else 30000
) * _scale
self._attr_native_step = (
device_point.step_value if device_point.step_value else 1.0
) * _scale
if entity_description is not None:
self.entity_description = entity_description

View File

@ -1091,5 +1091,22 @@
"enumValues": [],
"scaleValue": "1",
"zoneId": null
},
{
"category": "F730 CU 3x400V",
"parameterId": "47398",
"parameterName": "Room sensor set point value heating climate system 1",
"parameterUnit": "°C",
"writable": true,
"timestamp": "2024-12-11T13:23:12+00:00",
"value": 14.5,
"strVal": "14.5°C",
"smartHomeCategories": [],
"minValue": 50.0,
"maxValue": 350.0,
"stepValue": 5.0,
"enumValues": [],
"scaleValue": "0.1",
"zoneId": null
}
]

View File

@ -1152,6 +1152,23 @@
"enumValues": [],
"scaleValue": "1",
"zoneId": null
},
{
"category": "F730 CU 3x400V",
"parameterId": "47398",
"parameterName": "Room sensor set point value heating climate system 1",
"parameterUnit": "°C",
"writable": true,
"timestamp": "2024-12-11T13:23:12+00:00",
"value": 14.5,
"strVal": "14.5°C",
"smartHomeCategories": [],
"minValue": 50.0,
"maxValue": 350.0,
"stepValue": 5.0,
"enumValues": [],
"scaleValue": "0.1",
"zoneId": null
}
]
@ -2297,6 +2314,23 @@
"enumValues": [],
"scaleValue": "1",
"zoneId": null
},
{
"category": "F730 CU 3x400V",
"parameterId": "47398",
"parameterName": "Room sensor set point value heating climate system 1",
"parameterUnit": "°C",
"writable": true,
"timestamp": "2024-12-11T13:23:12+00:00",
"value": 14.5,
"strVal": "14.5°C",
"smartHomeCategories": [],
"minValue": 50.0,
"maxValue": 350.0,
"stepValue": 5.0,
"enumValues": [],
"scaleValue": "0.1",
"zoneId": null
}
]

View File

@ -8,7 +8,7 @@
'max': 3000.0,
'min': -3000.0,
'mode': <NumberMode.AUTO: 'auto'>,
'step': 1.0,
'step': 0.1,
}),
'config_entry_id': <ANY>,
'device_class': None,
@ -44,7 +44,7 @@
'max': 3000.0,
'min': -3000.0,
'mode': <NumberMode.AUTO: 'auto'>,
'step': 1.0,
'step': 0.1,
'unit_of_measurement': 'DM',
}),
'context': <ANY>,
@ -64,7 +64,7 @@
'max': 3000.0,
'min': -3000.0,
'mode': <NumberMode.AUTO: 'auto'>,
'step': 1.0,
'step': 0.1,
}),
'config_entry_id': <ANY>,
'device_class': None,
@ -100,7 +100,7 @@
'max': 3000.0,
'min': -3000.0,
'mode': <NumberMode.AUTO: 'auto'>,
'step': 1.0,
'step': 0.1,
'unit_of_measurement': 'DM',
}),
'context': <ANY>,
@ -221,6 +221,116 @@
'state': '1.0',
})
# ---
# name: test_number_states[platforms0][number.gotham_city_room_sensor_set_point_value_heating_climate_system_1-entry]
EntityRegistryEntrySnapshot({
'aliases': set({
}),
'area_id': None,
'capabilities': dict({
'max': 35.0,
'min': 5.0,
'mode': <NumberMode.AUTO: 'auto'>,
'step': 0.5,
}),
'config_entry_id': <ANY>,
'device_class': None,
'device_id': <ANY>,
'disabled_by': None,
'domain': 'number',
'entity_category': None,
'entity_id': 'number.gotham_city_room_sensor_set_point_value_heating_climate_system_1',
'has_entity_name': True,
'hidden_by': None,
'icon': None,
'id': <ANY>,
'labels': set({
}),
'name': None,
'options': dict({
}),
'original_device_class': None,
'original_icon': None,
'original_name': 'Room sensor set point value heating climate system 1',
'platform': 'myuplink',
'previous_unique_id': None,
'supported_features': 0,
'translation_key': None,
'unique_id': 'robin-r-1234-20240201-123456-aa-bb-cc-dd-ee-ff-47398',
'unit_of_measurement': None,
})
# ---
# name: test_number_states[platforms0][number.gotham_city_room_sensor_set_point_value_heating_climate_system_1-state]
StateSnapshot({
'attributes': ReadOnlyDict({
'friendly_name': 'Gotham City Room sensor set point value heating climate system 1',
'max': 35.0,
'min': 5.0,
'mode': <NumberMode.AUTO: 'auto'>,
'step': 0.5,
}),
'context': <ANY>,
'entity_id': 'number.gotham_city_room_sensor_set_point_value_heating_climate_system_1',
'last_changed': <ANY>,
'last_reported': <ANY>,
'last_updated': <ANY>,
'state': '14.5',
})
# ---
# name: test_number_states[platforms0][number.gotham_city_room_sensor_set_point_value_heating_climate_system_1_2-entry]
EntityRegistryEntrySnapshot({
'aliases': set({
}),
'area_id': None,
'capabilities': dict({
'max': 35.0,
'min': 5.0,
'mode': <NumberMode.AUTO: 'auto'>,
'step': 0.5,
}),
'config_entry_id': <ANY>,
'device_class': None,
'device_id': <ANY>,
'disabled_by': None,
'domain': 'number',
'entity_category': None,
'entity_id': 'number.gotham_city_room_sensor_set_point_value_heating_climate_system_1_2',
'has_entity_name': True,
'hidden_by': None,
'icon': None,
'id': <ANY>,
'labels': set({
}),
'name': None,
'options': dict({
}),
'original_device_class': None,
'original_icon': None,
'original_name': 'Room sensor set point value heating climate system 1',
'platform': 'myuplink',
'previous_unique_id': None,
'supported_features': 0,
'translation_key': None,
'unique_id': 'batman-r-1234-20240201-123456-aa-bb-cc-dd-ee-ff-47398',
'unit_of_measurement': None,
})
# ---
# name: test_number_states[platforms0][number.gotham_city_room_sensor_set_point_value_heating_climate_system_1_2-state]
StateSnapshot({
'attributes': ReadOnlyDict({
'friendly_name': 'Gotham City Room sensor set point value heating climate system 1',
'max': 35.0,
'min': 5.0,
'mode': <NumberMode.AUTO: 'auto'>,
'step': 0.5,
}),
'context': <ANY>,
'entity_id': 'number.gotham_city_room_sensor_set_point_value_heating_climate_system_1_2',
'last_changed': <ANY>,
'last_reported': <ANY>,
'last_updated': <ANY>,
'state': '14.5',
})
# ---
# name: test_number_states[platforms0][number.gotham_city_start_diff_additional_heat-entry]
EntityRegistryEntrySnapshot({
'aliases': set({
@ -230,7 +340,7 @@
'max': 2000.0,
'min': 100.0,
'mode': <NumberMode.AUTO: 'auto'>,
'step': 1.0,
'step': 10.0,
}),
'config_entry_id': <ANY>,
'device_class': None,
@ -266,7 +376,7 @@
'max': 2000.0,
'min': 100.0,
'mode': <NumberMode.AUTO: 'auto'>,
'step': 1.0,
'step': 10.0,
'unit_of_measurement': 'DM',
}),
'context': <ANY>,
@ -286,7 +396,7 @@
'max': 2000.0,
'min': 100.0,
'mode': <NumberMode.AUTO: 'auto'>,
'step': 1.0,
'step': 10.0,
}),
'config_entry_id': <ANY>,
'device_class': None,
@ -322,7 +432,7 @@
'max': 2000.0,
'min': 100.0,
'mode': <NumberMode.AUTO: 'auto'>,
'step': 1.0,
'step': 10.0,
'unit_of_measurement': 'DM',
}),
'context': <ANY>,