Add WLED IP as a sensor (#90241)

Co-authored-by: Franck Nijhof <frenck@frenck.nl>
pull/90317/head
Alexey Baturin 2023-03-26 20:03:03 +02:00 committed by GitHub
parent c075dac916
commit 89355e0879
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 27 additions and 6 deletions

View File

@ -128,6 +128,13 @@ SENSORS: tuple[WLEDSensorEntityDescription, ...] = (
entity_registry_enabled_default=False,
value_fn=lambda device: device.info.wifi.bssid if device.info.wifi else None,
),
WLEDSensorEntityDescription(
key="ip",
name="IP",
icon="mdi:ip-network",
entity_category=EntityCategory.DIAGNOSTIC,
value_fn=lambda device: device.info.ip,
),
)

View File

@ -86,7 +86,8 @@
"brand": "WLED",
"product": "DIY light",
"btype": "bin",
"mac": "aabbccddeeff"
"mac": "aabbccddeeff",
"ip": "127.0.0.1"
},
"effects": [
"Solid",

View File

@ -86,7 +86,8 @@
"brand": "WLED",
"product": "DIY light",
"btype": "bin",
"mac": "aabbccddeeff"
"mac": "aabbccddeeff",
"ip": "127.0.0.1"
},
"effects": [
"Solid",

View File

@ -68,7 +68,8 @@
"brand": "WLED",
"product": "DIY light",
"btype": "bin",
"mac": "aabbccddeeff"
"mac": "aabbccddeeff",
"ip": "127.0.0.1"
},
"effects": [
"Solid",

View File

@ -94,7 +94,8 @@
"opt": 127,
"brand": "WLED",
"product": "FOSS",
"mac": "aabbccddeeff"
"mac": "aabbccddeeff",
"ip": "127.0.0.1"
},
"effects": [
"Solid",

View File

@ -68,7 +68,8 @@
"brand": "WLED",
"product": "DIY light",
"btype": "bin",
"mac": "aabbccddee11"
"mac": "aabbccddee11",
"ip": "127.0.0.1"
},
"effects": [
"Solid",

View File

@ -92,7 +92,7 @@
'effect_count': 81,
'filesystem': None,
'free_heap': 14600,
'ip': 'Unknown',
'ip': '127.0.0.1',
'leds': dict({
'__type': "<class 'wled.models.Leds'>",
'repr': 'Leds(cct=False, count=30, fps=None, light_capabilities=None, max_power=850, max_segments=10, power=470, rgbw=False, wv=True, segment_light_capabilities=None)',

View File

@ -110,6 +110,15 @@ async def test_sensors(
assert entry.unique_id == "aabbccddeeff_wifi_bssid"
assert entry.entity_category is EntityCategory.DIAGNOSTIC
assert (state := hass.states.get("sensor.wled_rgb_light_ip"))
assert state.attributes.get(ATTR_ICON) == "mdi:ip-network"
assert state.attributes.get(ATTR_UNIT_OF_MEASUREMENT) is None
assert state.state == "127.0.0.1"
assert (entry := entity_registry.async_get("sensor.wled_rgb_light_ip"))
assert entry.unique_id == "aabbccddeeff_ip"
assert entry.entity_category is EntityCategory.DIAGNOSTIC
@pytest.mark.parametrize(
"entity_id",