Skip to content

Commit 368a8d4

Browse files
committed
Showcase: refine readme & adjust rainviewer
1 parent f262c52 commit 368a8d4

File tree

2 files changed

+34
-21
lines changed

2 files changed

+34
-21
lines changed

showcase/README.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ Put it under `showcase/NAME/README.md`.
1111

1212
Add `front matter`a and content:
1313

14-
```markdown
14+
````markdown
1515
---
1616
title: Your title
1717
authors:
@@ -28,7 +28,14 @@ Detailed description of your HA Map Card implementation, including:
2828

2929
Optionally, add more images:
3030
![Second Image](second-image.jpg)
31+
32+
Be sure to escape code blocks:
33+
{% raw %}
34+
```jinja
35+
{% set test = true %}
3136
```
37+
{% endraw %}
38+
````
3239

3340
The images go in the folder as well.
3441

showcase/animated-or-static-rainviewer-layer/README.md

Lines changed: 26 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,15 @@ authors:
44
title: Rainviewer Overlay
55
---
66

7+
![rainviewer screenshot](rainviewer.png)
8+
79
I just wanted to share my config after creating a rainviewer overlay, and correcting the dark mode display with card mod.
810

911
I'll lay out the code first, then mention some hurdles I had, and how I worked around them.
1012

1113
Firstly, in your configuration.yaml, you'll need rest sensors to get the current frame, and previous frames from rainviewer:
12-
13-
```
14+
{% raw %}
15+
```yaml
1416
rest:
1517
- resource: https://api.rainviewer.com/public/weather-maps.json
1618
scan_interval: 300 # Every 5 minutes
@@ -20,33 +22,36 @@ rest:
2022
- name: rainviewer_frames
2123
value_template: "{{ value_json.radar.past[-10:] | map(attribute='path') | join(',') }}"
2224
```
23-
25+
{% endraw %}
2426
Adjust the value_json.radar.past[-10:] to suit your needs. I left it at -10 even though I only animate 5 frames (for resource purposes.)
2527
2628
2729
Next, you'll need two helpers:
2830
2931
First, one that is the frame number index that will be changed via an automation:
30-
32+
{% raw %}
33+
```
3134
input_number.rainviewer_frame_index
3235
Minimum value: 0
3336
Maximum value :10 <---- adjust for your needs, but it needs to be at least 1 more than configured in the automation
3437
Step size: 1
3538
Display Mode: Slider
36-
37-
39+
```
40+
{% endraw %}
3841
Second, you'll need a template sensor
3942
4043
sensor.rainviewer_current_frame
41-
```
44+
{% raw %}
45+
```jinja
4246
{% set frames = states('sensor.rainviewer_frames').split(',') %}
43-
{% set idx = states('input_number.rainviewer_frame_index')|int(0) %}
44-
{{ frames[idx] if frames|length > idx else frames[-1] }}
47+
{% set idx = states('input_number.rainviewer_frame_index')|int(0) %}
48+
{{ frames[idx] if frames|length > idx else frames[-1] }}
4549
```
46-
50+
{% endraw %}
4751
Now, We need to create an automation to cycle the frames on the map:
4852

49-
```
53+
{% raw %}
54+
```yaml
5055
alias: Cycle RainViewer Frames
5156
triggers:
5257
- seconds: /1 # every 1 second. Adjust to your needs.
@@ -78,11 +83,11 @@ actions:
7883
- sensor.rainviewer_current_frame
7984
- input_number.rainviewer_frame_index
8085
```
81-
86+
{% endraw %}
8287
8388
Lastly, the card itself. This is a stripped down anonymized version:
84-
85-
```
89+
{% raw %}
90+
```yaml
8691
type: custom:map-card
8792
focus_follow: none
8893
theme_mode: light # Dark mode applies css filters to all layers and makes the rainmap layer look wrong.
@@ -116,7 +121,7 @@ card_mod: # This inverts ONLY the openstreetmap layer.
116121
117122
118123
```
119-
124+
{% endraw %}
120125
121126
Many of the things I found I had mentioned in the notes.
122127
@@ -127,27 +132,28 @@ Some of my lower end clients aren't super happy with the map with the animation
127132
I'm running homeassistant OS as a VM on a healthily configured Dell R730XD running proxmox and I was still experiencing some lag on the map until I added the purge to the automation.
128133
129134
If you don't want or need animation, All you would need to overlay the latest radar images is the first rest sensor:
130-
131-
```
135+
{% raw %}
136+
```yaml
132137
rest:
133138
- resource: https://api.rainviewer.com/public/weather-maps.json
134139
scan_interval: 300 # Every 5 minutes
135140
sensor:
136141
- name: rainviewer_frame
137142
value_template: "{{ value_json.radar.nowcast[0].path }}"
138143
```
144+
{% endraw %}
139145
140146
then adjust the card yaml and add this:
141-
142-
```
147+
{% raw %}
148+
```yaml
143149
tile_layers:
144150
- url: >-
145151
https://tilecache.rainviewer.com{{
146152
states('sensor.rainviewer_frame') }}/512/{z}/{x}/{y}/7/1_0.png
147153
options:
148154
opacity: 0.4
149155
```
150-
156+
{% endraw %}
151157
152158
Here is how it looks:
153159

0 commit comments

Comments
 (0)