Merge cf0938a6fd into 99d25bfd56
commit
2db0c27d68
|
|
@ -63,6 +63,7 @@ OUTSIDE_TEMP: Final = "outside_temp"
|
||||||
DEW_POINT: Final = "dew_point"
|
DEW_POINT: Final = "dew_point"
|
||||||
OUTSIDE_HUMIDITY: Final = "outside_humidity"
|
OUTSIDE_HUMIDITY: Final = "outside_humidity"
|
||||||
OUTSIDE_CONNECTION: Final = "outside_connection"
|
OUTSIDE_CONNECTION: Final = "outside_connection"
|
||||||
|
OUTSIDE_BATTERY: Final = "outside_battery"
|
||||||
WIND_SPEED: Final = "wind_speed"
|
WIND_SPEED: Final = "wind_speed"
|
||||||
WIND_GUST: Final = "wind_gust"
|
WIND_GUST: Final = "wind_gust"
|
||||||
WIND_DIR: Final = "wind_dir"
|
WIND_DIR: Final = "wind_dir"
|
||||||
|
|
@ -137,6 +138,7 @@ REMAP_WSLINK_ITEMS: dict = {
|
||||||
"t1rainwy": WEEKLY_RAIN,
|
"t1rainwy": WEEKLY_RAIN,
|
||||||
"t1rainmth": MONTHLY_RAIN,
|
"t1rainmth": MONTHLY_RAIN,
|
||||||
"t1rainyr": YEARLY_RAIN,
|
"t1rainyr": YEARLY_RAIN,
|
||||||
|
"t1bat": OUTSIDE_BATTERY,
|
||||||
}
|
}
|
||||||
|
|
||||||
# TODO: Add more sensors
|
# TODO: Add more sensors
|
||||||
|
|
@ -177,6 +179,26 @@ class UnitOfDir(StrEnum):
|
||||||
N = "n"
|
N = "n"
|
||||||
|
|
||||||
|
|
||||||
|
class UnitOfDir(StrEnum):
|
||||||
|
"""Wind direrction azimut."""
|
||||||
|
|
||||||
|
NNE = "nne"
|
||||||
|
NE = "ne"
|
||||||
|
ENE = "ene"
|
||||||
|
E = "e"
|
||||||
|
ESE = "ese"
|
||||||
|
SE = "se"
|
||||||
|
SSE = "sse"
|
||||||
|
S = "s"
|
||||||
|
SSW = "ssw"
|
||||||
|
SW = "sw"
|
||||||
|
WSW = "wsw"
|
||||||
|
W = "w"
|
||||||
|
WNW = "wnw"
|
||||||
|
NW = "nw"
|
||||||
|
NNW = "nnw"
|
||||||
|
N = "n"
|
||||||
|
|
||||||
AZIMUT: list[UnitOfDir] = [
|
AZIMUT: list[UnitOfDir] = [
|
||||||
UnitOfDir.NNE,
|
UnitOfDir.NNE,
|
||||||
UnitOfDir.NE,
|
UnitOfDir.NE,
|
||||||
|
|
@ -195,3 +217,14 @@ AZIMUT: list[UnitOfDir] = [
|
||||||
UnitOfDir.NNW,
|
UnitOfDir.NNW,
|
||||||
UnitOfDir.N,
|
UnitOfDir.N,
|
||||||
]
|
]
|
||||||
|
|
||||||
|
class UnitOfBat(StrEnum):
|
||||||
|
"""Battery level unit of measure."""
|
||||||
|
|
||||||
|
LOW = "low"
|
||||||
|
NORMAL = "normal"
|
||||||
|
|
||||||
|
BATLEVEL: list[UnitOfBat] = [
|
||||||
|
UnitOfBat.LOW,
|
||||||
|
UnitOfBat.NORMAL,
|
||||||
|
]
|
||||||
|
|
|
||||||
|
|
@ -29,6 +29,7 @@ from .const import (
|
||||||
HEAT_INDEX,
|
HEAT_INDEX,
|
||||||
INDOOR_HUMIDITY,
|
INDOOR_HUMIDITY,
|
||||||
INDOOR_TEMP,
|
INDOOR_TEMP,
|
||||||
|
OUTSIDE_BATTERY,
|
||||||
OUTSIDE_HUMIDITY,
|
OUTSIDE_HUMIDITY,
|
||||||
OUTSIDE_TEMP,
|
OUTSIDE_TEMP,
|
||||||
RAIN,
|
RAIN,
|
||||||
|
|
@ -45,7 +46,7 @@ from .const import (
|
||||||
WEEKLY_RAIN,
|
WEEKLY_RAIN,
|
||||||
)
|
)
|
||||||
from .sensors_common import WeatherSensorEntityDescription
|
from .sensors_common import WeatherSensorEntityDescription
|
||||||
from .utils import wind_dir_to_text
|
from .utils import battery_level_to_text, wind_dir_to_text
|
||||||
|
|
||||||
SENSOR_TYPES_WSLINK: tuple[WeatherSensorEntityDescription, ...] = (
|
SENSOR_TYPES_WSLINK: tuple[WeatherSensorEntityDescription, ...] = (
|
||||||
WeatherSensorEntityDescription(
|
WeatherSensorEntityDescription(
|
||||||
|
|
@ -303,4 +304,12 @@ SENSOR_TYPES_WSLINK: tuple[WeatherSensorEntityDescription, ...] = (
|
||||||
translation_key=CHILL_INDEX,
|
translation_key=CHILL_INDEX,
|
||||||
value_fn=lambda data: cast("int", data),
|
value_fn=lambda data: cast("int", data),
|
||||||
),
|
),
|
||||||
|
WeatherSensorEntityDescription(
|
||||||
|
key=OUTSIDE_BATTERY,
|
||||||
|
name="Outside Battery",
|
||||||
|
icon="mdi:battery",
|
||||||
|
device_class=SensorDeviceClass.ENUM,
|
||||||
|
value_fn=lambda data: battery_level_to_text(int(data)) if data is not None and str(data).isdigit() else "unknown",
|
||||||
|
translation_key=OUTSIDE_BATTERY,
|
||||||
|
),
|
||||||
)
|
)
|
||||||
|
|
|
||||||
|
|
@ -135,6 +135,7 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"outside_battery": { "name": "Outside battery level" },
|
||||||
"notify": {
|
"notify": {
|
||||||
"added": {
|
"added": {
|
||||||
"title": "New sensors for SWS 12500 found.",
|
"title": "New sensors for SWS 12500 found.",
|
||||||
|
|
|
||||||
|
|
@ -139,6 +139,7 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"outside_battery": { "name": "Vnější úroveň nabití baterie" },
|
||||||
"notify": {
|
"notify": {
|
||||||
"added": {
|
"added": {
|
||||||
"title": "Nalezeny nové senzory pro SWS 12500.",
|
"title": "Nalezeny nové senzory pro SWS 12500.",
|
||||||
|
|
|
||||||
|
|
@ -136,7 +136,8 @@
|
||||||
"nw": "NW",
|
"nw": "NW",
|
||||||
"nnw": "NNW"
|
"nnw": "NNW"
|
||||||
}
|
}
|
||||||
}
|
},
|
||||||
|
"outside_battery": { "name": "Outside battery level" }
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"notify": {
|
"notify": {
|
||||||
|
|
|
||||||
|
|
@ -20,6 +20,7 @@ from homeassistant.helpers.translation import async_get_translations
|
||||||
|
|
||||||
from .const import (
|
from .const import (
|
||||||
AZIMUT,
|
AZIMUT,
|
||||||
|
BATLEVEL,
|
||||||
DATABASE_PATH,
|
DATABASE_PATH,
|
||||||
DEV_DBG,
|
DEV_DBG,
|
||||||
OUTSIDE_HUMIDITY,
|
OUTSIDE_HUMIDITY,
|
||||||
|
|
@ -180,7 +181,19 @@ def wind_dir_to_text(deg: float) -> UnitOfDir | None:
|
||||||
|
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
def battery_level_to_text(battery: int) -> str:
|
||||||
|
"""Return battery level in text representation.
|
||||||
|
|
||||||
|
Returns UnitOfBat or None
|
||||||
|
"""
|
||||||
|
if battery is None:
|
||||||
|
return "unknown"
|
||||||
|
|
||||||
|
if battery is 0:
|
||||||
|
return BATLEVEL[battery]
|
||||||
|
elif battery is 1:
|
||||||
|
return BATLEVEL[battery]
|
||||||
|
|
||||||
def fahrenheit_to_celsius(fahrenheit: float) -> float:
|
def fahrenheit_to_celsius(fahrenheit: float) -> float:
|
||||||
"""Convert Fahrenheit to Celsius."""
|
"""Convert Fahrenheit to Celsius."""
|
||||||
return (fahrenheit - 32) * 5.0 / 9.0
|
return (fahrenheit - 32) * 5.0 / 9.0
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue