Use enum sensor device class in UptimeRobot (#83111)
parent
c7a6b5983f
commit
40d337479e
|
@ -3,7 +3,11 @@ from __future__ import annotations
|
|||
|
||||
from typing import TypedDict
|
||||
|
||||
from homeassistant.components.sensor import SensorEntity, SensorEntityDescription
|
||||
from homeassistant.components.sensor import (
|
||||
SensorDeviceClass,
|
||||
SensorEntity,
|
||||
SensorEntityDescription,
|
||||
)
|
||||
from homeassistant.config_entries import ConfigEntry
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.helpers.entity import EntityCategory
|
||||
|
@ -44,7 +48,9 @@ async def async_setup_entry(
|
|||
key=str(monitor.id),
|
||||
name=monitor.friendly_name,
|
||||
entity_category=EntityCategory.DIAGNOSTIC,
|
||||
device_class="uptimerobot__monitor_status",
|
||||
device_class=SensorDeviceClass.ENUM,
|
||||
options=["down", "not_checked_yet", "pause", "seems_down", "up"],
|
||||
translation_key="monitor_status",
|
||||
),
|
||||
monitor=monitor,
|
||||
)
|
||||
|
|
|
@ -28,5 +28,18 @@
|
|||
"reauth_failed_existing": "Could not update the config entry, please remove the integration and set it up again.",
|
||||
"unknown": "[%key:common::config_flow::error::unknown%]"
|
||||
}
|
||||
},
|
||||
"entity": {
|
||||
"sensor": {
|
||||
"monitor_status": {
|
||||
"state": {
|
||||
"down": "Down",
|
||||
"not_checked_yet": "Not checked yet",
|
||||
"pause": "Pause",
|
||||
"seems_down": "Seems down",
|
||||
"up": "Up"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,11 +0,0 @@
|
|||
{
|
||||
"state": {
|
||||
"uptimerobot__monitor_status": {
|
||||
"pause": "Pause",
|
||||
"not_checked_yet": "Not checked yet",
|
||||
"up": "Up",
|
||||
"seems_down": "Seems down",
|
||||
"down": "Down"
|
||||
}
|
||||
}
|
||||
}
|
|
@ -28,5 +28,18 @@
|
|||
"description": "You need to supply the 'main' API key from UptimeRobot"
|
||||
}
|
||||
}
|
||||
},
|
||||
"entity": {
|
||||
"sensor": {
|
||||
"monitor_status": {
|
||||
"state": {
|
||||
"down": "Down",
|
||||
"not_checked_yet": "Not checked yet",
|
||||
"pause": "Pause",
|
||||
"seems_down": "Seems down",
|
||||
"up": "Up"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -4,6 +4,7 @@ from unittest.mock import patch
|
|||
|
||||
from pyuptimerobot import UptimeRobotAuthenticationException
|
||||
|
||||
from homeassistant.components.sensor import SensorDeviceClass
|
||||
from homeassistant.components.uptimerobot.const import COORDINATOR_UPDATE_INTERVAL
|
||||
from homeassistant.const import STATE_UNAVAILABLE
|
||||
from homeassistant.core import HomeAssistant
|
||||
|
@ -30,6 +31,14 @@ async def test_presentation(hass: HomeAssistant) -> None:
|
|||
assert entity.state == STATE_UP
|
||||
assert entity.attributes["icon"] == SENSOR_ICON
|
||||
assert entity.attributes["target"] == MOCK_UPTIMEROBOT_MONITOR["url"]
|
||||
assert entity.attributes["device_class"] == SensorDeviceClass.ENUM
|
||||
assert entity.attributes["options"] == [
|
||||
"down",
|
||||
"not_checked_yet",
|
||||
"pause",
|
||||
"seems_down",
|
||||
"up",
|
||||
]
|
||||
|
||||
|
||||
async def test_unaviable_on_update_failure(hass: HomeAssistant) -> None:
|
||||
|
|
Loading…
Reference in New Issue