Compare commits

...

4 Commits

Author SHA1 Message Date
schizza e11e068c0f Reorders constants for better readability
Reorders the import of constants to improve readability and maintain consistency within the module.

Final touches.
2025-08-18 13:29:00 +02:00
schizza 1ecd88269d Adds missing constant and improves readability
Adds OUTSIDE_BATTERY to the DISABLED_BY_DEFAULT list.
Improves readability by formatting long strings with parenthesis.
2025-08-18 12:53:40 +02:00
schizza 09d79e2032 Improves battery sensor display
Updates the outside battery sensor to display an icon
reflecting the battery level, enhancing the user experience
by providing a visual indication of the battery status.
2025-08-18 12:50:31 +02:00
schizza bbe31da4c5 Adds battery state translations
Adds translations for the battery state of the outside sensor to both the English and Czech language files.

This change provides more descriptive and user-friendly information about the battery status.
2025-08-18 10:55:37 +02:00
5 changed files with 42 additions and 14 deletions

View File

@ -23,8 +23,12 @@ WSLINK: Final = "wslink"
WINDY_API_KEY = "WINDY_API_KEY" WINDY_API_KEY = "WINDY_API_KEY"
WINDY_ENABLED: Final = "windy_enabled_checkbox" WINDY_ENABLED: Final = "windy_enabled_checkbox"
WINDY_LOGGER_ENABLED: Final = "windy_logger_checkbox" WINDY_LOGGER_ENABLED: Final = "windy_logger_checkbox"
WINDY_NOT_INSERTED: Final = "Data was succefuly sent to Windy, but not inserted by Windy API. Does anyone else sent data to Windy?" WINDY_NOT_INSERTED: Final = (
WINDY_INVALID_KEY: Final = "Windy API KEY is invalid. Send data to Windy is now disabled. Check your API KEY and try again." "Data was succefuly sent to Windy, but not inserted by Windy API. Does anyone else sent data to Windy?"
)
WINDY_INVALID_KEY: Final = (
"Windy API KEY is invalid. Send data to Windy is now disabled. Check your API KEY and try again."
)
WINDY_SUCCESS: Final = ( WINDY_SUCCESS: Final = (
"Windy successfully sent data and data was successfully inserted by Windy API" "Windy successfully sent data and data was successfully inserted by Windy API"
) )
@ -155,6 +159,7 @@ DISABLED_BY_DEFAULT: Final = [
CH3_HUMIDITY, CH3_HUMIDITY,
CH4_TEMP, CH4_TEMP,
CH4_HUMIDITY, CH4_HUMIDITY,
OUTSIDE_BATTERY,
] ]
@ -178,6 +183,7 @@ class UnitOfDir(StrEnum):
NNW = "nnw" NNW = "nnw"
N = "n" N = "n"
AZIMUT: list[UnitOfDir] = [ AZIMUT: list[UnitOfDir] = [
UnitOfDir.NNE, UnitOfDir.NNE,
UnitOfDir.NE, UnitOfDir.NE,
@ -197,6 +203,7 @@ AZIMUT: list[UnitOfDir] = [
UnitOfDir.N, UnitOfDir.N,
] ]
class UnitOfBat(StrEnum): class UnitOfBat(StrEnum):
"""Battery level unit of measure.""" """Battery level unit of measure."""
@ -204,6 +211,7 @@ class UnitOfBat(StrEnum):
NORMAL = "normal" NORMAL = "normal"
UNKNOWN = "unknown" UNKNOWN = "unknown"
BATTERY_LEVEL: list[UnitOfBat] = [ BATTERY_LEVEL: list[UnitOfBat] = [
UnitOfBat.LOW, UnitOfBat.LOW,
UnitOfBat.NORMAL, UnitOfBat.NORMAL,

View File

@ -27,26 +27,26 @@ from .const import (
DAILY_RAIN, DAILY_RAIN,
DEW_POINT, DEW_POINT,
HEAT_INDEX, HEAT_INDEX,
HOURLY_RAIN,
INDOOR_HUMIDITY, INDOOR_HUMIDITY,
INDOOR_TEMP, INDOOR_TEMP,
MONTHLY_RAIN,
OUTSIDE_BATTERY, OUTSIDE_BATTERY,
OUTSIDE_HUMIDITY, OUTSIDE_HUMIDITY,
OUTSIDE_TEMP, OUTSIDE_TEMP,
RAIN, RAIN,
SOLAR_RADIATION, SOLAR_RADIATION,
UV, UV,
WEEKLY_RAIN,
WIND_AZIMUT, WIND_AZIMUT,
WIND_DIR, WIND_DIR,
WIND_GUST, WIND_GUST,
WIND_SPEED, WIND_SPEED,
UnitOfDir,
MONTHLY_RAIN,
YEARLY_RAIN, YEARLY_RAIN,
HOURLY_RAIN, UnitOfDir,
WEEKLY_RAIN,
) )
from .sensors_common import WeatherSensorEntityDescription from .sensors_common import WeatherSensorEntityDescription
from .utils import battery_level_to_text, wind_dir_to_text from .utils import battery_level_to_icon, battery_level_to_text, wind_dir_to_text
SENSOR_TYPES_WSLINK: tuple[WeatherSensorEntityDescription, ...] = ( SENSOR_TYPES_WSLINK: tuple[WeatherSensorEntityDescription, ...] = (
WeatherSensorEntityDescription( WeatherSensorEntityDescription(
@ -306,10 +306,9 @@ SENSOR_TYPES_WSLINK: tuple[WeatherSensorEntityDescription, ...] = (
), ),
WeatherSensorEntityDescription( WeatherSensorEntityDescription(
key=OUTSIDE_BATTERY, 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, translation_key=OUTSIDE_BATTERY,
icon=lambda data: battery_level_to_icon(battery_level_to_text(int(data))),
device_class=SensorDeviceClass.ENUM,
value_fn=lambda data: battery_level_to_text(int(data)),
), ),
) )

View File

@ -131,11 +131,18 @@
"wnw": "WNW", "wnw": "WNW",
"nw": "NW", "nw": "NW",
"nnw": "NNW" "nnw": "NNW"
},
"outside_battery": {
"name": "Outside battery level",
"state": {
"normal": "OK",
"low": "Low",
"unknown": "Unknown / drained out"
}
} }
} }
} }
}, },
"outside_battery": { "name": "Outside battery level" },
"notify": { "notify": {
"added": { "added": {
"title": "New sensors for SWS 12500 found.", "title": "New sensors for SWS 12500 found.",

View File

@ -136,10 +136,17 @@
"nw": "SZ", "nw": "SZ",
"nnw": "SSZ" "nnw": "SSZ"
} }
},
"outside_battery": {
"name": "Stav nabití venkovní baterie",
"state": {
"low": "Nízká",
"normal": "Normální",
"unknown": "Neznámá / zcela vybitá"
}
} }
} }
}, },
"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.",

View File

@ -137,7 +137,14 @@
"nnw": "NNW" "nnw": "NNW"
} }
}, },
"outside_battery": { "name": "Outside battery level" } "outside_battery": {
"name": "Outside battery level",
"state": {
"normal": "OK",
"low": "Low",
"unknown": "Unknown / drained out"
}
}
} }
}, },
"notify": { "notify": {