diff --git a/homeassistant/components/portainer/sensor.py b/homeassistant/components/portainer/sensor.py index e72db37351d7..53cb302e5d8d 100644 --- a/homeassistant/components/portainer/sensor.py +++ b/homeassistant/components/portainer/sensor.py @@ -16,7 +16,7 @@ from homeassistant.components.sensor import ( SensorStateClass, StateType, ) -from homeassistant.const import PERCENTAGE, UnitOfInformation +from homeassistant.const import UnitOfInformation, UnitOfRatio from homeassistant.core import HomeAssistant from homeassistant.helpers.entity_platform import AddConfigEntryEntitiesCallback @@ -122,7 +122,7 @@ CONTAINER_SENSORS: tuple[PortainerContainerSensorEntityDescription, ...] = ( and data.stats.memory_stats.usage > 0 else 0.0 ), - native_unit_of_measurement=PERCENTAGE, + native_unit_of_measurement=UnitOfRatio.PERCENTAGE, entity_category=EntityCategory.DIAGNOSTIC, suggested_display_precision=2, state_class=SensorStateClass.MEASUREMENT, @@ -151,7 +151,7 @@ CONTAINER_SENSORS: tuple[PortainerContainerSensorEntityDescription, ...] = ( and data.stats.cpu_stats.online_cpus > 0 else 0.0 ), - native_unit_of_measurement=PERCENTAGE, + native_unit_of_measurement=UnitOfRatio.PERCENTAGE, entity_category=EntityCategory.DIAGNOSTIC, suggested_display_precision=2, state_class=SensorStateClass.MEASUREMENT, diff --git a/tests/components/portainer/snapshots/test_sensor.ambr b/tests/components/portainer/snapshots/test_sensor.ambr index 0acd9aa8605d..c63338ea4000 100644 --- a/tests/components/portainer/snapshots/test_sensor.ambr +++ b/tests/components/portainer/snapshots/test_sensor.ambr @@ -203,7 +203,7 @@ 'supported_features': 0, 'translation_key': 'cpu_usage_total', 'unique_id': 'portainer_test_entry_123_dashy_dashy.1.qgza68hnz4n1qvyz3iohynx05_cpu_usage_total', - 'unit_of_measurement': '%', + 'unit_of_measurement': , }) # --- # name: test_all_entities[sensor.dashy_dashy_1_qgza68hnz4n1qvyz3iohynx05_cpu_usage_total-state] @@ -211,7 +211,7 @@ 'attributes': ReadOnlyDict({ : 'dashy_dashy.1.qgza68hnz4n1qvyz3iohynx05 CPU usage total', : , - : '%', + : , }), 'context': , 'entity_id': 'sensor.dashy_dashy_1_qgza68hnz4n1qvyz3iohynx05_cpu_usage_total', @@ -432,7 +432,7 @@ 'supported_features': 0, 'translation_key': 'memory_usage_percentage', 'unique_id': 'portainer_test_entry_123_dashy_dashy.1.qgza68hnz4n1qvyz3iohynx05_memory_usage_percentage', - 'unit_of_measurement': '%', + 'unit_of_measurement': , }) # --- # name: test_all_entities[sensor.dashy_dashy_1_qgza68hnz4n1qvyz3iohynx05_memory_usage_percentage-state] @@ -440,7 +440,7 @@ 'attributes': ReadOnlyDict({ : 'dashy_dashy.1.qgza68hnz4n1qvyz3iohynx05 Memory usage percentage', : , - : '%', + : , }), 'context': , 'entity_id': 'sensor.dashy_dashy_1_qgza68hnz4n1qvyz3iohynx05_memory_usage_percentage', @@ -730,7 +730,7 @@ 'supported_features': 0, 'translation_key': 'cpu_usage_total', 'unique_id': 'portainer_test_entry_123_focused_einstein_cpu_usage_total', - 'unit_of_measurement': '%', + 'unit_of_measurement': , }) # --- # name: test_all_entities[sensor.focused_einstein_cpu_usage_total-state] @@ -738,7 +738,7 @@ 'attributes': ReadOnlyDict({ : 'focused_einstein CPU usage total', : , - : '%', + : , }), 'context': , 'entity_id': 'sensor.focused_einstein_cpu_usage_total', @@ -959,7 +959,7 @@ 'supported_features': 0, 'translation_key': 'memory_usage_percentage', 'unique_id': 'portainer_test_entry_123_focused_einstein_memory_usage_percentage', - 'unit_of_measurement': '%', + 'unit_of_measurement': , }) # --- # name: test_all_entities[sensor.focused_einstein_memory_usage_percentage-state] @@ -967,7 +967,7 @@ 'attributes': ReadOnlyDict({ : 'focused_einstein Memory usage percentage', : , - : '%', + : , }), 'context': , 'entity_id': 'sensor.focused_einstein_memory_usage_percentage', @@ -1084,7 +1084,7 @@ 'supported_features': 0, 'translation_key': 'cpu_usage_total', 'unique_id': 'portainer_test_entry_123_funny_chatelet_cpu_usage_total', - 'unit_of_measurement': '%', + 'unit_of_measurement': , }) # --- # name: test_all_entities[sensor.funny_chatelet_cpu_usage_total-state] @@ -1092,7 +1092,7 @@ 'attributes': ReadOnlyDict({ : 'funny_chatelet CPU usage total', : , - : '%', + : , }), 'context': , 'entity_id': 'sensor.funny_chatelet_cpu_usage_total', @@ -1313,7 +1313,7 @@ 'supported_features': 0, 'translation_key': 'memory_usage_percentage', 'unique_id': 'portainer_test_entry_123_funny_chatelet_memory_usage_percentage', - 'unit_of_measurement': '%', + 'unit_of_measurement': , }) # --- # name: test_all_entities[sensor.funny_chatelet_memory_usage_percentage-state] @@ -1321,7 +1321,7 @@ 'attributes': ReadOnlyDict({ : 'funny_chatelet Memory usage percentage', : , - : '%', + : , }), 'context': , 'entity_id': 'sensor.funny_chatelet_memory_usage_percentage', @@ -2533,7 +2533,7 @@ 'supported_features': 0, 'translation_key': 'cpu_usage_total', 'unique_id': 'portainer_test_entry_123_practical_morse_cpu_usage_total', - 'unit_of_measurement': '%', + 'unit_of_measurement': , }) # --- # name: test_all_entities[sensor.practical_morse_cpu_usage_total-state] @@ -2541,7 +2541,7 @@ 'attributes': ReadOnlyDict({ : 'practical_morse CPU usage total', : , - : '%', + : , }), 'context': , 'entity_id': 'sensor.practical_morse_cpu_usage_total', @@ -2762,7 +2762,7 @@ 'supported_features': 0, 'translation_key': 'memory_usage_percentage', 'unique_id': 'portainer_test_entry_123_practical_morse_memory_usage_percentage', - 'unit_of_measurement': '%', + 'unit_of_measurement': , }) # --- # name: test_all_entities[sensor.practical_morse_memory_usage_percentage-state] @@ -2770,7 +2770,7 @@ 'attributes': ReadOnlyDict({ : 'practical_morse Memory usage percentage', : , - : '%', + : , }), 'context': , 'entity_id': 'sensor.practical_morse_memory_usage_percentage', @@ -2887,7 +2887,7 @@ 'supported_features': 0, 'translation_key': 'cpu_usage_total', 'unique_id': 'portainer_test_entry_123_serene_banach_cpu_usage_total', - 'unit_of_measurement': '%', + 'unit_of_measurement': , }) # --- # name: test_all_entities[sensor.serene_banach_cpu_usage_total-state] @@ -2895,7 +2895,7 @@ 'attributes': ReadOnlyDict({ : 'serene_banach CPU usage total', : , - : '%', + : , }), 'context': , 'entity_id': 'sensor.serene_banach_cpu_usage_total', @@ -3116,7 +3116,7 @@ 'supported_features': 0, 'translation_key': 'memory_usage_percentage', 'unique_id': 'portainer_test_entry_123_serene_banach_memory_usage_percentage', - 'unit_of_measurement': '%', + 'unit_of_measurement': , }) # --- # name: test_all_entities[sensor.serene_banach_memory_usage_percentage-state] @@ -3124,7 +3124,7 @@ 'attributes': ReadOnlyDict({ : 'serene_banach Memory usage percentage', : , - : '%', + : , }), 'context': , 'entity_id': 'sensor.serene_banach_memory_usage_percentage', @@ -3241,7 +3241,7 @@ 'supported_features': 0, 'translation_key': 'cpu_usage_total', 'unique_id': 'portainer_test_entry_123_stoic_turing_cpu_usage_total', - 'unit_of_measurement': '%', + 'unit_of_measurement': , }) # --- # name: test_all_entities[sensor.stoic_turing_cpu_usage_total-state] @@ -3249,7 +3249,7 @@ 'attributes': ReadOnlyDict({ : 'stoic_turing CPU usage total', : , - : '%', + : , }), 'context': , 'entity_id': 'sensor.stoic_turing_cpu_usage_total', @@ -3470,7 +3470,7 @@ 'supported_features': 0, 'translation_key': 'memory_usage_percentage', 'unique_id': 'portainer_test_entry_123_stoic_turing_memory_usage_percentage', - 'unit_of_measurement': '%', + 'unit_of_measurement': , }) # --- # name: test_all_entities[sensor.stoic_turing_memory_usage_percentage-state] @@ -3478,7 +3478,7 @@ 'attributes': ReadOnlyDict({ : 'stoic_turing Memory usage percentage', : , - : '%', + : , }), 'context': , 'entity_id': 'sensor.stoic_turing_memory_usage_percentage',