Skip to content

Commit

Permalink
Update Dwains Theme 1.3.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Klumpke committed Apr 3, 2020
1 parent 7283488 commit 687dbbc
Show file tree
Hide file tree
Showing 7 changed files with 284 additions and 17 deletions.
6 changes: 6 additions & 0 deletions dwains-theme/configs/rooms.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ rooms:
light: group.woonkamer_lights
temperature: sensor.temp_woonkamer
humidity: sensor.temp_woonkamer_humidity
pressure: sensor.temp_woonkamer_pressure
motion: binary_sensor.motion_woonkamer
media_player: media_player.tv_woonkamer
addons:
Expand Down Expand Up @@ -62,6 +63,7 @@ rooms:
light: group.slaapkamer_lights
temperature: sensor.temp_slaapkamer
humidity: sensor.temp_slaapkamer_humidity
pressure: sensor.temp_slaapkamer_pressure
motion: binary_sensor.motion_slaapkamer
window: binary_sensor.contact_slaapkamerraam
cover: cover.slaapkamer
Expand All @@ -72,6 +74,7 @@ rooms:
light: light.kleine_kamer
temperature: sensor.temp_kleine_kamer
humidity: sensor.temp_kleine_kamer_humidity
pressure: sensor.temp_kleine_kamer_pressure
addons:
- name: Printer
icon: fal:print
Expand All @@ -91,11 +94,13 @@ rooms:
light: light.logeerkamer
temperature: sensor.temp_logeerkamer
humidity: sensor.temp_logeerkamer_humidity
pressure: sensor.temp_logeerkamer_pressure

- name: Badkamer
icon: fal:bath
temperature: sensor.temp_badkamer
humidity: sensor.temp_badkamer_humidity
pressure: sensor.temp_badkamer_pressure

- name: Garage
icon: fal:warehouse
Expand All @@ -104,6 +109,7 @@ rooms:
humidity: sensor.temp_garage_humidity
motion: binary_sensor.motion_garage
door: binary_sensor.contact_garagedeur
#media_player: media_player.eetkamer

- name: Hal
icon: fal:key-skeleton
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,7 @@ header_weather:
]]]
entity: {{ _d_t_config.global["weather"] }}
tap_action:
!include
- ../../../../views/popups/weather.yaml
- entity: {{ _d_t_config.global["weather"] }}
action: more-info
state:
- value: clear-night
icon: mdi:weather-night
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
room_climate_info:
show_name: true
show_icon: true
show_state: true
show_label: false
show_last_changed: true
color: 'auto'
styles:
grid:
- grid-template-areas: '"i n""i s""i l"'
- grid-template-columns: 30% 70%
- grid-template-rows: min-content
card:
- background-color: var(--dwains-theme-primary)
- border-radius: 5px
- margin-bottom: 0px
- padding-top: 14px
- padding-bottom: 14px
icon:
- width: 55%
img_cell:
- width: 45px
- height: 45px
- border-radius: 100%
name:
- color: var(--dwains-theme-names)
- justify-self: start
- font-size: 15px
- align-self: center
state:
- justify-self: start
- align-self: left
- font-size: 13px
- color: var(--dwains-theme-grey)
label:
- justify-self: start
- align-self: left
- font-size: 12px
- color: var(--dwains-theme-grey)
double_tap_action:
action: toggle
haptic: light
1 change: 1 addition & 0 deletions dwains-theme/views/main/01.homepage.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@
}
card:
type: custom:swipe-card
card_width: '62px'
cards:
{% if _d_t_config.persons %}
{% for person in _d_t_config.persons %}
Expand Down
11 changes: 7 additions & 4 deletions dwains-theme/views/main/more_page/settings.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,6 @@
padding: true
items_classes: 'col-xs-12 col-sm-6 col-md-3 col-lg-3'
cards:
#heading
- !include
- ../../partials/heading.yaml
- title: Dwains Theme
- type: custom:button-card
template: more_page_list-item
entity: sensor.dwains_theme_version
Expand Down Expand Up @@ -59,6 +55,10 @@
}
}
]]]
#heading
- !include
- ../../partials/heading.yaml
- title: "{{ _d_t_trans.more_page.settings.title }}"
- type: entities
style: |
ha-card {
Expand All @@ -76,6 +76,9 @@
tap_action:
action: call-service
service: dwains_theme.reload
- !include
- ../../partials/heading.yaml
- title: Dwains Theme
- type: custom:button-card
template: more_page_list-item
name: {{ _d_t_trans.more_page.settings.theme_docs }}
Expand Down
33 changes: 23 additions & 10 deletions dwains-theme/views/main/rooms/room/climate.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -134,16 +134,24 @@
- color: var(--dwains-theme-names)
{% endfor %}
{% elif room["temperature"] %}
- type: markdown
style: |
ha-card {
box-shadow: none;
background: none;
font-size: 50px;
text-align: center;
}
content: >
{% raw %}{{ states('{% endraw %}{{ room["temperature"] }}{% raw %}') }}{% endraw %} °C
- type: custom:dwains-flexbox-card
cards:
- type: custom:button-card
item_classes: 'col-xs-12'
template: room_climate_info
entity: {{ room["temperature"] }}
{% if room["humidity"] %}
- type: custom:button-card
item_classes: 'col-xs-6'
template: room_climate_info
entity: {{ room["humidity"] }}
{% endif %}
{% if room["pressure"] %}
- type: custom:button-card
item_classes: 'col-xs-6'
template: room_climate_info
entity: {{ room["pressure"] }}
{% endif %}
{% endif %}

#Start of graphs
Expand Down Expand Up @@ -174,6 +182,11 @@
show_indicator: true
name: {{ _d_t_trans.climate.humidity }}
{% endif %}
{% if room["pressure"] %}
- entity: {{ room["pressure"] }}
show_state: true
show_indicator: true
{% endif %}
graph: line
show:
icon: false
Expand Down
204 changes: 204 additions & 0 deletions www/dwains-theme/plugins/dwains-swipe-card/dwains-swipe-card.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,204 @@
import {
LitElement,
html,
css
} from "https://unpkg.com/[email protected]/lit-element.js?module";

const VERSION = '0.0.1';

class DwainsSwipeCard extends LitElement {
static get properties() {
return {
_config: {},
_cards: {},
_hass: {}
};
}

async setConfig(config) {
if (!config
&& ((!config.cards && !Array.isArray(config.cards))
|| (!config.entities || !Array.isArray(config.entities)) )
) {
throw new Error('Card config incorrect');
}
this._config = config;
this._refCards = [];

if (window.loadCardHelpers) {
this.helpers = await window.loadCardHelpers();
}

this.renderCard();

this._transform = null;
}

renderCard() {
const config = this._config;
if(config.entities){
const promises = config.entities.map(config => this.createCardElement(config));
Promise.all(promises).then((cards) => {
this._refCards = cards;
//Removed some code here
})
} else {
const promises = config.cards.map(config => this.createCardElement(config));
Promise.all(promises).then((cards) => {
this._refCards = cards;
//Removed some code here
})
}
}

async createCardElement(cardConfig) {
const createError = (error, config) => {
return createThing('hui-error-card', {
type: 'error',
error,
config,
});
};

const createThing = (tag, config) => {
if (this.helpers) {
return this.helpers.createCardElement(config);
}

const element = document.createElement(tag);

try {
element.setConfig(config);
} catch (err) {
console.error(tag, err);
return createError(err.message, config);
}
return element;
};

let tag = cardConfig.type;
if (tag.startsWith('divider')) {
tag = `hui-divider-row`;
} else if (tag.startsWith('custom:')) {
tag = tag.substr('custom:'.length);
} else {
tag = `hui-${tag}-card`;
}

const element = createThing(tag, cardConfig);

if(cardConfig.item_classes){
//console.log(cardConfig.grid);
element.className = "item " + cardConfig.item_classes;
} else {
if(this._config.items_classes){
element.className = "item " + this._config.items_classes;
} else {
element.className = "item";
}
}

element.hass = this._hass;
element.addEventListener(
'll-rebuild',
ev => {
ev.stopPropagation();
this.createCardElement(cardConfig).then(() => {
this.renderCard();
});
},
{ once: true },
);
return element;
}

set hass(hass) {
this._hass = hass
if (this._refCards) {
this._refCards.forEach((card) => {
card.hass = hass;
});
}
}

firstUpdated(){
this.addEventListener('mousedown', this.mouseDown, false);
this.addEventListener('touchestart', this.mouseDown, false);

this.addEventListener('mouseup', this.mouseUp, false);
this.addEventListener('toucheend', this.mouseUp, false);
}

updateDivPosition (event) {
//var divRect = div.getBoundingClientRect()
//var startX = seekbar.getBoundingClientRect().left
var mouseX = event.clientX
//div.style.transform = 'translateX(' + (mouseX - startX) + 'px)'
this._transform = mouseX;
console.log(mouseX);
//div.style.left = mouseX - startX + 'px';
}

mouseUp() {
console.log('mouseup')
window.removeEventListener('mousemove', this.updateDivPosition, true);
}

mouseDown() {
console.log('mousedown');
window.addEventListener('mousemove', this.updateDivPosition, true);
}

render() {
if (!this._config || !this._hass || !this._refCards) {
return html``;
}

return html`
<div class="glider">
<div class="glider-track" style="transform: translateX('${this._transform}')">
${this._refCards}
</div>
</div>
`;
}

static get styles() {
return [
css`
.glider {
background: red;
}
.glider {
margin: 0 auto;
position: relative;
overflow-x: hidden;
overflow-y: hidden;
}
.glider-track {
width: 100%;
margin: 0;
padding: 0;
display: flex;
z-index: 1;
}
.item {
pointer-events: none;
}
`
];
}

getCardSize() {
return 3;
}
}

if(!customElements.get("dwains-swipe-card")) {
customElements.define("dwains-swipe-card", DwainsSwipeCard);
console.info(
`%c DWAINS-SWIPE-CARD \n%c Version ${VERSION} `,
'color: #2fbae5; font-weight: bold; background: black',
'color: white; font-weight: bold; background: dimgray',
);
}

0 comments on commit 687dbbc

Please sign in to comment.