Skip to content

Commit

Permalink
Corrected rain storm start date device class
Browse files Browse the repository at this point in the history
  • Loading branch information
MarcoGos committed Feb 9, 2024
1 parent e311700 commit e89d663
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 7 deletions.
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,10 @@ The following entities will be created:
- Today's highest rain rate
- Rain Rate Time:
- Time of today's highest rain rate (or Unknown if no rain)
- Rain Storm:
- Total rainfall during an extended period of rain
- Rain Storm Start Date:
- Start date or current rain storm
- Solar Radiation:
- Current solar radiation
- Solar Radiation (Day):
Expand Down Expand Up @@ -113,10 +117,6 @@ The following entities will be created:
- 10 minutes average wind speed
- Wind Speed (Bft):
- 10 minutes average wind speed in Beaufort
- Rain Storm:
- Total rainfall during an extended period of rain
- Storm Start Date:
- Start date or current rain storm
- Extra Humidity 1-7:
- Current humidity extra sensor 1-7
- Extra Temperature 1-7:
Expand Down Expand Up @@ -152,4 +152,4 @@ The entity information is updated every 30 seconds (default or other value is ch

During first setup the communication to the weather station can be a bit tricky, resulting in an error saying the device didn't communicate. Please try again to set it up (can take up to 5 times).

Determining Wind Gust value is done by reading archive data of the weather station. Unfortunately this part of the library function is a bit unstable.
Determining Wind Gust value is done by reading archive data of the weather station.
9 changes: 8 additions & 1 deletion custom_components/davis_vantage/client.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"""All client function"""
from typing import Any
from datetime import datetime, timedelta, time
from datetime import datetime, timedelta, time, date
from zoneinfo import ZoneInfo
import logging
import asyncio
Expand Down Expand Up @@ -267,6 +267,7 @@ def convert_values(self, data: dict[str, Any]) -> None:
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'])

def correct_rain_values(self, data: dict[str, Any]):
if data["RainDay"] is not None:
Expand Down Expand Up @@ -362,3 +363,9 @@ def strtotime(self, time_str: str | None) -> time | None:
return None
else:
return datetime.strptime(time_str, "%H:%M").time()

def strtodate(self, date_str: str | None) -> date | None:
if date_str is None:
return None
else:
return datetime.strptime(date_str, "%Y-%m-%d").date()
2 changes: 1 addition & 1 deletion 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.6"
VERSION = "1.1.7"

DEFAULT_SYNC_INTERVAL = 30 # seconds
DEFAULT_NAME = NAME
Expand Down
1 change: 1 addition & 0 deletions custom_components/davis_vantage/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -434,6 +434,7 @@
key="StormStartDate",
name="Rain Storm Start Date",
icon="mdi:calendar-outline",
device_class=SensorDeviceClass.DATE,
entity_registry_enabled_default=False
),
SensorEntityDescription(
Expand Down

0 comments on commit e89d663

Please sign in to comment.