Skip to content

Commit

Permalink
0.2 remove display time in name
Browse files Browse the repository at this point in the history
  • Loading branch information
websylv committed Jan 27, 2020
1 parent ae902e9 commit e407f1c
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 17 deletions.
6 changes: 0 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,3 @@ If not provided the post code is determined by the location configured in home a

Meteo Swiss weather station code. This code can be found in : [https://data.geo.admin.ch/ch.meteoschweiz.messwerte-aktuell/info/VQHA80_en.txt](https://data.geo.admin.ch/ch.meteoschweiz.messwerte-aktuell/info/VQHA80_en.txt)
If not provided the closest from you location is use

**displayTime**
(boolean)(Optional)

Display time information next to the location. Enable by default

17 changes: 6 additions & 11 deletions custom_components/meteo-swiss/weather.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,14 +68,14 @@ async def async_setup_platform(hass, config, async_add_entities, discovery_info=
lon = config.get(CONF_LONGITUDE, hass.config.longitude)
station = config.get(CONF_STATION)
postcode = config.get(CONF_POSTCODE)
displayTime = config.get(CONF_DISPLAYTIME)

_LOGGER.debug("Configuration :")
_LOGGER.debug("lat: %s"%lat)
_LOGGER.debug("lon: %s"%lon)
_LOGGER.debug("station: %s"%station)
_LOGGER.debug("postcode: %s"%postcode)
_LOGGER.debug("displayTime: %s"%displayTime)
msConfig={"coord":{"lat":lat,"lon":lon},"postcode": postcode, "station":station,"displayTime":displayTime}

msConfig={"coord":{"lat":lat,"lon":lon},"postcode": postcode, "station":station}
async_add_entities([MeteoSwissWeather(msConfig,config)], True)


Expand All @@ -97,7 +97,7 @@ def __init__(self,msConfig,config):
self._condition = None
self._forecast = None
self._description = None
self._displayTime = None


_LOGGER.debug("meteo-swiss INIT")
with async_timeout.timeout(10):
Expand All @@ -123,7 +123,7 @@ def __init__(self,msConfig,config):
allStation = ms.get_all_stations()
self._station_name = allStation[self.stationCode]['name']

self._displayTime = msConfig["displayTime"]


async def async_update(self):
"""Update Condition and Forecast."""
Expand All @@ -136,12 +136,7 @@ async def async_update(self):

@property
def name(self):
if(self._displayTime):
conditionTime = self._condition[0]["time"]
m = re.search(r"^(?P<Y>\d{4})(?P<M>\d{2})(?P<D>\d{2})(?P<h>\d{2})(?P<m>\d{2})",str(conditionTime))
return "%s - %s:%s"%(self._station_name,int(m["h"])+1,m["m"])
else:
return self._station_name
return self._station_name
@property
def temperature(self):
return float(self._condition[0]['tre200s0'])
Expand Down
5 changes: 5 additions & 0 deletions hacs.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"name": "Meteo Swiss",
"render_readme" : true,
"domains": "weather",
}
1 change: 1 addition & 0 deletions info.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
please see README.md

0 comments on commit e407f1c

Please sign in to comment.