Skip to content

Commit f1a8974

Browse files
authored
Add counter for KNX DataSecure undecodable telegrams (home-assistant#157844)
1 parent 7629c9f commit f1a8974

File tree

4 files changed

+17
-2
lines changed

4 files changed

+17
-2
lines changed

homeassistant/components/knx/icons.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@
2121
"telegram_count": {
2222
"default": "mdi:plus-network"
2323
},
24+
"telegrams_data_secure_undecodable": {
25+
"default": "mdi:lock-alert"
26+
},
2427
"telegrams_incoming": {
2528
"default": "mdi:upload-network"
2629
},

homeassistant/components/knx/sensor.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,12 @@ class KNXSystemEntityDescription(SensorEntityDescription):
108108
+ knx.xknx.connection_manager.cemi_count_incoming
109109
+ knx.xknx.connection_manager.cemi_count_incoming_error,
110110
),
111+
KNXSystemEntityDescription(
112+
key="telegrams_data_secure_undecodable",
113+
entity_registry_enabled_default=False,
114+
state_class=SensorStateClass.TOTAL_INCREASING,
115+
value_fn=lambda knx: knx.xknx.connection_manager.undecoded_data_secure,
116+
),
111117
)
112118

113119

homeassistant/components/knx/strings.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -639,6 +639,10 @@
639639
"name": "Telegrams",
640640
"unit_of_measurement": "telegrams"
641641
},
642+
"telegrams_data_secure_undecodable": {
643+
"name": "Undecodable Data Secure telegrams",
644+
"unit_of_measurement": "[%key:component::knx::entity::sensor::telegrams_incoming_error::unit_of_measurement%]"
645+
},
642646
"telegrams_incoming": {
643647
"name": "Incoming telegrams",
644648
"unit_of_measurement": "[%key:component::knx::entity::sensor::telegram_count::unit_of_measurement%]"

tests/components/knx/test_interface_device.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,15 @@ async def test_diagnostic_entities(
3636
"sensor.knx_interface_outgoing_telegrams",
3737
"sensor.knx_interface_outgoing_telegram_errors",
3838
"sensor.knx_interface_telegrams",
39+
"sensor.knx_interface_undecodable_data_secure_telegrams",
3940
):
4041
entity = entity_registry.async_get(entity_id)
4142
assert entity.entity_category is EntityCategory.DIAGNOSTIC
4243

4344
for entity_id in (
4445
"sensor.knx_interface_incoming_telegrams",
4546
"sensor.knx_interface_outgoing_telegrams",
47+
"sensor.knx_interface_undecodable_data_secure_telegrams",
4648
):
4749
entity = entity_registry.async_get(entity_id)
4850
assert entity.disabled is True
@@ -57,7 +59,7 @@ async def test_diagnostic_entities(
5759
async_fire_time_changed(hass)
5860
await hass.async_block_till_done()
5961

60-
assert len(events) == 3 # 5 polled sensors - 2 disabled
62+
assert len(events) == 3 # 6 polled sensors - 3 disabled
6163
events.clear()
6264

6365
for entity_id, test_state in (
@@ -74,7 +76,7 @@ async def test_diagnostic_entities(
7476
state=XknxConnectionState.DISCONNECTED
7577
)
7678
await hass.async_block_till_done()
77-
assert len(events) == 4 # 3 not always_available + 3 force_update - 2 disabled
79+
assert len(events) == 4
7880
events.clear()
7981

8082
knx.xknx.current_address = IndividualAddress("1.1.1")

0 commit comments

Comments
 (0)