Skip to content

Commit

Permalink
Add entity_category to Rituals Entities (home-assistant#59756)
Browse files Browse the repository at this point in the history
  • Loading branch information
milanmeu authored Nov 16, 2021
1 parent e1e6925 commit f8501de
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
BinarySensorEntity,
)
from homeassistant.config_entries import ConfigEntry
from homeassistant.const import ENTITY_CATEGORY_DIAGNOSTIC
from homeassistant.core import HomeAssistant
from homeassistant.helpers.entity_platform import AddEntitiesCallback

Expand Down Expand Up @@ -38,6 +39,7 @@ class DiffuserBatteryChargingBinarySensor(DiffuserEntity, BinarySensorEntity):
"""Representation of a diffuser battery charging binary sensor."""

_attr_device_class = DEVICE_CLASS_BATTERY_CHARGING
_attr_entity_category = ENTITY_CATEGORY_DIAGNOSTIC

def __init__(
self, diffuser: Diffuser, coordinator: RitualsDataUpdateCoordinator
Expand Down
3 changes: 2 additions & 1 deletion homeassistant/components/rituals_perfume_genie/select.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

from homeassistant.components.select import SelectEntity
from homeassistant.config_entries import ConfigEntry
from homeassistant.const import AREA_SQUARE_METERS
from homeassistant.const import AREA_SQUARE_METERS, ENTITY_CATEGORY_CONFIG
from homeassistant.core import HomeAssistant
from homeassistant.helpers.entity_platform import AddEntitiesCallback

Expand Down Expand Up @@ -36,6 +36,7 @@ class DiffuserRoomSize(DiffuserEntity, SelectEntity):
_attr_icon = "mdi:ruler-square"
_attr_unit_of_measurement = AREA_SQUARE_METERS
_attr_options = ["15", "30", "60", "100"]
_attr_entity_category = ENTITY_CATEGORY_CONFIG

def __init__(
self, diffuser: Diffuser, coordinator: RitualsDataUpdateCoordinator
Expand Down
3 changes: 3 additions & 0 deletions homeassistant/components/rituals_perfume_genie/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
from homeassistant.const import (
DEVICE_CLASS_BATTERY,
DEVICE_CLASS_SIGNAL_STRENGTH,
ENTITY_CATEGORY_DIAGNOSTIC,
PERCENTAGE,
)
from homeassistant.core import HomeAssistant
Expand Down Expand Up @@ -92,6 +93,7 @@ class DiffuserBatterySensor(DiffuserEntity, SensorEntity):

_attr_device_class = DEVICE_CLASS_BATTERY
_attr_native_unit_of_measurement = PERCENTAGE
_attr_entity_category = ENTITY_CATEGORY_DIAGNOSTIC

def __init__(
self, diffuser: Diffuser, coordinator: RitualsDataUpdateCoordinator
Expand All @@ -110,6 +112,7 @@ class DiffuserWifiSensor(DiffuserEntity, SensorEntity):

_attr_device_class = DEVICE_CLASS_SIGNAL_STRENGTH
_attr_native_unit_of_measurement = PERCENTAGE
_attr_entity_category = ENTITY_CATEGORY_DIAGNOSTIC

def __init__(
self, diffuser: Diffuser, coordinator: RitualsDataUpdateCoordinator
Expand Down
3 changes: 2 additions & 1 deletion tests/components/rituals_perfume_genie/test_binary_sensor.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""Tests for the Rituals Perfume Genie binary sensor platform."""
from homeassistant.components.binary_sensor import DEVICE_CLASS_BATTERY_CHARGING
from homeassistant.components.rituals_perfume_genie.binary_sensor import CHARGING_SUFFIX
from homeassistant.const import ATTR_DEVICE_CLASS, STATE_ON
from homeassistant.const import ATTR_DEVICE_CLASS, ENTITY_CATEGORY_DIAGNOSTIC, STATE_ON
from homeassistant.core import HomeAssistant
from homeassistant.helpers import entity_registry

Expand All @@ -28,3 +28,4 @@ async def test_binary_sensors(hass: HomeAssistant) -> None:
entry = registry.async_get("binary_sensor.genie_battery_charging")
assert entry
assert entry.unique_id == f"{hublot}{CHARGING_SUFFIX}"
assert entry.entity_category == ENTITY_CATEGORY_DIAGNOSTIC
2 changes: 2 additions & 0 deletions tests/components/rituals_perfume_genie/test_select.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
AREA_SQUARE_METERS,
ATTR_ENTITY_ID,
ATTR_ICON,
ENTITY_CATEGORY_CONFIG,
SERVICE_SELECT_OPTION,
)
from homeassistant.core import HomeAssistant
Expand Down Expand Up @@ -36,6 +37,7 @@ async def test_select_entity(hass: HomeAssistant) -> None:
assert entry
assert entry.unique_id == f"{diffuser.hublot}{ROOM_SIZE_SUFFIX}"
assert entry.unit_of_measurement == AREA_SQUARE_METERS
assert entry.entity_category == ENTITY_CATEGORY_CONFIG


async def test_select_option(hass: HomeAssistant) -> None:
Expand Down
3 changes: 3 additions & 0 deletions tests/components/rituals_perfume_genie/test_sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
ATTR_UNIT_OF_MEASUREMENT,
DEVICE_CLASS_BATTERY,
DEVICE_CLASS_SIGNAL_STRENGTH,
ENTITY_CATEGORY_DIAGNOSTIC,
PERCENTAGE,
)
from homeassistant.core import HomeAssistant
Expand Down Expand Up @@ -59,6 +60,7 @@ async def test_sensors_diffuser_v1_battery_cartridge(hass: HomeAssistant) -> Non
entry = registry.async_get("sensor.genie_battery")
assert entry
assert entry.unique_id == f"{hublot}{BATTERY_SUFFIX}"
assert entry.entity_category == ENTITY_CATEGORY_DIAGNOSTIC

state = hass.states.get("sensor.genie_wifi")
assert state
Expand All @@ -69,6 +71,7 @@ async def test_sensors_diffuser_v1_battery_cartridge(hass: HomeAssistant) -> Non
entry = registry.async_get("sensor.genie_wifi")
assert entry
assert entry.unique_id == f"{hublot}{WIFI_SUFFIX}"
assert entry.entity_category == ENTITY_CATEGORY_DIAGNOSTIC


async def test_sensors_diffuser_v2_no_battery_no_cartridge(hass: HomeAssistant) -> None:
Expand Down

0 comments on commit f8501de

Please sign in to comment.