From 4ed3415476e770b187bdee98734442c58b787c81 Mon Sep 17 00:00:00 2001 From: Artem Sedykh Date: Wed, 22 Apr 2020 00:52:21 +0300 Subject: [PATCH 1/4] Added rounding configuration for temperature and humidity Added `strong` option(hidden by default) for fan_mode_button source, for zhimi.humidifier.v1 --- README.md | 37 ++++++++++++++++++++++++++++++++++--- package-lock.json | 2 +- package.json | 2 +- release_notes/v1.0.7.md | 5 +++++ src/main.js | 9 +++++++++ src/model.js | 6 ++++-- 6 files changed, 54 insertions(+), 7 deletions(-) create mode 100644 release_notes/v1.0.7.md diff --git a/README.md b/README.md index 22db8ce..2c87b88 100644 --- a/README.md +++ b/README.md @@ -25,7 +25,7 @@ Inspired by [mini media player](https://github.com/kalkih/mini-media-player). ```yaml resources: - - url: /local/mini-humidifier-bundle.js?v=1.0.6 + - url: /local/mini-humidifier-bundle.js?v=1.0.7 type: module ``` @@ -43,7 +43,7 @@ Inspired by [mini media player](https://github.com/kalkih/mini-media-player). ```yaml resources: - - url: /local/mini-humidifier-bundle.js?v=1.0.6 + - url: /local/mini-humidifier-bundle.js?v=1.0.7 type: module ``` @@ -56,7 +56,7 @@ Inspired by [mini media player](https://github.com/kalkih/mini-media-player). ```yaml resources: - - url: /local/mini-humidifier-bundle.js?v=1.0.6 + - url: /local/mini-humidifier-bundle.js?v=1.0.7 type: module ``` @@ -107,6 +107,11 @@ Inspired by [mini media player](https://github.com/kalkih/mini-media-player). | fan_mode_button: `source: high: name` | string | optional | v1.0.6 | Display name, default `High` | fan_mode_button: `source: high: order` | number | optional | v1.0.6 | Sort order, default `3` | fan_mode_button: `source: high: hide` | boolean | optional | v1.0.6 | Hide from dropdown list, default `False` +| fan_mode_button: `source: strong` | object | optional | v1.0.7 | strong mode configuration, for `ZHIMI.HUMIDIFIER.V1` +| fan_mode_button: `source: strong: value` | string | optional | v1.0.7 | value, default `High` +| fan_mode_button: `source: strong: name` | string | optional | v1.0.7 | Display name, default `Strong` +| fan_mode_button: `source: strong: order` | number | optional | v1.0.7 | Sort order, default `4` +| fan_mode_button: `source: strong: hide` | boolean | optional | v1.0.7 | Hide from dropdown list, default `True` | **led_button** | object | optional | v1.0.1 | Button Illumination on/off | led_button: `icon` | string | optional | v1.0.1 | Custom icon, default value `mdi:lightbulb-on-outline` | led_button: `hide` | boolean | optional | v1.0.1 | Hide button, default value `False` @@ -151,6 +156,7 @@ Inspired by [mini media player](https://github.com/kalkih/mini-media-player). | temperature: `hide` | boolean | optional | v1.0.1 | Hide indicator, default value `False` | temperature: `order` | number | optional | v1.0.1 | Indicator sort order, default value `1` | temperature: `unit` | string | optional | v1.0.1 | display unit, default `°C` +| temperature: `fixed` | number | optional | v1.0.7 | Rounding the calculated values, default value `1` | temperature: `source` | object | optional | v1.0.6 | data source, by default, data taken from the attribute `temperature` [examples](#temperature-source-examples). | temperature: `source: entity` | string | optional | v1.0.6 | custom entity, if the attribute is not set, the state value | temperature: `source: attribute` | string | optional | v1.0.6 | if the entity parameter is not set, then the data will be obtained from the specified entity attribute, otherwise from the current entity attribute @@ -159,6 +165,7 @@ Inspired by [mini media player](https://github.com/kalkih/mini-media-player). | humidity: `hide` | boolean | optional | v1.0.1 | Hide indicator, default value `False` | humidity: `order` | number | optional | v1.0.1 | Indicator sort order, default value `2` | humidity: `unit` | string | optional | v1.0.1 | display unit, default `%` +| humidity: `fixed` | number | optional | v1.0.7 | Rounding the calculated values, default value `1` | humidity: `source` | object | optional | v1.0.6 | data source, by default, data taken from the attribute `humidity` | humidity: `source: entity` | string | optional | v1.0.6 | custom entity, if the attribute is not set, the state value | humidity: `source: attribute` | string | optional | v1.0.6 | if the entity parameter is not set, then the data will be obtained from the specified entity attribute, otherwise from the current entity attribute @@ -393,6 +400,30 @@ For use Entities card you need to add `group: on` ``` +#### ZHIMI.HUMIDIFIER.V1 configuration + + +```yaml +- type: custom:mini-humidifier + entity: fan.xiaomi_miio_device +# hide the indicator showing the amount of water + depth: + hide: on +# hide dry button + dry_button: + hide: on + fan_mode_button: + source: +# hide auto mode option + auto: + hide: on +# show strong option + strong: + hide: off +``` + + + ## Development *If you plan to contribute back to this repo, please fork & create the PR against the [dev](https://github.com/artem-sedykh/mini-humidifier/tree/dev) branch.* diff --git a/package-lock.json b/package-lock.json index a046cce..4bca2be 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "mini-humidifier", - "version": "v1.0.6", + "version": "v1.0.7", "lockfileVersion": 1, "requires": true, "dependencies": { diff --git a/package.json b/package.json index eb22b82..aa59ea8 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "mini-humidifier", - "version": "v1.0.6", + "version": "v1.0.7", "description": "humidifier card for Home Assistant Lovelace UI", "keywords": [ "home-assistant", diff --git a/release_notes/v1.0.7.md b/release_notes/v1.0.7.md new file mode 100644 index 0000000..d9e932c --- /dev/null +++ b/release_notes/v1.0.7.md @@ -0,0 +1,5 @@ +## v1.0.7 +[![Downloads](https://img.shields.io/github/downloads/artem-sedykh/mini-humidifier/v1.0.7/total.svg)](https://github.com/artem-sedykh/mini-humidifier/releases/tag/v1.0.7) +### ADDED +- Added rounding configuration for temperature and humidity +- Added `strong` option(hidden by default) for fan_mode_button source, for zhimi.humidifier.v1 diff --git a/src/main.js b/src/main.js index ff2c425..6587afc 100644 --- a/src/main.js +++ b/src/main.js @@ -109,6 +109,13 @@ class MiniHumidifier extends LitElement { name: 'High', hide: false, order: 3, + }, + { + id: 'strong', + value: 'Strong', + name: 'Strong', + hide: true, + order: 4, }]; const data = Object.entries(fanModeConf.source); @@ -249,6 +256,7 @@ class MiniHumidifier extends LitElement { unit: '°C', source: { enitity: undefined, attribute: undefined }, order: 1, + fixed: 1, hide: false, ...config.temperature || {}, }; @@ -257,6 +265,7 @@ class MiniHumidifier extends LitElement { unit: '%', source: { enitity: undefined, attribute: undefined }, order: 2, + fixed: 1, hide: false, ...config.humidity || {}, }; diff --git a/src/model.js b/src/model.js index 4e076b8..a29c752 100644 --- a/src/model.js +++ b/src/model.js @@ -112,11 +112,13 @@ export default class HumidifierObject { } get temperature() { - return this.getValue(this.config.temperature.source, this.attr.temperature); + const value = this.getValue(this.config.temperature.source, this.attr.temperature); + return this.round(value, this.config.temperature.fixed); } get humidity() { - return this.getValue(this.config.humidity.source, this.attr.humidity); + const value = this.getValue(this.config.humidity.source, this.attr.humidity); + return this.round(value, this.config.humidity.fixed); } getValue(config, defaultValue) { From 023b5adbba3cd2e5269fbb7c493485c9db80e9ed Mon Sep 17 00:00:00 2001 From: Artem Sedykh Date: Fri, 24 Apr 2020 23:37:41 +0300 Subject: [PATCH 2/4] depth:max_value changed default value from 120 to 125 --- README.md | 2 +- release_notes/v1.0.7.md | 5 ++++- src/main.js | 2 +- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 2c87b88..22821fc 100644 --- a/README.md +++ b/README.md @@ -148,7 +148,7 @@ Inspired by [mini media player](https://github.com/kalkih/mini-media-player). | depth: `order` | number | optional | v1.0.1 | Indicator sort order, default value `0` | depth: `unit_type` | string | optional | v1.0.1 | Indicator type available Values: `liters` or `percent`, default `percent` | depth: `unit` | string | optional | v1.0.1 | display unit, default `%` -| depth: `max_value` | number | optional | v1.0.1 | Depth attribute value with a full tank of humidifier, default `120` +| depth: `max_value` | number | optional | v1.0.1 | Depth attribute value with a full tank of humidifier, default `125` | depth: `volume` | number | optional | v1.0.1 | Humidifier tank volume, needed to calculate values in liters, default `4` liters | depth: `fixed` | number | optional | v1.0.1 | Rounding the calculated values, default value `0` | **temperature** | object | optional | v1.0.1 | Information indicator, showing temperature diff --git a/release_notes/v1.0.7.md b/release_notes/v1.0.7.md index d9e932c..42b8138 100644 --- a/release_notes/v1.0.7.md +++ b/release_notes/v1.0.7.md @@ -1,5 +1,8 @@ ## v1.0.7 -[![Downloads](https://img.shields.io/github/downloads/artem-sedykh/mini-humidifier/v1.0.7/total.svg)](https://github.com/artem-sedykh/mini-humidifier/releases/tag/v1.0.7) +[![Downloads](https://img.shields.io/github/downloads/artem-sedykh/mini-humidifier/v1.0.4/total.svg)](https://github.com/artem-sedykh/mini-humidifier/releases/tag/v1.0.4) ### ADDED - Added rounding configuration for temperature and humidity - Added `strong` option(hidden by default) for fan_mode_button source, for zhimi.humidifier.v1 + +### CHANGED +- `depth:max_value` changed default value from `120` to `125` diff --git a/src/main.js b/src/main.js index 6587afc..294ef83 100644 --- a/src/main.js +++ b/src/main.js @@ -228,7 +228,7 @@ class MiniHumidifier extends LitElement { this.config.depth = { icon: ICON.DEPTH, - max_value: 120, + max_value: 125, unit_type: 'percent', fixed: 0, order: 0, From a540e6f69693dc4010a8001d917773045af4df95 Mon Sep 17 00:00:00 2001 From: Artem Sedykh Date: Mon, 18 May 2020 20:22:10 +0300 Subject: [PATCH 3/4] HA > 0.110.0 support --- .babelrc | 3 +-- release_notes/v1.0.7.md | 3 +++ src/components/controls.js | 16 ++++++++-------- src/components/dropdown.js | 10 +++++----- src/components/info.js | 7 ++++--- src/components/powerstrip.js | 4 ++-- src/components/targetHumiditySlider.js | 3 ++- src/main.js | 13 ++++++++++--- src/sharedStyle.js | 7 ++++--- src/style.js | 2 ++ 10 files changed, 41 insertions(+), 27 deletions(-) diff --git a/.babelrc b/.babelrc index 404710f..00a39d3 100644 --- a/.babelrc +++ b/.babelrc @@ -8,8 +8,7 @@ "esmodules": true } } - ], - ["minify"] + ] ], "comments": false, "plugins": [ diff --git a/release_notes/v1.0.7.md b/release_notes/v1.0.7.md index 42b8138..a51bfcc 100644 --- a/release_notes/v1.0.7.md +++ b/release_notes/v1.0.7.md @@ -6,3 +6,6 @@ ### CHANGED - `depth:max_value` changed default value from `120` to `125` + +### FIXED +- HA > 0.110.0 support, #14 diff --git a/src/components/controls.js b/src/components/controls.js index 8afd79c..4002458 100644 --- a/src/components/controls.js +++ b/src/components/controls.js @@ -32,11 +32,11 @@ class MiniHumidifierControls extends LitElement { renderDryButton(context) { return html` - context.toggleDry(e)} ?color=${context.humidifier.isDryOn}> - + `; } @@ -61,31 +61,31 @@ class MiniHumidifierControls extends LitElement { `; return html` - context.toggleLedBrightness(e)} ?color=${context.humidifier.isLedBrightnessOn}> - + `; } renderBuzzerButton(context) { return html` - context.toggleBuzzer(e)} ?color=${context.humidifier.isBuzzerOn}> - + `; } renderChildLockButton(context) { return html` - context.toggleChildLock(e)} ?color=${context.humidifier.isChildLockOn}> - + `; } diff --git a/src/components/dropdown.js b/src/components/dropdown.js index b9857d4..1293d17 100644 --- a/src/components/dropdown.js +++ b/src/components/dropdown.js @@ -40,11 +40,11 @@ class MiniHumidifierDropdown extends LitElement { .dynamicAlign=${true} ?disabled=${this.disabled} @click=${e => e.stopPropagation()}> - - + ${this.items.map(item => html` @@ -75,7 +75,7 @@ class MiniHumidifierDropdown extends LitElement { padding: 0; display: block; } - paper-icon-button[disabled] { + ha-icon-button[disabled] { opacity: .25; pointer-events: none; } @@ -86,10 +86,10 @@ class MiniHumidifierDropdown extends LitElement { paper-item > *:nth-child(2) { margin-left: 4px; } - paper-menu-button[focused] paper-icon-button { + paper-menu-button[focused] ha-icon-button { color: var(--mh-accent-color); } - paper-menu-button[focused] paper-icon-button[focused] { + paper-menu-button[focused] ha-icon-button[focused] { color: var(--mh-text-color); transform: rotate(0deg); } diff --git a/src/components/info.js b/src/components/info.js index 12bf5d4..dcfc905 100644 --- a/src/components/info.js +++ b/src/components/info.js @@ -12,7 +12,7 @@ class MiniHumidifierInfo extends LitElement { renderDepth(context) { return html`
- + ${context.humidifier.depth} ${context.config.depth.unit}
@@ -22,7 +22,7 @@ class MiniHumidifierInfo extends LitElement { renderTemperature(context) { return html`
- + ${context.humidifier.temperature} ${context.config.temperature.unit}
@@ -32,7 +32,7 @@ class MiniHumidifierInfo extends LitElement { renderHumidity(context) { return html`
- + ${context.humidifier.humidity} ${context.config.humidity.unit}
@@ -82,6 +82,7 @@ class MiniHumidifierInfo extends LitElement { height: calc(var(--mh-unit) * .475); width: calc(var(--mh-unit) * .425); color: var(--mh-icon-color); + --mdc-icon-size: calc(var(--mh-unit) * .425); } .state__value { margin: 0 1px; diff --git a/src/components/powerstrip.js b/src/components/powerstrip.js index 6a5107f..c5a1041 100644 --- a/src/components/powerstrip.js +++ b/src/components/powerstrip.js @@ -29,11 +29,11 @@ class MiniHumidifierPowerstrip extends LitElement { } return html` - this.humidifier.togglePower(e)} ?color=${this.humidifier.isOn}> - + `; } diff --git a/src/components/targetHumiditySlider.js b/src/components/targetHumiditySlider.js index ea5dced..04a1ed2 100644 --- a/src/components/targetHumiditySlider.js +++ b/src/components/targetHumiditySlider.js @@ -21,7 +21,7 @@ class MiniHumidifierTargetHumiditySlider extends LitElement { return html`
- + ${sliderValue} ${this.config.target_humidity.unit}
@@ -76,6 +76,7 @@ class MiniHumidifierTargetHumiditySlider extends LitElement { .state__value_icon { height: calc(var(--mh-unit) * .475); width: calc(var(--mh-unit) * .425); + --mdc-icon-size: calc(var(--mh-unit) * .425); color: var(--mh-icon-color); } .state__value { diff --git a/src/main.js b/src/main.js index 294ef83..3c63921 100644 --- a/src/main.js +++ b/src/main.js @@ -21,6 +21,13 @@ if (!customElements.get('ha-slider')) { ); } +if (!customElements.get('ha-icon-button')) { + customElements.define( + 'ha-icon-button', + class extends customElements.get('paper-icon-button') {}, + ); +} + class MiniHumidifier extends LitElement { constructor() { super(); @@ -354,10 +361,10 @@ class MiniHumidifier extends LitElement { return html`
- this.handleToggle(e)}> - +
`; } @@ -399,7 +406,7 @@ class MiniHumidifier extends LitElement { return html`
- + ${this.secondaryInfoLabel}
`; diff --git a/src/sharedStyle.js b/src/sharedStyle.js index 3cb0879..9a9bbc8 100644 --- a/src/sharedStyle.js +++ b/src/sharedStyle.js @@ -13,17 +13,18 @@ const sharedStyle = css` width: calc(var(--mh-unit) * .6); height: calc(var(--mh-unit) * .6); } - paper-icon-button { + ha-icon-button { width: calc(var(--mh-unit)); height: calc(var(--mh-unit)); + --mdc-icon-button-size: calc(var(--mh-unit)); color: var(--mh-button-color); transition: color .25s; } - paper-icon-button[color] { + ha-icon-button[color] { color: var(--mh-icon-active-color) !important; opacity: 1 !important; } - paper-icon-button[inactive] { + ha-icon-button[inactive] { opacity: .5; } `; diff --git a/src/style.js b/src/style.js index a949a05..02bd15f 100644 --- a/src/style.js +++ b/src/style.js @@ -120,6 +120,7 @@ const style = css` width: calc(var(--mh-unit) * .375); height: calc(var(--mh-unit) * .375); min-width: calc(var(--mh-unit) * .375); + --mdc-icon-size: calc(var(--mh-unit) * .375); } .entity__secondary_info { margin-top: -2px; @@ -160,6 +161,7 @@ const style = css` .toggle-button { width: calc(var(--mh-unit) * .75); height: calc(var(--mh-unit) * .75); + --mdc-icon-button-size: calc(var(--mh-unit) * .75); padding: 3px; color: var(--mh-icon-color); } From ac74d8eb649d121c0803b3e7c02e905bc378271f Mon Sep 17 00:00:00 2001 From: Artem Sedykh Date: Mon, 18 May 2020 20:23:35 +0300 Subject: [PATCH 4/4] revert minify to babel --- .babelrc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.babelrc b/.babelrc index 00a39d3..404710f 100644 --- a/.babelrc +++ b/.babelrc @@ -8,7 +8,8 @@ "esmodules": true } } - ] + ], + ["minify"] ], "comments": false, "plugins": [