Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set zwave_js voltage sensor suggested precision #107116

Merged
merged 2 commits into from
Jan 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions homeassistant/components/zwave_js/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@
device_class=SensorDeviceClass.VOLTAGE,
state_class=SensorStateClass.MEASUREMENT,
native_unit_of_measurement=UnitOfElectricPotential.VOLT,
suggested_display_precision=0,
),
(
ENTITY_DESC_KEY_VOLTAGE,
Expand Down
12 changes: 11 additions & 1 deletion tests/components/zwave_js/test_sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,10 @@ async def test_invalid_multilevel_sensor_scale(


async def test_energy_sensors(
hass: HomeAssistant, hank_binary_switch, integration
hass: HomeAssistant,
entity_registry: er.EntityRegistry,
hank_binary_switch,
integration,
) -> None:
"""Test power and energy sensors."""
state = hass.states.get(POWER_SENSOR)
Expand All @@ -191,6 +194,13 @@ async def test_energy_sensors(
assert state.attributes[ATTR_UNIT_OF_MEASUREMENT] == UnitOfElectricPotential.VOLT
assert state.attributes[ATTR_DEVICE_CLASS] == SensorDeviceClass.VOLTAGE

entity_entry = entity_registry.async_get(VOLTAGE_SENSOR)

assert entity_entry is not None
sensor_options = entity_entry.options.get("sensor")
assert sensor_options is not None
assert sensor_options["suggested_display_precision"] == 0

state = hass.states.get(CURRENT_SENSOR)

assert state
Expand Down
Loading