Skip to content

Commit

Permalink
Merge pull request #16 from artem-sedykh/dev
Browse files Browse the repository at this point in the history
1.0.8
  • Loading branch information
artem-sedykh authored May 20, 2020
2 parents 93d3d20 + a1b50fb commit 8a7c77c
Show file tree
Hide file tree
Showing 13 changed files with 219 additions and 37 deletions.
30 changes: 27 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.7
- url: /local/mini-humidifier-bundle.js?v=1.0.8
type: module
```
Expand All @@ -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.7
- url: /local/mini-humidifier-bundle.js?v=1.0.8
type: module
```

Expand All @@ -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.7
- url: /local/mini-humidifier-bundle.js?v=1.0.8
type: module
```

Expand Down Expand Up @@ -144,6 +144,7 @@ Inspired by [mini media player](https://github.com/kalkih/mini-media-player).
| toggle_button: `default` | boolean | optional | v1.0.5 | Default toggle_button state, default value `off`, [example](#always-show-control-buttons).
| **depth** | object | optional | v1.0.1 | Information indicator, showing how much water is left in the humidifier
| depth: `icon` | string | optional | v1.0.1 | Custom icon, default value `mdi:beaker-outline`
| depth: `icon_template` | string | optional | v1.0.8 | Custom icon template, context values: `depth`(calculated value) and `raw`(raw depth value) [example](#icon-template-example)
| depth: `hide` | boolean | optional | v1.0.1 | Hide indicator, default value `False`
| 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`
Expand All @@ -153,6 +154,7 @@ Inspired by [mini media player](https://github.com/kalkih/mini-media-player).
| depth: `fixed` | number | optional | v1.0.1 | Rounding the calculated values, default value `0`
| **temperature** | object | optional | v1.0.1 | Information indicator, showing temperature
| temperature: `icon` | string | optional | v1.0.1 | Custom icon, default value `mdi:thermometer-low`
| temperature: `icon_template` | string | optional | v1.0.8 | Custom icon template, context value: `temperature`
| 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`
Expand All @@ -162,6 +164,7 @@ Inspired by [mini media player](https://github.com/kalkih/mini-media-player).
| 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
| **humidity** | object | optional | v1.0.1 | Information indicator, showing humidity
| humidity: `icon` | string | optional | v1.0.1 | Custom icon, default value `mdi:water-outline`
| humidity: `icon_template` | string | optional | v1.0.8 | Custom icon template, context value: `humidity`
| 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 `%`
Expand All @@ -171,6 +174,7 @@ Inspired by [mini media player](https://github.com/kalkih/mini-media-player).
| 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
| **target_humidity** | object | optional | v1.0.1 | Target humidity
| target_humidity: `icon` | string | optional | v1.0.1 | Custom icon, default value `mdi:water-outline`
| target_humidity: `icon_template` | string | optional | v1.0.8 | Custom icon template, context value: `targetHumidity`
| target_humidity: `hide` | boolean | optional | v1.0.1 | Hide indicator, default value `False`
| target_humidity: `unit` | string | optional | v1.0.1 | display unit, default `%`
| target_humidity: `min` | number | optional | v1.0.1 | minimum target humidity, default value `30` [see](https://www.home-assistant.io/integrations/fan.xiaomi_miio/)
Expand Down Expand Up @@ -423,6 +427,26 @@ For use Entities card you need to add `group: on`
```


#### icon template example

when changing `depth` value we change the icon
```yaml
- type: custom:mini-humidifier
entity: fan.xiaomi_miio_device
depth:
icon_template: >
{% if depth < 10 %}
<ha-icon class='state__value_icon' icon='mdi:tray-alert' style='color: #bd1c1c;'></ha-icon>
{% elseif depth < 45 %}
<ha-icon class='state__value_icon' icon='mdi:tray-minus'></ha-icon>
{% else %}
<ha-icon class='state__value_icon' icon='mdi:tray-full'></ha-icon>
{% endif %}
```
used plugin [jinja-js](https://github.com/sstur/jinja-js)

<img src="https://user-images.githubusercontent.com/861063/82473688-a1685380-9ad2-11ea-9f7f-ba094f1e2d27.png" alt="expample"/>


## 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.*
Expand Down
81 changes: 69 additions & 12 deletions package-lock.json

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

8 changes: 5 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.7",
"version": "v1.0.8",
"description": "humidifier card for Home Assistant Lovelace UI",
"keywords": [
"home-assistant",
Expand All @@ -17,6 +17,7 @@
"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,11 +30,12 @@
"@babel/plugin-transform-template-literals": "^7.2.0",
"@babel/preset-env": "^7.3.1",
"babel-plugin-iife-wrap": "^1.1.0",
"babel-preset-minify": "^0.5.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": "^0.66.6",
"rollup": "^2.10.5",
"rollup-plugin-commonjs": "^10.1.0",
"rollup-plugin-node-resolve": "^3.4.0"
},
"scripts": {
Expand Down
2 changes: 1 addition & 1 deletion release_notes/v1.0.7.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
## 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)
[![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
Expand Down
27 changes: 27 additions & 0 deletions release_notes/v1.0.8.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
## v1.0.8
[![Downloads](https://img.shields.io/github/downloads/artem-sedykh/mini-humidifier/v1.0.8/total.svg)](https://github.com/artem-sedykh/mini-humidifier/releases/tag/v1.0.8)
### ADDED
- Added `humidity: icon_template` icon template for humidity indicator, a simple template engine is used [jinja-js](https://github.com/sstur/jinja-js)
- Added `target_humidity: icon_template` icon template for target_humidity indicator, a simple template engine is used [jinja-js](https://github.com/sstur/jinja-js)
- Added `temperature: icon_template` icon template for temperature indicator, a simple template engine is used [jinja-js](https://github.com/sstur/jinja-js)
- Added `depth: icon_template` icon template for temperature indicator, a simple template engine is used [jinja-js](https://github.com/sstur/jinja-js)

#####Example
```yaml
- type: custom:mini-humidifier
entity: fan.xiaomi_miio_device
depth:
icon_template: >
{% if depth < 10 %}
<ha-icon class='state__value_icon' icon='mdi:tray-alert' style='color: #bd1c1c;'></ha-icon>
{% elseif depth < 45 %}
<ha-icon class='state__value_icon' icon='mdi:tray-minus'></ha-icon>
{% else %}
<ha-icon class='state__value_icon' icon='mdi:tray-full'></ha-icon>
{% endif %}
```
### CHANGED
- styles
- `humidity:icon` changed default icon from `mdi:water-outline` to `mdi:water`
- `depth:icon` changed default icon from `mdi:beaker-outline` to `mdi:tray-full`
2 changes: 2 additions & 0 deletions rollup.config.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import resolve from 'rollup-plugin-node-resolve';
import commonjs from 'rollup-plugin-commonjs';

export default {
input: 'src/main.js',
Expand All @@ -9,5 +10,6 @@ export default {
},
plugins: [
resolve(),
commonjs(),
],
};
25 changes: 19 additions & 6 deletions src/components/info.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { LitElement, html, css } from 'lit-element';
import { unsafeHTML } from 'lit-html/directives/unsafe-html';

class MiniHumidifierInfo extends LitElement {
static get properties() {
Expand All @@ -10,29 +11,40 @@ class MiniHumidifierInfo extends LitElement {
}

renderDepth(context) {
const icon = context.config.depth.icon_template
? unsafeHTML(context.humidifier.depthIcon)
: html`<ha-icon class='state__value_icon' .icon=${context.config.depth.icon}></ha-icon>`;

return html`
<div class='state depth'>
<ha-icon class='state__value_icon' .icon=${context.config.depth.icon}></ha-icon>
${icon}
<span class='state__value'>${context.humidifier.depth}</span>
<span class='state__uom'>${context.config.depth.unit}</span>
</div>
`;
}

renderTemperature(context) {
const icon = context.config.temperature.icon_template
? unsafeHTML(context.humidifier.temperatureIcon)
: html`<ha-icon class='state__value_icon' .icon=${context.config.temperature.icon}></ha-icon>`;

return html`
<div class='state temperature'>
<ha-icon class='state__value_icon' .icon=${context.config.temperature.icon}></ha-icon>
${icon}
<span class='state__value'>${context.humidifier.temperature}</span>
<span class='state__uom'>${context.config.temperature.unit}</span>
</div>
`;
}

renderHumidity(context) {
const icon = context.config.humidity.icon_template
? unsafeHTML(context.humidifier.humidityIcon)
: html`<ha-icon class='state__value_icon' .icon=${context.config.humidity.icon}></ha-icon>`;
return html`
<div class='state humidity'>
<ha-icon class='state__value_icon' .icon=${context.config.humidity.icon}></ha-icon>
${icon}
<span class='state__value'>${context.humidifier.humidity}</span>
<span class='state__uom'>${context.config.humidity.unit}</span>
</div>
Expand Down Expand Up @@ -66,8 +78,8 @@ class MiniHumidifierInfo extends LitElement {
box-sizing: border-box;
min-width: 0;
overflow: hidden;
font-size: calc(var(--mh-unit) * .325);
line-height: calc(var(--mh-unit) / 2);
font-size: calc(var(--mh-unit) * .35);
line-height: calc(var(--mh-unit) * .35);
}
.mh-humidifier-state__container {
display: flex;
Expand All @@ -80,13 +92,14 @@ class MiniHumidifierInfo extends LitElement {
}
.state__value_icon {
height: calc(var(--mh-unit) * .475);
width: calc(var(--mh-unit) * .425);
width: calc(var(--mh-unit) * .5);
color: var(--mh-icon-color);
--mdc-icon-size: calc(var(--mh-unit) * .425);
}
.state__value {
margin: 0 1px;
font-weight: var(--mh-info-font-weight);
line-height: calc(var(--mh-unit) * .475);
}
.state__uom {
font-size: calc(var(--mh-unit) * .275);
Expand Down
Loading

0 comments on commit 8a7c77c

Please sign in to comment.