Add support for Z-Wave battery level (#26943)
* Add support for Z-Wave battery level * Improve coverage
This commit is contained in:
1 parent
b1a9fa47ca
commit
eeffd090a3
3 files changed
+30
-1
No files matched your search
@@ -1,7 +1,7 @@
|
||||
"""Support for Z-Wave sensors."""
|
||||
import logging
|
||||
from homeassistant.core import callback
|
||||
from homeassistant.components.sensor import DOMAIN
|
||||
from homeassistant.components.sensor import DOMAIN, DEVICE_CLASS_BATTERY
|
||||
from homeassistant.const import TEMP_CELSIUS, TEMP_FAHRENHEIT
|
||||
from homeassistant.helpers.dispatcher import async_dispatcher_connect
|
||||
from . import const, ZWaveDeviceEntity
|
||||
@@ -28,6 +28,8 @@ async def async_setup_entry(hass, config_entry, async_add_entities):
|
||||
def get_device(node, values, **kwargs):
|
||||
"""Create Z-Wave entity device."""
|
||||
# Generic Device mappings
|
||||
if values.primary.command_class == const.COMMAND_CLASS_BATTERY:
|
||||
return ZWaveBatterySensor(values)
|
||||
if node.has_command_class(const.COMMAND_CLASS_SENSOR_MULTILEVEL):
|
||||
return ZWaveMultilevelSensor(values)
|
||||
if (
|
||||
@@ -107,3 +109,12 @@ class ZWaveAlarmSensor(ZWaveSensor):
|
||||
"""
|
||||
|
||||
pass
|
||||
|
||||
|
||||
class ZWaveBatterySensor(ZWaveSensor):
|
||||
"""Representation of Z-Wave device battery level."""
|
||||
|
||||
@property
|
||||
def device_class(self):
|
||||
"""Return the class of this device."""
|
||||
return DEVICE_CLASS_BATTERY
|
||||
Reference in new issue
Block a user