Skip to content

Commit

Permalink
added Station and Date from clientraw.txt information (#16)
Browse files Browse the repository at this point in the history
  • Loading branch information
martinezpenya authored Mar 20, 2022
1 parent 745467f commit eedae78
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 1 deletion.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ Configuration variables:
- **humidity_indoor**: Relative humidity (%)
- **cloud_height**: Cloud Height (m or ft)
- **forecast**: string based output ie.: night showers
- **station**: station name with time added
- **date**: current date
## Install via [HACS](https://github.com/custom-components/hacs)
You can find this integration in a store.
Expand Down Expand Up @@ -96,6 +98,8 @@ sensor:
- humidity_indoor
- cloud_height
- forecast
- station
- date
```
Symbol codes:
```
Expand Down
20 changes: 19 additions & 1 deletion custom_components/clientraw/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,9 @@
'humidity_indoor': ['Indoor Humidity', '%', '%', 'mdi:water-percent'],
'cloud_height': ['Cloud Height', LENGTH_METERS, LENGTH_FEET,
'mdi:cloud-outline'],
'forecast': ['Forecast', None, None, "mdi:card-text-outline"]
'forecast': ['Forecast', None, None, "mdi:card-text-outline"],
'station': ['Station', None, None, "mdi:home-thermometer-outline"],
'date': ['Date', None, None, "mdi:calendar"]
}

CONF_URL = 'url'
Expand Down Expand Up @@ -512,6 +514,22 @@ def try_again(err: str):
else:
new_state = STATE_UNAVAILABLE

elif dev.type == 'station':
if self.data[32] != '-' and self.data[32] != '--' \
and self.data[32] != '---':
station = str(self.data[32])
new_state = station
else:
new_state = STATE_UNAVAILABLE

elif dev.type == 'date':
if self.data[74] != '-' and self.data[74] != '--' \
and self.data[74] != '---':
date = str(self.data[74])
new_state = date
else:
new_state = STATE_UNAVAILABLE

_LOGGER.debug("%s %s", dev.type, new_state)

# pylint: disable=protected-access
Expand Down
4 changes: 4 additions & 0 deletions info.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ Configuration variables:
- **humidity_indoor**: Relative humidity (%)
- **cloud_height**: Cloud Height (m or ft)
- **forecast**: string based output ie.: night showers
- **station**: station name with time added
- **date**: current date
A full configuration example can be found below:
Expand Down Expand Up @@ -76,4 +78,6 @@ sensor:
- humidity_indoor
- cloud_height
- forecast
- station
- date
```

0 comments on commit eedae78

Please sign in to comment.