mirror of
https://github.com/home-assistant/core.git
synced 2025-07-18 18:57:06 +00:00
Use zwave_js.number platform for Basic CC values (#54512)
* Use zwave_js.number platform for some Basic CC values * Remove Basic CC sensor discovery schema * update comment * update comment
This commit is contained in:
parent
2b1299b540
commit
61ab2b0c60
@ -542,10 +542,10 @@ DISCOVERY_SCHEMAS = [
|
||||
allow_multi=True,
|
||||
entity_registry_enabled_default=False,
|
||||
),
|
||||
# sensor for basic CC
|
||||
# number for Basic CC
|
||||
ZWaveDiscoverySchema(
|
||||
platform="sensor",
|
||||
hint="numeric_sensor",
|
||||
platform="number",
|
||||
hint="Basic",
|
||||
primary_value=ZWaveValueDiscoverySchema(
|
||||
command_class={
|
||||
CommandClass.BASIC,
|
||||
@ -553,6 +553,15 @@ DISCOVERY_SCHEMAS = [
|
||||
type={"number"},
|
||||
property={"currentValue"},
|
||||
),
|
||||
required_values=[
|
||||
ZWaveValueDiscoverySchema(
|
||||
command_class={
|
||||
CommandClass.BASIC,
|
||||
},
|
||||
type={"number"},
|
||||
property={"targetValue"},
|
||||
)
|
||||
],
|
||||
entity_registry_enabled_default=False,
|
||||
),
|
||||
# binary switches
|
||||
|
@ -198,22 +198,6 @@ class ZWaveStringSensor(ZwaveSensorBase):
|
||||
class ZWaveNumericSensor(ZwaveSensorBase):
|
||||
"""Representation of a Z-Wave Numeric sensor."""
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
config_entry: ConfigEntry,
|
||||
client: ZwaveClient,
|
||||
info: ZwaveDiscoveryInfo,
|
||||
) -> None:
|
||||
"""Initialize a ZWaveNumericSensor entity."""
|
||||
super().__init__(config_entry, client, info)
|
||||
|
||||
# Entity class attributes
|
||||
if self.info.primary_value.command_class == CommandClass.BASIC:
|
||||
self._attr_name = self.generate_name(
|
||||
include_value_name=True,
|
||||
alternate_value_name=self.info.primary_value.command_class_name,
|
||||
)
|
||||
|
||||
@property
|
||||
def native_value(self) -> float:
|
||||
"""Return state of the sensor."""
|
||||
|
@ -16,7 +16,7 @@ NOTIFICATION_MOTION_BINARY_SENSOR = (
|
||||
)
|
||||
NOTIFICATION_MOTION_SENSOR = "sensor.multisensor_6_home_security_motion_sensor_status"
|
||||
INDICATOR_SENSOR = "sensor.z_wave_thermostat_indicator_value"
|
||||
BASIC_SENSOR = "sensor.livingroomlight_basic"
|
||||
BASIC_NUMBER_ENTITY = "number.livingroomlight_basic"
|
||||
PROPERTY_DOOR_STATUS_BINARY_SENSOR = (
|
||||
"binary_sensor.august_smart_lock_pro_3rd_gen_the_current_status_of_the_door"
|
||||
)
|
||||
|
@ -1,6 +1,10 @@
|
||||
"""Test the Z-Wave JS number platform."""
|
||||
from zwave_js_server.event import Event
|
||||
|
||||
from homeassistant.helpers import entity_registry as er
|
||||
|
||||
from .common import BASIC_NUMBER_ENTITY
|
||||
|
||||
NUMBER_ENTITY = "number.thermostat_hvac_valve_control"
|
||||
|
||||
|
||||
@ -67,3 +71,13 @@ async def test_number(hass, client, aeotec_radiator_thermostat, integration):
|
||||
|
||||
state = hass.states.get(NUMBER_ENTITY)
|
||||
assert state.state == "99.0"
|
||||
|
||||
|
||||
async def test_disabled_basic_number(hass, ge_in_wall_dimmer_switch, integration):
|
||||
"""Test number is created from Basic CC and is disabled."""
|
||||
ent_reg = er.async_get(hass)
|
||||
entity_entry = ent_reg.async_get(BASIC_NUMBER_ENTITY)
|
||||
|
||||
assert entity_entry
|
||||
assert entity_entry.disabled
|
||||
assert entity_entry.disabled_by == er.DISABLED_INTEGRATION
|
||||
|
@ -28,7 +28,6 @@ from homeassistant.helpers import entity_registry as er
|
||||
|
||||
from .common import (
|
||||
AIR_TEMPERATURE_SENSOR,
|
||||
BASIC_SENSOR,
|
||||
CURRENT_SENSOR,
|
||||
DATETIME_LAST_RESET,
|
||||
DATETIME_ZERO,
|
||||
@ -131,16 +130,6 @@ async def test_disabled_indcator_sensor(
|
||||
assert entity_entry.disabled_by == er.DISABLED_INTEGRATION
|
||||
|
||||
|
||||
async def test_disabled_basic_sensor(hass, ge_in_wall_dimmer_switch, integration):
|
||||
"""Test sensor is created from Basic CC and is disabled."""
|
||||
ent_reg = er.async_get(hass)
|
||||
entity_entry = ent_reg.async_get(BASIC_SENSOR)
|
||||
|
||||
assert entity_entry
|
||||
assert entity_entry.disabled
|
||||
assert entity_entry.disabled_by == er.DISABLED_INTEGRATION
|
||||
|
||||
|
||||
async def test_config_parameter_sensor(hass, lock_id_lock_as_id150, integration):
|
||||
"""Test config parameter sensor is created."""
|
||||
ent_reg = er.async_get(hass)
|
||||
|
Loading…
x
Reference in New Issue
Block a user