Skip to content

Commit

Permalink
Describe sensor value/attributes and provide hourly sensor template
Browse files Browse the repository at this point in the history
Closes #3
  • Loading branch information
davidn authored Jan 21, 2024
1 parent 37361ee commit 9f5f1db
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ You will now have a sensor that provides the UV Index in that city.

## Example dashboard card

The screenshot above is from the following dashboard card:
```
The gauge screenshot above is from the following dashboard card:
```yaml
type: gauge
entity: sensor.uv_index
segments:
Expand All @@ -58,3 +58,20 @@ type: gauge
max: 12
needle: true
```
The hourly card is can be found at https://github.com/davidn/uvindex-hourly.
# Usage
This integration provides a single sensor called `sensor.uv_index`. The value of the sensor is the max UV index for the current day. The sensor also has a `forecast` attribute that provides hourly UV index predictions. This attribute is an array of dicts, each dict having a `datetime` and a `uv_index` entry with the time and UV index for that prediction. This comes directly from the EPA source, which currently provides a prediction for a sensible range of hours, on the hour, but could potentially change.

If you want a separate sensor with the current UV index, create a template sensor using the following template:

```python
{% for forecast in state_attr("sensor.uv_index", "forecast") %}
{% if forecast.datetime | as_local >= now() %}
{{ forecast.uv_index }}
{% break %}
{% endif %}
{% endfor %}
```

0 comments on commit 9f5f1db

Please sign in to comment.