-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #12 from artem-sedykh/dev
version 1.2.1
- Loading branch information
Showing
19 changed files
with
479 additions
and
103 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
## v1.2.1 | ||
[![Downloads](https://img.shields.io/github/downloads/artem-sedykh/mini-climate-card/v1.2.1/total.svg)](https://github.com/artem-sedykh/mini-climate-card/releases/tag/v1.2.1) | ||
|
||
### ADDED | ||
- Add new secondary_info type: `hvac-action` #9 | ||
By default, translations from [ha frontend](https://github.com/home-assistant/frontend/blob/master/translations/frontend/en.json#L33) | ||
```yaml | ||
- type: custom:mini-climate | ||
entity: climate.dahatsu | ||
secondary_info: | ||
type: hvac-action | ||
``` | ||
but you can customize your translations | ||
```yaml | ||
- type: custom:mini-climate | ||
entity: climate.dahatsu | ||
secondary_info: | ||
type: hvac-action | ||
source: | ||
cooling: Охлаждение | ||
``` | ||
You can set your own icon for each hvac-action | ||
```yaml | ||
- type: custom:mini-climate | ||
entity: climate.dahatsu | ||
secondary_info: | ||
type: hvac-action | ||
source: | ||
cooling: | ||
icon: 'mdi:snowflake' | ||
name: Охлаждение | ||
``` | ||
You can set your own icon for each hvac-action | ||
```yaml | ||
- type: custom:mini-climate | ||
entity: climate.dahatsu | ||
secondary_info: | ||
type: hvac-action | ||
source: | ||
cooling: | ||
icon: 'mdi:snowflake' | ||
name: Охлаждение | ||
``` | ||
Or you can use one permanent icon | ||
```yaml | ||
- type: custom:mini-climate | ||
entity: climate.dahatsu | ||
secondary_info: | ||
type: hvac-action | ||
icon: 'mdi:cached' | ||
``` | ||
- Add new secondary_info type: `fan-mode-dropdown` #10 | ||
|
||
```yaml | ||
- type: custom:mini-climate | ||
entity: climate.dahatsu | ||
secondary_info: fan-mode-dropdown | ||
``` | ||
![image](https://user-images.githubusercontent.com/861063/84180244-d80d0a80-aa8f-11ea-8275-f4e3db85fd31.png) | ||
|
||
- Added the ability to make buttons on the main screen | ||
|
||
```yaml | ||
- type: custom:mini-climate | ||
entity: climate.dahatsu | ||
fan_mode: | ||
location: main | ||
``` | ||
![image](https://user-images.githubusercontent.com/861063/84198175-d5201300-aaab-11ea-94fb-bf9fde5aa2b1.png) | ||
|
||
This rule also applies to buttons. | ||
```yaml | ||
- type: custom:mini-climate | ||
entity: climate.dahatsu | ||
buttons: | ||
custom_button: | ||
location: main | ||
``` | ||
![image](https://user-images.githubusercontent.com/861063/84198845-d4d44780-aaac-11ea-8590-4eff94457593.png) | ||
|
||
> With these settings, the data may not fit on the mobile version! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,127 @@ | ||
import { LitElement, html, css } from 'lit-element'; | ||
import sharedStyle from '../sharedStyle'; | ||
|
||
class FanModeSecondary extends LitElement { | ||
constructor() { | ||
super(); | ||
this.fanMode = {}; | ||
this.config = {}; | ||
this.timer = undefined; | ||
this._selected = {}; | ||
this.source = {}; | ||
} | ||
|
||
static get properties() { | ||
return { | ||
fanMode: { type: Object }, | ||
config: { type: Object }, | ||
}; | ||
} | ||
|
||
get selectedIndex() { | ||
return this.fanMode.source.map(item => item.id).indexOf(this._selected.id); | ||
} | ||
|
||
handleChange(e) { | ||
const index = e.target.selected; | ||
|
||
if (index === this.selectedIndex || !this.fanMode.source[index]) | ||
return; | ||
|
||
clearTimeout(this.timer); | ||
|
||
const selected = this.fanMode.source[index]; | ||
const { entity } = this.fanMode; | ||
const oldSelected = this._selected; | ||
this._selected = selected; | ||
|
||
this.timer = setTimeout(async () => { | ||
if (this.fanMode.entity === entity) { | ||
this._selected = oldSelected; | ||
return this.requestUpdate('_selected'); | ||
} | ||
}, this.fanMode.actionTimeout); | ||
|
||
this.fanMode.handleChange(selected.id); | ||
|
||
return this.requestUpdate('_selected'); | ||
} | ||
|
||
renderFanMode() { | ||
const label = this._selected ? this._selected.name : this.fanMode.state; | ||
const icon = this.config.secondary_info.icon ? this.config.secondary_info.icon | ||
: this.fanMode.icon; | ||
|
||
return html` | ||
<ha-icon class='icon' .icon=${icon}></ha-icon> | ||
<span class='name'>${label}</span> | ||
`; | ||
} | ||
|
||
renderFanModeDropdown() { | ||
return html` | ||
<paper-menu-button | ||
class='mc-dropdown' | ||
noink no-animations | ||
.horizontalAlign=${'right'} | ||
.verticalAlign=${'top'} | ||
.verticalOffset=${44} | ||
?disabled=${this.fanMode.disabled} | ||
.dynamicAlign=${true}> | ||
<div class="wrap" slot='dropdown-trigger'> | ||
${this.renderFanMode()} | ||
</div> | ||
<paper-listbox slot="dropdown-content" .selected=${this.selectedIndex} @iron-select=${this.handleChange}> | ||
${this.fanMode.source.map(item => html` | ||
<paper-item value=${item.id || item.name}> | ||
<span class='mc-dropdown__item__label'>${item.name}</span> | ||
</paper-item>`)} | ||
</paper-listbox> | ||
</paper-menu-button> | ||
`; | ||
} | ||
|
||
render() { | ||
const { type } = this.config.secondary_info; | ||
|
||
if (type === 'fan-mode-dropdown') { | ||
return this.renderFanModeDropdown(); | ||
} | ||
|
||
return this.renderFanMode(); | ||
} | ||
|
||
updated(changedProps) { | ||
if (changedProps.has('fanMode')) { | ||
clearTimeout(this.timer); | ||
this._selected = this.fanMode.selected; | ||
this.requestUpdate('_selected').then(); | ||
} | ||
} | ||
|
||
static get styles() { | ||
return [ | ||
sharedStyle, | ||
css` | ||
paper-menu-button { | ||
padding: 0; | ||
} | ||
.name { | ||
font-size: calc(var(--mc-unit) * .35); | ||
font-weight: var(--mc-info-font-weight); | ||
line-height: calc(var(--mc-unit) * .5); | ||
vertical-align: middle; | ||
display: inline-block; | ||
} | ||
.icon { | ||
color: var(--mc-icon-color); | ||
height: calc(var(--mc-unit) * .475); | ||
width: calc(var(--mc-unit) * .5); | ||
min-width: calc(var(--mc-unit) * .5); | ||
--mdc-icon-size: calc(var(--mc-unit) * 0.5); | ||
} | ||
`]; | ||
} | ||
} | ||
|
||
customElements.define('mc-fan-mode-secondary', FanModeSecondary); |
Oops, something went wrong.