mirror of
https://github.com/home-assistant/core.git
synced 2025-11-12 20:40:18 +00:00
spaceapi: fix sensor values (#132099)
This commit is contained in:
@@ -6,7 +6,12 @@ from unittest.mock import patch
|
||||
from aiohttp.test_utils import TestClient
|
||||
import pytest
|
||||
|
||||
from homeassistant.components.spaceapi import DOMAIN, SPACEAPI_VERSION, URL_API_SPACEAPI
|
||||
from homeassistant.components.spaceapi import (
|
||||
ATTR_SENSOR_LOCATION,
|
||||
DOMAIN,
|
||||
SPACEAPI_VERSION,
|
||||
URL_API_SPACEAPI,
|
||||
)
|
||||
from homeassistant.const import ATTR_UNIT_OF_MEASUREMENT, PERCENTAGE, UnitOfTemperature
|
||||
from homeassistant.core import HomeAssistant
|
||||
from homeassistant.setup import async_setup_component
|
||||
@@ -27,7 +32,7 @@ CONFIG = {
|
||||
"icon_closed": "https://home-assistant.io/close.png",
|
||||
},
|
||||
"sensors": {
|
||||
"temperature": ["test.temp1", "test.temp2"],
|
||||
"temperature": ["test.temp1", "test.temp2", "test.temp3"],
|
||||
"humidity": ["test.hum1"],
|
||||
},
|
||||
"spacefed": {"spacenet": True, "spacesaml": False, "spacephone": True},
|
||||
@@ -67,17 +72,23 @@ SENSOR_OUTPUT = {
|
||||
"location": "Home",
|
||||
"name": "temp1",
|
||||
"unit": UnitOfTemperature.CELSIUS,
|
||||
"value": "25",
|
||||
"value": 25.0,
|
||||
},
|
||||
{
|
||||
"location": "outside",
|
||||
"name": "temp2",
|
||||
"unit": UnitOfTemperature.CELSIUS,
|
||||
"value": 23.0,
|
||||
},
|
||||
{
|
||||
"location": "Home",
|
||||
"name": "temp2",
|
||||
"name": "temp3",
|
||||
"unit": UnitOfTemperature.CELSIUS,
|
||||
"value": "23",
|
||||
"value": None,
|
||||
},
|
||||
],
|
||||
"humidity": [
|
||||
{"location": "Home", "name": "hum1", "unit": PERCENTAGE, "value": "88"}
|
||||
{"location": "Home", "name": "hum1", "unit": PERCENTAGE, "value": 88.0}
|
||||
],
|
||||
}
|
||||
|
||||
@@ -96,6 +107,19 @@ def mock_client(hass: HomeAssistant, hass_client: ClientSessionGenerator) -> Tes
|
||||
hass.states.async_set(
|
||||
"test.temp2",
|
||||
23,
|
||||
attributes={
|
||||
ATTR_UNIT_OF_MEASUREMENT: UnitOfTemperature.CELSIUS,
|
||||
ATTR_SENSOR_LOCATION: "outside",
|
||||
},
|
||||
)
|
||||
hass.states.async_set(
|
||||
"test.temp3",
|
||||
"foo",
|
||||
attributes={ATTR_UNIT_OF_MEASUREMENT: UnitOfTemperature.CELSIUS},
|
||||
)
|
||||
hass.states.async_set(
|
||||
"test.temp3",
|
||||
"foo",
|
||||
attributes={ATTR_UNIT_OF_MEASUREMENT: UnitOfTemperature.CELSIUS},
|
||||
)
|
||||
hass.states.async_set(
|
||||
|
||||
Reference in New Issue
Block a user