Skip to content

Commit 65d8f64

Browse files
committed
Add RSSI diagnostic
1 parent 8c0e63e commit 65d8f64

File tree

3 files changed

+12
-1
lines changed

3 files changed

+12
-1
lines changed

custom_components/powersensor/PowersensorSensorEntity.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
from homeassistant.components.sensor import SensorDeviceClass, SensorStateClass
2-
from homeassistant.const import EntityCategory, UnitOfPower, UnitOfEnergy, PERCENTAGE
2+
from homeassistant.const import EntityCategory, UnitOfPower, UnitOfEnergy, PERCENTAGE, SIGNAL_STRENGTH_DECIBELS
33
from homeassistant.core import HomeAssistant
44
from homeassistant.helpers.device_registry import DeviceInfo
55

@@ -47,6 +47,15 @@
4747
'event': 'role',
4848
'message_key': 'role',
4949
},
50+
SensorMeasurements.RSSI: {
51+
'name': 'Signal strength (Bluetooth)',
52+
"device_class": SensorDeviceClass.SIGNAL_STRENGTH,
53+
"unit": SIGNAL_STRENGTH_DECIBELS,
54+
"precision": 1,
55+
'category': EntityCategory.DIAGNOSTIC,
56+
'event': 'radio_signal_quality',
57+
'message_key': 'average_rssi',
58+
},
5059
}
5160

5261
class PowersensorSensorEntity(PowersensorEntity):

custom_components/powersensor/SensorMeasurements.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,4 @@ class SensorMeasurements(Enum):
66
WATTS = 2
77
SUMMATION_ENERGY = 3
88
ROLE = 4
9+
RSSI = 5

custom_components/powersensor/sensor.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@ async def handle_discovered_sensor(sensor_mac: str, sensor_role: str):
110110
PowersensorSensorEntity(hass, sensor_mac, sensor_role, SensorMeasurements.WATTS),
111111
PowersensorSensorEntity(hass, sensor_mac, sensor_role, SensorMeasurements.SUMMATION_ENERGY),
112112
PowersensorSensorEntity(hass, sensor_mac, sensor_role, SensorMeasurements.ROLE),
113+
PowersensorSensorEntity(hass, sensor_mac, sensor_role, SensorMeasurements.RSSI),
113114
]
114115
async_add_entities(new_sensors, True)
115116
async_dispatcher_send(hass, SENSOR_ADDED_TO_HA_SIGNAL, sensor_mac, sensor_role)

0 commit comments

Comments
 (0)