Add analog input value sensor for Shelly (#109312)

Co-authored-by: Maciej Bieniek <478555+bieniu@users.noreply.github.com>
Co-authored-by: J. Nick Koston <nick@koston.org>
pull/109888/head
Maciej Bieniek 2024-02-07 17:22:00 +01:00 committed by GitHub
parent d0384480f5
commit b5b09446a1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 16 additions and 1 deletions

View File

@ -960,6 +960,11 @@ RPC_SENSORS: Final = {
native_unit_of_measurement=PERCENTAGE,
state_class=SensorStateClass.MEASUREMENT,
),
"analoginput_xpercent": RpcSensorDescription(
key="input",
sub_key="xpercent",
name="Analog value",
),
}

View File

@ -219,7 +219,7 @@ MOCK_STATUS_COAP = {
MOCK_STATUS_RPC = {
"switch:0": {"output": True},
"input:0": {"id": 0, "state": None},
"input:0": {"id": 0, "state": None, "xpercent": 8.9},
"light:0": {"output": True, "brightness": 53.0},
"cloud": {"connected": False},
"cover:0": {

View File

@ -594,3 +594,13 @@ async def test_block_sleeping_update_entity_service(
"Entity sensor.test_name_temperature comes from a sleeping device"
in caplog.text
)
async def test_rpc_analog_input_xpercent_sensor(
hass: HomeAssistant, mock_rpc_device
) -> None:
"""Test RPC analog input xpercent sensor."""
entity_id = f"{SENSOR_DOMAIN}.test_name_input_0_analog_value"
await init_integration(hass, 2)
assert hass.states.get(entity_id).state == "8.9"