parent
9fafa57074
commit
e97133613a
|
@ -75,7 +75,7 @@ class WallboxCoordinator(DataUpdateCoordinator):
|
|||
filtered_data = {k: data[k] for k in CONF_SENSOR_TYPES if k in data}
|
||||
|
||||
for key, value in filtered_data.items():
|
||||
if sensor_round := CONF_SENSOR_TYPES[key][CONF_ROUND]:
|
||||
if (sensor_round := CONF_SENSOR_TYPES[key][CONF_ROUND]) is not None:
|
||||
try:
|
||||
filtered_data[key] = round(value, sensor_round)
|
||||
except TypeError:
|
||||
|
|
|
@ -31,7 +31,7 @@ test_response = json.loads(
|
|||
json.dumps(
|
||||
{
|
||||
CONF_CHARGING_POWER_KEY: 0,
|
||||
CONF_MAX_AVAILABLE_POWER_KEY: 25,
|
||||
CONF_MAX_AVAILABLE_POWER_KEY: 25.2,
|
||||
CONF_CHARGING_SPEED_KEY: 0,
|
||||
CONF_ADDED_RANGE_KEY: "xx",
|
||||
CONF_ADDED_ENERGY_KEY: "44.697",
|
||||
|
|
|
@ -8,3 +8,4 @@ CONF_STATUS = "status"
|
|||
CONF_MOCK_NUMBER_ENTITY_ID = "number.mock_title_max_charging_current"
|
||||
CONF_MOCK_SENSOR_CHARGING_SPEED_ID = "sensor.mock_title_charging_speed"
|
||||
CONF_MOCK_SENSOR_CHARGING_POWER_ID = "sensor.mock_title_charging_power"
|
||||
CONF_MOCK_SENSOR_MAX_AVAILABLE_POWER = "sensor.mock_title_max_available_power"
|
||||
|
|
|
@ -5,6 +5,7 @@ from tests.components.wallbox import entry, setup_integration
|
|||
from tests.components.wallbox.const import (
|
||||
CONF_MOCK_SENSOR_CHARGING_POWER_ID,
|
||||
CONF_MOCK_SENSOR_CHARGING_SPEED_ID,
|
||||
CONF_MOCK_SENSOR_MAX_AVAILABLE_POWER,
|
||||
)
|
||||
|
||||
|
||||
|
@ -21,4 +22,8 @@ async def test_wallbox_sensor_class(hass):
|
|||
assert state.attributes[CONF_ICON] == "mdi:speedometer"
|
||||
assert state.name == "Mock Title Charging Speed"
|
||||
|
||||
# Test round with precision '0' works
|
||||
state = hass.states.get(CONF_MOCK_SENSOR_MAX_AVAILABLE_POWER)
|
||||
assert state.state == "25.0"
|
||||
|
||||
await hass.config_entries.async_unload(entry.entry_id)
|
||||
|
|
Loading…
Reference in New Issue