Skip to content

Commit

Permalink
pop fixes and preping for 0.71 release
Browse files Browse the repository at this point in the history
  • Loading branch information
DavidFW1960 committed May 22, 2020
1 parent ce04a35 commit 4d1aaa7
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 7 deletions.
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,8 @@ Optional entries add components to the card. My BOM area (Gosford) does not incl

***Also note that the name for tomorrow's possible rainfall has changed!

***Defining BOTH entity_pop_intensity and entity_pop_intensity_rate will give an INVALID message in the pop slot if defined.

~~~~
entity_sun: sun.sun
# entity_visibility: sensor.???? - Not available in my area
Expand All @@ -148,6 +150,7 @@ Optional entries add components to the card. My BOM area (Gosford) does not incl
entity_daily_summary: sensor.bom_gosford_detailed_summary_0
entity_pop: sensor.bom_gosford_chance_of_rain_0
entity_pop_intensity: sensor.bom_gosford_rain_today
# entity_pop_intensity_rate: sensor.bom_gosford_rain_today
entity_possible_today: sensor.bom_gosford_possible_rainfall_0
entity_pos_1: sensor.bom_gosford_possible_rainfall_1
entity_pos_2: sensor.bom_gosford_possible_rainfall_2
Expand Down
12 changes: 6 additions & 6 deletions bom-weather-card.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
console.info(
`%c BOM-WEATHER-CARD \n%c Version 0.70 `,
`%c BOM-WEATHER-CARD \n%c Version 0.71 `,
"color: orange; font-weight: bold; background: black",
"color: white; font-weight: bold; background: dimgray"
);
Expand Down Expand Up @@ -107,7 +107,7 @@ class BOMWeatherCard extends LitElement {
var sunFollowing = this.config.alt_sun_following ? html`<li><span id="alt-sun-following">${this._hass.states[this.config.alt_sun_following].state}</span></li>` : this.config.entity_sun ? this.sunSet.following : "";
var daytimeHigh = this.config.alt_daytime_high ? html`<li><span class="ha-icon"><ha-icon icon="mdi:thermometer-high"></ha-icon></span><span id="alt-daytime-high">${this._hass.states[this.config.alt_daytime_high].state}</span></li>` : this.config.entity_daytime_high ? html`<li><span class="ha-icon"><ha-icon icon="mdi:thermometer-high"></ha-icon></span>${this.localeText.maxToday} <span id="daytime-high-text">${Math.round(this._hass.states[this.config.entity_daytime_high].state)}</span><span> ${this.getUOM('temperature')}</span></li>` : ``;
var daytimeLow = this.config.entity_daytime_low ? html`<li><span class="ha-icon"><ha-icon icon="mdi:thermometer-low"></ha-icon></span>${this.localeText.minToday} <span id="daytime-low-text">${Math.round(this._hass.states[this.config.entity_daytime_low].state)}</span><span> ${this.getUOM('temperature')}</span></li>` : ``;
var intensity = this.config.entity_pop_intensity ? html`<span id="intensity-text"> - ${this._hass.states[this.config.entity_pop_intensity].state}</span><span class="unit"> ${this.getUOM('precipitation')}</span>` : ``;
var intensity = this.config.entity_pop_intensity && !(this.config.entity_pop_intensity_rate) ? html`<span id="intensity-text"> - ${this._hass.states[this.config.entity_pop_intensity].state}</span><span class="unit"> ${this.getUOM('precipitation')}</span>` : this.config.entity_pop_intensity_rate && !(this.config.entity_pop_intensity) ? html`<span id="intensity-text"> - ${this._hass.states[this.config.entity_pop_intensity_rate].state}</span><span class="unit"> ${this.getUOM('intensity')}</span>` : ` invalid`;
var pop = this.config.alt_pop ? html`<li><span class="ha-icon"><ha-icon icon="mdi:weather-rainy"></ha-icon></span><span id="alt-pop">${this._hass.states[this.config.alt_pop].state}</span></li>` : this.config.entity_pop ? html`<li><span class="ha-icon"><ha-icon icon="mdi:weather-rainy"></ha-icon></span><span id="pop-text">${Math.round(this._hass.states[this.config.entity_pop].state)}</span><span class="unit"> %</span><span id="pop-intensity-text">${intensity}</span></li>` : ``;
var possibleToday = this.config.entity_possible_today ? html`<li><span class="ha-icon"><ha-icon icon="mdi:weather-rainy"></ha-icon></span>${this.localeText.posToday} <span id="possible_today-text">${this._hass.states[this.config.entity_possible_today].state}</span><span class="unit"> ${this.getUOM('precipitation')}</span></li>` : ``;
var possibleTomorrow = this.config.entity_pos_1 ? html`<li><span class="ha-icon"><ha-icon icon="mdi:weather-rainy"></ha-icon></span>${this.localeText.posTomorrow} <span id="possible_tomorrow-text">${this._hass.states[this.config.entity_pos_1].state}</span><span class="unit"> ${this.getUOM('precipitation')}</span></li>` : ``;
Expand Down Expand Up @@ -439,9 +439,9 @@ get sunSet() {
var nextSunRise;
if (this.config.time_format) {
nextSunSet = new Date(this._hass.states[this.config.entity_sun].attributes.next_setting).toLocaleTimeString(this.config.locale, {hour: '2-digit', minute:'2-digit',hour12: this.is12Hour});
nextSunSet = nextSunSet.replace(/^0+/, '');
nextSunSet = nextSunSet.replace(/^0+/, '');
nextSunRise = new Date(this._hass.states[this.config.entity_sun].attributes.next_rising).toLocaleTimeString(this.config.locale, {hour: '2-digit', minute:'2-digit',hour12: this.is12Hour});
nextSunRise = nextSunRise.replace(/^0+/, '');
nextSunRise = nextSunRise.replace(/^0+/, '');
}
else {
nextSunSet = new Date(this._hass.states[this.config.entity_sun].attributes.next_setting).toLocaleTimeString(this.config.locale, {hour: '2-digit', minute:'2-digit'});
Expand Down Expand Up @@ -787,7 +787,7 @@ style() {
case 'precipitation':
return lengthUnit === 'km' ? 'mm' : 'in';
case 'intensity':
return lengthUnit === 'km' ? 'mm/h' : 'in/h'
return lengthUnit === 'km' ? 'mm/h' : 'in/h';
default:
return this._hass.config.unit_system[measure] || '';
}
Expand Down Expand Up @@ -860,7 +860,7 @@ style() {
if (this.config.entity_pop_intensity && !this.config.alt_pop) {
root.getElementById("intensity-text").textContent =
` - ${this._hass.states[this.config.entity_pop_intensity].state} `
}
}
if (this.config.entity_possible_today) { root.getElementById("possible_today-text").textContent = `${this._hass.states[this.config.entity_possible_today].state}` }
if (this.config.entity_pos_1) { root.getElementById("possible_tomorrow-text").textContent = `${this._hass.states[this.config.entity_pos_1].state}` }
if (this.config.entity_daytime_high && !this.config.alt_daytime_high) { root.getElementById("daytime-high-text").textContent = `${Math.round(this._hass.states[this.config.entity_daytime_high].state)}` }
Expand Down
9 changes: 8 additions & 1 deletion info.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,14 @@

## Latest Changes

Fix card refresh.
With the variable for rainfall today. The ORIGINAL card used a rate in say mm/h. I changed this to just be an amount of rainfall today in mm.
So I added a new variable, entity_pop_intensity_rate in case you are using a mm/h rather than just blanket rainfall for the day.
You can only use ONE of these variables. If you use both you will see an invalid message on the card where rainfall is displayed.
```
entity_pop_intensity: sensor.bom_gosford_rain_today
# entity_pop_intensity_rate: sensor.bom_gosford_rain_today #####NOTE only define entity_pop_intensity OR entity_pop_intensity_rate or you will get an invalid message!
```
Fix card refresh. (again!)
Remove leading zeros from 12h times
I have added an option to display the Wind Gust speed.

Expand Down
1 change: 1 addition & 0 deletions lovelace.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ entity_apparent_temp: sensor.bom_gosford_feels_like_c
entity_daily_summary: sensor.bom_gosford_detailed_summary_0
entity_pop: sensor.bom_gosford_chance_of_rain_0
entity_pop_intensity: sensor.bom_gosford_rain_today
# entity_pop_intensity_rate: sensor.bom_gosford_rain_today #####NOTE only define entity_pop_intensity OR entity_pop_intensity_rate or you will get an invalid message!
entity_possible_today: sensor.bom_gosford_possible_rainfall_0
entity_pos_1: sensor.bom_gosford_possible_rainfall_1
entity_pos_2: sensor.bom_gosford_possible_rainfall_2
Expand Down

0 comments on commit 4d1aaa7

Please sign in to comment.