mirror of
https://github.com/home-assistant/core.git
synced 2025-07-21 12:17:07 +00:00
Add support for Glances v4 (#117664)
This commit is contained in:
parent
0112c7fcfd
commit
0c37a065ad
@ -73,7 +73,7 @@ async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
|
|||||||
async def get_api(hass: HomeAssistant, entry_data: dict[str, Any]) -> Glances:
|
async def get_api(hass: HomeAssistant, entry_data: dict[str, Any]) -> Glances:
|
||||||
"""Return the api from glances_api."""
|
"""Return the api from glances_api."""
|
||||||
httpx_client = get_async_client(hass, verify_ssl=entry_data[CONF_VERIFY_SSL])
|
httpx_client = get_async_client(hass, verify_ssl=entry_data[CONF_VERIFY_SSL])
|
||||||
for version in (3, 2):
|
for version in (4, 3, 2):
|
||||||
api = Glances(
|
api = Glances(
|
||||||
host=entry_data[CONF_HOST],
|
host=entry_data[CONF_HOST],
|
||||||
port=entry_data[CONF_PORT],
|
port=entry_data[CONF_PORT],
|
||||||
@ -100,7 +100,7 @@ async def get_api(hass: HomeAssistant, entry_data: dict[str, Any]) -> Glances:
|
|||||||
)
|
)
|
||||||
_LOGGER.debug("Connected to Glances API v%s", version)
|
_LOGGER.debug("Connected to Glances API v%s", version)
|
||||||
return api
|
return api
|
||||||
raise ServerVersionMismatch("Could not connect to Glances API version 2 or 3")
|
raise ServerVersionMismatch("Could not connect to Glances API version 2, 3 or 4")
|
||||||
|
|
||||||
|
|
||||||
class ServerVersionMismatch(HomeAssistantError):
|
class ServerVersionMismatch(HomeAssistantError):
|
||||||
|
@ -6,5 +6,5 @@
|
|||||||
"documentation": "https://www.home-assistant.io/integrations/glances",
|
"documentation": "https://www.home-assistant.io/integrations/glances",
|
||||||
"iot_class": "local_polling",
|
"iot_class": "local_polling",
|
||||||
"loggers": ["glances_api"],
|
"loggers": ["glances_api"],
|
||||||
"requirements": ["glances-api==0.6.0"]
|
"requirements": ["glances-api==0.7.0"]
|
||||||
}
|
}
|
||||||
|
@ -949,7 +949,7 @@ gios==4.0.0
|
|||||||
gitterpy==0.1.7
|
gitterpy==0.1.7
|
||||||
|
|
||||||
# homeassistant.components.glances
|
# homeassistant.components.glances
|
||||||
glances-api==0.6.0
|
glances-api==0.7.0
|
||||||
|
|
||||||
# homeassistant.components.goalzero
|
# homeassistant.components.goalzero
|
||||||
goalzero==0.2.2
|
goalzero==0.2.2
|
||||||
|
@ -778,7 +778,7 @@ getmac==0.9.4
|
|||||||
gios==4.0.0
|
gios==4.0.0
|
||||||
|
|
||||||
# homeassistant.components.glances
|
# homeassistant.components.glances
|
||||||
glances-api==0.6.0
|
glances-api==0.7.0
|
||||||
|
|
||||||
# homeassistant.components.goalzero
|
# homeassistant.components.goalzero
|
||||||
goalzero==0.2.2
|
goalzero==0.2.2
|
||||||
|
@ -38,8 +38,9 @@ async def test_entry_deprecated_version(
|
|||||||
entry.add_to_hass(hass)
|
entry.add_to_hass(hass)
|
||||||
|
|
||||||
mock_api.return_value.get_ha_sensor_data.side_effect = [
|
mock_api.return_value.get_ha_sensor_data.side_effect = [
|
||||||
GlancesApiNoDataAvailable("endpoint: 'all' is not valid"),
|
GlancesApiNoDataAvailable("endpoint: 'all' is not valid"), # fail v4
|
||||||
HA_SENSOR_DATA,
|
GlancesApiNoDataAvailable("endpoint: 'all' is not valid"), # fail v3
|
||||||
|
HA_SENSOR_DATA, # success v2
|
||||||
HA_SENSOR_DATA,
|
HA_SENSOR_DATA,
|
||||||
]
|
]
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user