Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for custom colors per condition #54

Merged
merged 20 commits into from
Jul 11, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions .github/workflows/build.yml → .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@ on:
push:
branches:
- main
pull_request:
branches:
- main

jobs:
build:
Expand Down
27 changes: 27 additions & 0 deletions .github/workflows/non-main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: 'Build non-main'

on:
push:
branches-ignore:
- main
pull_request:
branches:
- main

jobs:
build:
name: Build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Build
run: |
cd /home/runner/work/lovelace-hourly-weather/lovelace-hourly-weather
npm ci
npm run build
- name: Save artifact
uses: actions/upload-artifact@v3
with:
name: hourly-weather.js
retention-days: 5
path: /home/runner/work/lovelace-hourly-weather/lovelace-hourly-weather/dist/hourly-weather.js
40 changes: 40 additions & 0 deletions .github/workflows/translate.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: 'Translate strings'

on:
pull_request:
branches:
- main

jobs:
translate:
name: translate
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Install localization package
run: npm install -g i18n-auto-translation #-msnyder

- name: Translate files
id: translate
uses: msnyder-msft/[email protected]
with:
provider: 'google-official'
subscriptionKey: '${{ secrets.TRANSLATOR_SUBSCRIPTION_KEY }}'
filePath: './src/localize/languages/en.json'
from: 'en'
to: 'de,es,fr,nb,pl,pt'
debug: false

- name: Get current branch name
id: branch_name
run: echo ::set-output name=current_branch::${GITHUB_REF#refs/*/}

- name: Commit changes
uses: devops-infra/[email protected]
continue-on-error: true
with:
github_token: '${{ secrets.GITHUB_TOKEN }}'
commit_prefix: '[Auto] '
commit_message: 'Adding updated localization files'
force: false
target_branch: ${{steps.vars.branch_name.current_branch}}
40 changes: 38 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ This card is focused on displaying hourly weather data. If you try selecting a w
forecasts, it will show a warning. I've tested with the OpenWeatherMap integration using the `onecall_hourly` mode and
that works very well.

> ℹ️ NOTE: If your selected weather entity provides forecasts in increments of greater than one hour at a time, each segment
> of the bar will be for one segment, not one hour.
> ℹ️ NOTE: If your selected weather entity provides forecasts in increments of greater than one hour at a time, each
> segment of the bar will be for one segment, not one hour.

If you already use OpenWeatherMap for daily data, you can add a second integration of the same
component for hourly -- just adjust the latitude or longitude a tiny bit (i.e. change the last decimal by 1).
Expand All @@ -65,6 +65,7 @@ Otherwise, the integration may complain of a duplicate unique ID.
| name | string | **Optional** | Card name | `Hourly Weather` |
| icons | bool | **Optional** | Whether to show icons instead of text labels | `false` |
| num_hours | number | **Optional** | Number of hours to show (even integer >= 2) | `12` |
| colors | object | **Optional** | Set colors for all or some conditions | |
| tap_action | object | **Optional** | Action to take on tap | `action: more-info` |
| hold_action | object | **Optional** | Action to take on hold | `none` |
| double_tap_action | object | **Optional** | Action to take on double tap | `none` |
Expand All @@ -81,6 +82,41 @@ Otherwise, the integration may complain of a duplicate unique ID.
| haptic | string | **Optional** | Haptic feedback _success, warning, failure, light, medium, heavy, selection_ | `none` |
| repeat | number | **Optional** | How often to repeat the `hold_action` in milliseconds. | `none` |

## Color Options

`colors` is specified as an object containing one or more of the keys listed below and values that are valid CSS
colors. Invalid color values will be discarded and will trigger a warning.

Some conditions will default to whatever the value is of some other condition. For example, `fog` will default to
whatever `cloudy` is.

| Key | Default |
| ----------------- | ---------------------- |
| `clear-night` | `#000` |
| `cloudy` | `#777` |
| `fog` | same as `cloudy` |
| `hail` | `#2b5174` |
| `lightning` | same as `rainy` |
| `lightning-rainy` | same as `rainy` |
| `partlycloudy` | `#b3dbff` |
| `pouring` | same as `rainy` |
| `rainy` | `#44739d` |
| `snowy` | `#fff` |
| `snowy-rainy` | same as `partlycloudy` |
| `sunny` | `#90cbff` |
| `windy` | same as `sunny` |
| `windy-variant` | same as `sunny` |
| `exceptional` | `#ff9d00` |

### Sample colors configuration

```yaml
colors:
sunny: '#bbccee' # note that hex colors must be quoted
snowy-rainy: rgba(255, 255, 255, 0.8) # rgba works (and hsla too)
exceptional: red # as do valid CSS color names
```

[commits-shield]: https://img.shields.io/github/commit-activity/y/decompil3d/lovelace-hourly-weather.svg?style=for-the-badge
[commits]: https://github.com/decompil3d/lovelace-hourly-weather/commits/master
[devcontainer]: https://code.visualstudio.com/docs/remote/containers
Expand Down
Loading