Skip to content

Commit

Permalink
Merge pull request #19 from artem-sedykh/dev
Browse files Browse the repository at this point in the history
update to version 2.0.1
  • Loading branch information
artem-sedykh authored Jun 3, 2020
2 parents 4f4bfc5 + ab2e137 commit 21aa0e1
Show file tree
Hide file tree
Showing 30 changed files with 2,015 additions and 1,479 deletions.
813 changes: 553 additions & 260 deletions README.md

Large diffs are not rendered by default.

15 changes: 5 additions & 10 deletions info.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,14 @@
[![hacs_badge](https://img.shields.io/badge/HACS-Default-orange.svg)](https://github.com/artem-sedykh/mini-humidifier)
[![buymeacoffee_badge](https://img.shields.io/badge/Donate-buymeacoffe-ff813f?style=flat)](https://www.buymeacoffee.com/anavrin72)

A minimalistic yet customizable humidifier(Xiaomi Smartmi Zhimi Air Humidifier) card for [Home Assistant](https://github.com/home-assistant/home-assistant) Lovelace UI.
A minimalistic yet customizable humidifier card for [Home Assistant](https://github.com/home-assistant/home-assistant) Lovelace UI.

Tested on [zhimi.humidifier.cb1](https://www.home-assistant.io/integrations/fan.xiaomi_miio/)

![Preview Image](https://user-images.githubusercontent.com/861063/79672681-0f241580-81dd-11ea-913c-234c287a6264.png)
> Attention! The config version *v1.0.8* **very differs** from version >= *v2.0.1*
> Read the [README](https://github.com/artem-sedykh/mini-humidifier) before upgrading
## Examples
![Preview Image](https://user-images.githubusercontent.com/861063/83651482-3171c700-a5c2-11ea-8053-f66472a8d539.png)

#### Basic card
<img src="https://user-images.githubusercontent.com/861063/79479945-27960380-8016-11ea-8110-5460566feb0b.png" width="500px" alt="Basic card example" />

#### Entity card
<img src="https://user-images.githubusercontent.com/861063/79480184-75127080-8016-11ea-8b0b-c102bf26a5d6.png" width="500px" alt="Entities card example" />


**Check the repository for card options & example configurations**
**Check the [repository](https://github.com/artem-sedykh/mini-humidifier) for card options & example configurations**
93 changes: 35 additions & 58 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 2 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "mini-humidifier",
"version": "v1.0.8",
"version": "v2.0.1",
"description": "humidifier card for Home Assistant Lovelace UI",
"keywords": [
"home-assistant",
Expand All @@ -17,7 +17,6 @@
"author": "Artem Sedykh <[email protected]>",
"license": "MIT",
"dependencies": {
"jinja-js": "^0.1.8",
"lit-element": "^2.2.1",
"lit-html": "^1.1.2",
"resize-observer-polyfill": "^1.5.1"
Expand All @@ -29,13 +28,13 @@
"@babel/plugin-proposal-decorators": "^7.3.0",
"@babel/plugin-transform-template-literals": "^7.2.0",
"@babel/preset-env": "^7.3.1",
"@rollup/plugin-json": "^4.0.3",
"babel-plugin-iife-wrap": "^1.1.0",
"babel-preset-minify": "^0.5.1",
"eslint": "^5.16.0",
"eslint-config-airbnb-base": "^13.1.0",
"eslint-plugin-import": "2.16.0",
"rollup": "^2.10.5",
"rollup-plugin-commonjs": "^10.1.0",
"rollup-plugin-node-resolve": "^3.4.0"
},
"scripts": {
Expand Down
10 changes: 10 additions & 0 deletions release_notes/v2.0.1.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
## v2.0.1
[![Downloads](https://img.shields.io/github/downloads/artem-sedykh/mini-humidifier/v2.0.1/total.svg)](https://github.com/artem-sedykh/mini-humidifier/releases/tag/v2.0.1)
### Attention
> The config version *v1.0.8* **very differs** from version >= *v2.0.1*
> No backward compatibility, Sorry
### CHANGES

- Added ability to redefine all control functions for compatibility with different humidifier integrations
- The default configuration is saved for the `zhimi.humidifier.cb1` model
- Read [README](https://github.com/artem-sedykh/mini-humidifier/blob/master/README.md) and decide to upgrade or not
4 changes: 2 additions & 2 deletions rollup.config.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import resolve from 'rollup-plugin-node-resolve';
import commonjs from 'rollup-plugin-commonjs';
import json from '@rollup/plugin-json';

export default {
input: 'src/main.js',
Expand All @@ -10,6 +10,6 @@ export default {
},
plugins: [
resolve(),
commonjs(),
json(),
],
};
89 changes: 89 additions & 0 deletions src/components/button.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
import { LitElement, html, css } from 'lit-element';
import { styleMap } from 'lit-html/directives/style-map';
import sharedStyle from '../sharedStyle';
import { ACTION_TIMEOUT } from '../const';

class HumidifierButton extends LitElement {
constructor() {
super();
this._isOn = false;
this.timer = undefined;
}

static get properties() {
return {
button: { type: Object },
cls: { type: String },
};
}

handleToggle(e) {
e.stopPropagation();
const { entity } = this.button;

this._isOn = !this._isOn;
this.button.handleToggle();

if (this.timer)
clearTimeout(this.timer);

this.timer = setTimeout(async () => {
if (this.button.entity === entity) {
this._isOn = this.button.isOn;
return this.requestUpdate('_isOn');
}
}, ACTION_TIMEOUT);

return this.requestUpdate('_isOn');
}

render() {
return html`
<ha-icon-button
style=${styleMap(this.button.style)}
.icon=${this.button.icon}
@click=${e => this.handleToggle(e)}
?disabled="${this.button.disabled || this.button.isUnavailable}"
?color=${this._isOn}>
</ha-icon-button>
`;
}

updated(changedProps) {
if (changedProps.has('button')) {
this._isOn = this.button.isOn;

if (this.timer)
clearTimeout(this.timer);

return this.requestUpdate('_isOn');
}
}

static get styles() {
return [
sharedStyle,
css`
:host {
position: relative;
box-sizing: border-box;
margin: 0;
overflow: hidden;
transition: background .5s;
--paper-item-min-height: var(--mh-unit);
--mh-dropdown-unit: var(--mh-unit);
}
:host([color]) {
background: var(--mh-active-color);
transition: background .25s;
opacity: 1;
}
:host([disabled]) {
opacity: .25;
pointer-events: none;
}
`];
}
}

customElements.define('mh-button', HumidifierButton);
Loading

0 comments on commit 21aa0e1

Please sign in to comment.