Skip to content

Commit

Permalink
Removed windrose with 16 cardinal directions. Windrose has now only 8…
Browse files Browse the repository at this point in the history
… cardinal directions. Also added dynamic icons for windrose and barometric trend.
  • Loading branch information
MarcoGos committed Feb 14, 2024
1 parent 0d0c1d1 commit dc28279
Show file tree
Hide file tree
Showing 12 changed files with 828 additions and 608 deletions.
2 changes: 0 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -141,8 +141,6 @@ Diagnostic entities:
- Last fetch time
- Battery Voltage:
- Current battery voltage
- Cardinal Directions:
- Number of cardinal direction 8 or 16 (set during setup)
- Last Error Time:
- Last error time
- Last Success Time:
Expand Down
4 changes: 1 addition & 3 deletions custom_components/davis_vantage/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
CONFIG_RAIN_COLLECTOR,
CONFIG_STATION_MODEL,
CONFIG_INTERVAL,
CONFIG_WINDROSE8,
CONFIG_PROTOCOL,
CONFIG_LINK
)
Expand All @@ -49,11 +48,10 @@ async def async_setup_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
protocol = entry.data.get(CONFIG_PROTOCOL, "")
link = entry.data.get(CONFIG_LINK, "")
rain_collector = entry.data.get(CONFIG_RAIN_COLLECTOR, RAIN_COLLECTOR_IMPERIAL)
windrose8 = entry.data.get(CONFIG_WINDROSE8, False)

hass.data[DOMAIN]['interval'] = entry.data.get(CONFIG_INTERVAL, 30)

client = DavisVantageClient(hass, protocol, link, rain_collector, windrose8)
client = DavisVantageClient(hass, protocol, link, rain_collector)
await client.connect_to_station()
info = await client.async_get_info()
firmware_version = info.get('version', None) if info is not None else None
Expand Down
7 changes: 2 additions & 5 deletions custom_components/davis_vantage/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,11 @@ def __init__(
hass: HomeAssistant,
protocol: str,
link: str,
rain_collector: str,
windrose8: bool,
rain_collector: str
) -> None:
self._hass = hass
self._protocol = protocol
self._link = link
self._windrose8 = windrose8
self._rain_collector = rain_collector
self._last_data: LoopDataParserRevB = {} # type: ignore
self._last_raw_data: DataParser = {} # type: ignore
Expand Down Expand Up @@ -244,7 +242,7 @@ def add_additional_info(self, data: dict[str, Any]) -> None:
data["TempOut"], data["HumOut"], data["WindSpeed"]
)
if data["WindDir"] is not None:
data["WindDirRose"] = get_wind_rose(data["WindDir"], self._windrose8)
data["WindDirRose"] = get_wind_rose(data["WindDir"])
if data["WindSpeed10Min"] is not None:
data["WindSpeedBft"] = convert_kmh_to_bft(
convert_to_kmh(data["WindSpeed10Min"])
Expand All @@ -264,7 +262,6 @@ def convert_values(self, data: dict[str, Any]) -> None:
if data["ForecastRuleNo"] is not None:
data["ForecastRuleNo"] = get_forecast_string(data["ForecastRuleNo"])
data["RainCollector"] = self._rain_collector
data["WindRoseSetup"] = 8 if self._windrose8 else 16
if data["RainCollector"] != RAIN_COLLECTOR_IMPERIAL:
self.correct_rain_values(data)
data['StormStartDate'] = self.strtodate(data['StormStartDate'])
Expand Down
6 changes: 2 additions & 4 deletions custom_components/davis_vantage/config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
CONFIG_RAIN_COLLECTOR,
CONFIG_STATION_MODEL,
CONFIG_INTERVAL,
CONFIG_WINDROSE8,
CONFIG_PROTOCOL,
CONFIG_LINK
)
Expand All @@ -45,7 +44,7 @@ def __init__(self, hass: HomeAssistant) -> None:
async def authenticate(self, protocol: str, link: str) -> bool:
"""Test if we can find data for the given link."""
_LOGGER.info(f"authenticate called")
client = DavisVantageClient(self._hass, protocol, link, "", False)
client = DavisVantageClient(self._hass, protocol, link, "")
await client.connect_to_station()
return await client.async_get_davis_time() != None

Expand Down Expand Up @@ -160,8 +159,7 @@ async def async_step_setup_other_info(
CONFIG_INTERVAL,
default=DEFAULT_SYNC_INTERVAL): vol.All(int, vol.Range(min=30) # type: ignore
),
vol.Required(CONFIG_RAIN_COLLECTOR): vol.In(list_of_rain_collector),
vol.Required(CONFIG_WINDROSE8): bool,
vol.Required(CONFIG_RAIN_COLLECTOR): vol.In(list_of_rain_collector)
}
)

Expand Down
3 changes: 1 addition & 2 deletions custom_components/davis_vantage/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
DOMAIN = "davis_vantage"
MANUFACTURER = "Davis"
MODEL = "Vantage Pro2/Vue"
VERSION = "1.1.8"
VERSION = "1.1.9"

DEFAULT_SYNC_INTERVAL = 30 # seconds
DEFAULT_NAME = NAME
Expand All @@ -27,6 +27,5 @@
CONFIG_RAIN_COLLECTOR = "rain_collector"
CONFIG_STATION_MODEL = "station_model"
CONFIG_INTERVAL = "interval"
CONFIG_WINDROSE8 = "windrose8"
CONFIG_PROTOCOL = "protocol"
CONFIG_LINK = "link"
39 changes: 33 additions & 6 deletions custom_components/davis_vantage/icons.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,35 @@
{
"services": {
"set_davis_time": "mdi:clock-edit-outline",
"get_davis_time": "mdi:clock-outline",
"get_raw_data": "mdi:export",
"get_info": "mdi:information-box-outline"
"services": {
"set_davis_time": "mdi:clock-edit-outline",
"get_davis_time": "mdi:clock-outline",
"get_raw_data": "mdi:export",
"get_info": "mdi:information-box-outline"
},
"entity": {
"sensor": {
"davis_vantage_barometric_trend": {
"default": "mdi:trending-neutral",
"state": {
"falling_rapidly": "mdi:trending-down",
"falling_slowly": "mdi:trending-down",
"steady": "mdi:trending-neutral",
"rising_slowly": "mdi:trending-up",
"rising_rapidly": "mdi:trending-up"
}
},
"wind_direction_rose": {
"default": "mdi:compass-outline",
"state": {
"N": "mdi:arrow-down-bold-outline",
"NE": "mdi:arrow-bottom-left-bold-outline",
"E": "mdi:arrow-left-bold-outline",
"SE": "mdi:arrow-top-left-bold-outline",
"S": "mdi:arrow-up-bold-outline",
"SW": "mdi:arrow-top-right-bold-outline",
"W": "mdi:arrow-right-bold-outline",
"NW": "mdi:arrow-bottom-right-bold-outline"
}
}
}
}
}
}
Loading

0 comments on commit dc28279

Please sign in to comment.