Skip to content

Commit 8121a4c

Browse files
committed
Add Solar Irradiation & UV index
2 parents e53c8a8 + 4a5c0ac commit 8121a4c

File tree

4 files changed

+31
-4
lines changed

4 files changed

+31
-4
lines changed

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,9 @@ Configuration variables:
5050
- **date**: current date
5151
- **wind_chill**: Wind Chill (°C or °F)
5252
- **wind_chill_max**: Today MAX Wind Chill (°C or °F)
53-
- **wind_chill_min**: Today MIN Wind Chill (°C or °F)
53+
- **wind_chill_min**: Today MIN Wind Chill (°C or °F)
54+
- **vp_solar**: Solar Irradiation (W/m² or BTU/(h×ft²))
55+
- **uv_index**: UV Index
5456
5557
## Install via [HACS](https://github.com/custom-components/hacs)
5658
You can find this integration in a store.

custom_components/clientraw/manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,5 @@
77
"iot_class": "cloud_polling",
88
"issue_tracker": "https://github.com/pilotak/homeassistant-clientraw/issues",
99
"requirements": [],
10-
"version": "2.4.1"
10+
"version": "2.5.0"
1111
}

custom_components/clientraw/sensor.py

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
from homeassistant.const import (
1515
CONF_MONITORED_CONDITIONS, TEMP_CELSIUS, TEMP_FAHRENHEIT, PRESSURE_HPA,
1616
PRESSURE_INHG, LENGTH_METERS, LENGTH_FEET, LENGTH_INCHES, STATE_UNKNOWN,
17-
STATE_UNAVAILABLE)
17+
STATE_UNAVAILABLE, UV_INDEX, UnitOfIrradiance)
1818
from homeassistant.util import slugify
1919
from homeassistant.util.unit_conversion import (
2020
TemperatureConverter, PressureConverter)
@@ -25,7 +25,7 @@
2525
async_call_later)
2626
from homeassistant.util.unit_system import METRIC_SYSTEM
2727

28-
__version__ = '2.4.1'
28+
__version__ = '2.5.0'
2929

3030
_LOGGER = logging.getLogger(__name__)
3131

@@ -77,6 +77,10 @@
7777
'mdi:thermometer'],
7878
'wind_chill_min': ['Today MIN Wind Chill', TEMP_CELSIUS, TEMP_FAHRENHEIT,
7979
'mdi:thermometer'],
80+
'vp_solar': ['VP solar', UnitOfIrradiance.WATTS_PER_SQUARE_METER,
81+
UnitOfIrradiance.BTUS_PER_HOUR_SQUARE_FOOT,
82+
'mdi:solar-power'],
83+
'uv_index': ['UV index', UV_INDEX, UV_INDEX, 'mdi:white-balance-sunny']
8084
}
8185

8286
CONF_URL = 'url'
@@ -576,6 +580,25 @@ def try_again(err: str):
576580
else:
577581
new_state = STATE_UNAVAILABLE
578582

583+
elif dev.type == 'vp_solar':
584+
if self.data[127] != '-' and self.data[127] != '--' \
585+
and self.data[127] != '---':
586+
solar = float(self.data[127])
587+
588+
if self.hass.config.units is not METRIC_SYSTEM:
589+
solar *= 0.3169983306
590+
591+
new_state = round(solar, 2)
592+
else:
593+
new_state = STATE_UNAVAILABLE
594+
595+
elif dev.type == 'uv_index':
596+
if self.data[79] != '-' and self.data[79] != '--' \
597+
and self.data[79] != '---':
598+
new_state = float(self.data[79])
599+
else:
600+
new_state = STATE_UNAVAILABLE
601+
579602
_LOGGER.debug("%s %s", dev.type, new_state)
580603

581604
# pylint: disable=protected-access

info.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@ Configuration variables:
4747
- **wind_chill**: Wind Chill (°C or °F)
4848
- **wind_chill_max**: Today MAX Wind Chill (°C or °F)
4949
- **wind_chill_min**: Today MIN Wind Chill (°C or °F)
50+
- **vp_solar**: Solar Irradiation (W/m² or BTU/(h×ft²))
51+
- **uv_index**: UV Index
5052
5153
A full configuration example can be found below:
5254

0 commit comments

Comments
 (0)