diff --git a/homeassistant/components/shelly/sensor.py b/homeassistant/components/shelly/sensor.py index e46800963a3..824b7264f26 100644 --- a/homeassistant/components/shelly/sensor.py +++ b/homeassistant/components/shelly/sensor.py @@ -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", + ), } diff --git a/tests/components/shelly/conftest.py b/tests/components/shelly/conftest.py index 194ee57e13b..45e1e551b23 100644 --- a/tests/components/shelly/conftest.py +++ b/tests/components/shelly/conftest.py @@ -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": { diff --git a/tests/components/shelly/test_sensor.py b/tests/components/shelly/test_sensor.py index 79776c00b41..87d0c1baa14 100644 --- a/tests/components/shelly/test_sensor.py +++ b/tests/components/shelly/test_sensor.py @@ -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"