|
28 | 28 | SIGNAL_STRENGTH_DECIBELS, |
29 | 29 | UnitOfElectricCurrent, |
30 | 30 | UnitOfElectricPotential, |
| 31 | + UnitOfInformation, |
31 | 32 | UnitOfLength, |
32 | 33 | UnitOfMass, |
33 | 34 | UnitOfPressure, |
@@ -477,6 +478,46 @@ def _build_local_stats_sensors( |
477 | 478 | ) |
478 | 479 | for node_id, node_info in nodes_with_local_stats.items() |
479 | 480 | ] |
| 481 | + |
| 482 | + entities += [ |
| 483 | + MeshtasticSensor( |
| 484 | + coordinator=coordinator, |
| 485 | + entity_description=MeshtasticSensorEntityDescription( |
| 486 | + key="stats_heap_total_bytes", |
| 487 | + name="Heap Total", |
| 488 | + icon="mdi:memory", |
| 489 | + native_unit_of_measurement=UnitOfInformation.BYTES, |
| 490 | + device_class=SensorDeviceClass.DATA_SIZE, |
| 491 | + state_class=SensorStateClass.MEASUREMENT, |
| 492 | + value_fn=lambda device: device.coordinator.data[device.node_id] |
| 493 | + .get("localStats", {}) |
| 494 | + .get("heapTotalBytes", None), |
| 495 | + ), |
| 496 | + gateway=gateway, |
| 497 | + node_id=node_id, |
| 498 | + ) |
| 499 | + for node_id, node_info in nodes_with_local_stats.items() |
| 500 | + ] |
| 501 | + |
| 502 | + entities += [ |
| 503 | + MeshtasticSensor( |
| 504 | + coordinator=coordinator, |
| 505 | + entity_description=MeshtasticSensorEntityDescription( |
| 506 | + key="stats_heap_free_bytes", |
| 507 | + name="Heap Free", |
| 508 | + icon="mdi:memory", |
| 509 | + native_unit_of_measurement=UnitOfInformation.BYTES, |
| 510 | + device_class=SensorDeviceClass.DATA_SIZE, |
| 511 | + state_class=SensorStateClass.MEASUREMENT, |
| 512 | + value_fn=lambda device: device.coordinator.data[device.node_id] |
| 513 | + .get("localStats", {}) |
| 514 | + .get("heapFreeBytes", None), |
| 515 | + ), |
| 516 | + gateway=gateway, |
| 517 | + node_id=node_id, |
| 518 | + ) |
| 519 | + for node_id, node_info in nodes_with_local_stats.items() |
| 520 | + ] |
480 | 521 | except: # noqa: E722 |
481 | 522 | LOGGER.warning("Failed to create local stats entities", exc_info=True) |
482 | 523 |
|
|
0 commit comments