Skip to content

Commit

Permalink
Use EntityCategory enum instead of str
Browse files Browse the repository at this point in the history
  • Loading branch information
kvj committed Mar 30, 2022
1 parent aa9deaf commit c9c0531
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 14 deletions.
13 changes: 7 additions & 6 deletions custom_components/nuki_ng/binary_sensor.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from homeassistant.components.binary_sensor import BinarySensorEntity
from homeassistant.helpers.entity import EntityCategory

import logging

Expand Down Expand Up @@ -48,7 +49,7 @@ def device_class(self) -> str:

@property
def entity_category(self):
return "diagnostic"
return EntityCategory.DIAGNOSTIC


class BatteryCharging(NukiEntity, BinarySensorEntity):
Expand All @@ -64,7 +65,7 @@ def is_on(self) -> bool:

@property
def entity_category(self):
return "diagnostic"
return EntityCategory.DIAGNOSTIC


class KeypadBatteryLow(NukiEntity, BinarySensorEntity):
Expand All @@ -83,7 +84,7 @@ def device_class(self) -> str:

@property
def entity_category(self):
return "diagnostic"
return EntityCategory.DIAGNOSTIC


class RingAction(NukiEntity, BinarySensorEntity):
Expand All @@ -104,7 +105,7 @@ def extra_state_attributes(self):

@property
def entity_category(self):
return "diagnostic"
return EntityCategory.DIAGNOSTIC


class LockState(NukiEntity, BinarySensorEntity):
Expand Down Expand Up @@ -161,7 +162,7 @@ def extra_state_attributes(self):

@property
def entity_category(self):
return "diagnostic"
return EntityCategory.DIAGNOSTIC


class BridgeCallbackSet(NukiBridge, BinarySensorEntity):
Expand All @@ -186,4 +187,4 @@ def extra_state_attributes(self):

@property
def entity_category(self):
return "diagnostic"
return EntityCategory.DIAGNOSTIC
15 changes: 8 additions & 7 deletions custom_components/nuki_ng/sensor.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from homeassistant.components.sensor import SensorEntity
from homeassistant.helpers.entity import EntityCategory

import logging

Expand Down Expand Up @@ -53,7 +54,7 @@ def state(self):

@property
def entity_category(self):
return "diagnostic"
return EntityCategory.DIAGNOSTIC


class LockState(NukiEntity, SensorEntity):
Expand All @@ -69,7 +70,7 @@ def state(self):

@property
def entity_category(self):
return "diagnostic"
return EntityCategory.DIAGNOSTIC


class RSSI(NukiEntity, SensorEntity):
Expand All @@ -94,7 +95,7 @@ def state(self):

@property
def entity_category(self):
return "diagnostic"
return EntityCategory.DIAGNOSTIC


class DoorSensorState(NukiEntity, SensorEntity):
Expand All @@ -110,7 +111,7 @@ def state(self):

@property
def entity_category(self):
return "diagnostic"
return EntityCategory.DIAGNOSTIC


class DoorSecurityState(NukiEntity, SensorEntity):
Expand Down Expand Up @@ -160,7 +161,7 @@ def state(self):

@property
def entity_category(self):
return "diagnostic"
return EntityCategory.DIAGNOSTIC


class BridgeVersion(NukiBridge, SensorEntity):
Expand All @@ -176,7 +177,7 @@ def state(self):

@property
def entity_category(self):
return "diagnostic"
return EntityCategory.DIAGNOSTIC


class LockVersion(NukiEntity, SensorEntity):
Expand All @@ -192,4 +193,4 @@ def state(self):

@property
def entity_category(self):
return "diagnostic"
return EntityCategory.DIAGNOSTIC
3 changes: 2 additions & 1 deletion custom_components/nuki_ng/switch.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from homeassistant.components.switch import SwitchEntity
from homeassistant.helpers.entity import EntityCategory

import logging

Expand Down Expand Up @@ -86,4 +87,4 @@ def device_info(self):

@property
def entity_category(self):
return "config"
return EntityCategory.CONFIG

0 comments on commit c9c0531

Please sign in to comment.