Skip to content

Commit

Permalink
Merge pull request #3 from basbruss/popup
Browse files Browse the repository at this point in the history
Add files and python framework
  • Loading branch information
basbruss authored May 30, 2022
2 parents 4c60294 + 813181f commit cda605c
Show file tree
Hide file tree
Showing 17 changed files with 415 additions and 7 deletions.
3 changes: 3 additions & 0 deletions custom_components/ui_lovelace_minimalist/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ class UlmConfiguration:
sidepanel_enabled: bool = DEFAULT_SIDEPANEL_ENABLED
sidepanel_icon: str = DEFAULT_SIDEPANEL_ICON
sidepanel_title: str = DEFAULT_SIDEPANEL_TITLE
advanced_ui_enabled: bool = DEFAULT_SIDEPANEL_ENABLED
advanced_ui_icon: str = DEFAULT_SIDEPANEL_ICON
advanced_ui_title: str = DEFAULT_SIDEPANEL_TITLE
theme_path: str = DEFAULT_THEME_PATH
theme: str = DEFAULT_THEME
plugin_path: str = "www/community/"
Expand Down
15 changes: 15 additions & 0 deletions custom_components/ui_lovelace_minimalist/config_flow.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@
CONF_INCLUDE_OTHER_CARDS,
CONF_LANGUAGE,
CONF_LANGUAGES,
CONF_SIDEPANEL_ADV_ENABLED,
CONF_SIDEPANEL_ADV_ICON,
CONF_SIDEPANEL_ADV_TITLE,
CONF_SIDEPANEL_ENABLED,
CONF_SIDEPANEL_ICON,
CONF_SIDEPANEL_TITLE,
Expand Down Expand Up @@ -54,6 +57,18 @@ def ulm_config_option_schema(options: dict = {}) -> dict:
CONF_SIDEPANEL_ICON,
default=options.get(CONF_SIDEPANEL_ICON, DEFAULT_SIDEPANEL_ICON),
): str,
vol.Optional(
CONF_SIDEPANEL_ADV_ENABLED,
default=options.get(CONF_SIDEPANEL_ADV_ENABLED, DEFAULT_SIDEPANEL_ENABLED),
): bool,
vol.Optional(
CONF_SIDEPANEL_ADV_TITLE,
default=options.get(CONF_SIDEPANEL_ADV_TITLE, DEFAULT_SIDEPANEL_TITLE),
): str,
vol.Optional(
CONF_SIDEPANEL_ADV_ICON,
default=options.get(CONF_SIDEPANEL_ADV_ICON, DEFAULT_SIDEPANEL_ICON),
): str,
vol.Optional(
CONF_THEME, default=options.get(CONF_THEME, DEFAULT_THEME)
): vol.In(CONF_THEME_OPTIONS),
Expand Down
28 changes: 21 additions & 7 deletions custom_components/ui_lovelace_minimalist/configure.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,27 @@ def configure_cards(hass: HomeAssistant, ulm: UlmBase):
language = LANGUAGES[ulm.configuration.language]

# Copy example dashboard file over to user config dir if not exists
if not os.path.exists(hass.config.path(f"{DOMAIN}/dashboard/ui-lovelace.yaml")):
shutil.copy2(
hass.config.path(
f"custom_components/{DOMAIN}/lovelace/ui-lovelace.yaml"
),
hass.config.path(f"{DOMAIN}/dashboard/ui-lovelace.yaml"),
)
if ulm.configuration.sidepanel_enabled:
if not os.path.exists(
hass.config.path(f"{DOMAIN}/dashboard/ui-lovelace.yaml")
):
shutil.copy2(
hass.config.path(
f"custom_components/{DOMAIN}/lovelace/ui-lovelace.yaml"
),
hass.config.path(f"{DOMAIN}/dashboard/ui-lovelace.yaml"),
)
# Copy advanced dashboard if not exists and is selected as option
if ulm.configuration.advanced_ui_enabled:
if not os.path.exists(
hass.config.path(f"{DOMAIN}/dashboard/advanced-dash")
):
shutil.copytree(
hass.config.path(
f"custom_components/{DOMAIN}/lovelace/advanced-dash"
),
hass.config.path(f"{DOMAIN}/dashboard/advanced-dash"),
)
# Copy chosen language file over to config dir
shutil.copy2(
hass.config.path(
Expand Down
3 changes: 3 additions & 0 deletions custom_components/ui_lovelace_minimalist/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@
CONF_SIDEPANEL_ENABLED = "sidepanel_enabled"
CONF_SIDEPANEL_TITLE = "sidepanel_title"
CONF_SIDEPANEL_ICON = "sidepanel_icon"
CONF_SIDEPANEL_ADV_ENABLED = "advanced_ui_enabled"
CONF_SIDEPANEL_ADV_TITLE = "advanced_ui_title"
CONF_SIDEPANEL_ADV_ICON = "advanced_ui_icon"
CONF_THEME = "theme"
CONF_THEME_PATH = "theme_path"
CONF_THEME_OPTIONS = [
Expand Down
19 changes: 19 additions & 0 deletions custom_components/ui_lovelace_minimalist/load_dashboard.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,15 @@ def load_dashboard(hass: HomeAssistant, ulm: UlmBase):
"require_admin": False,
}

adv_dashboard_url = "advanced-dash"
adv_dashboard_config = {
"mode": "yaml",
"icon": ulm.configuration.advanced_ui_icon,
"title": ulm.configuration.advanced_ui_title,
"filename": "ui_lovelace_minimalist/dashboard/advanced-dash/advanced-ui.yaml",
"show_in_sidebar": True,
"require_admin": False,
}
# Optoinal override can be done with config_flow?
# if not dashboard_url in hass.data["lovelace"]["dashboards"]:
if ulm.configuration.sidepanel_enabled:
Expand All @@ -38,3 +47,13 @@ def load_dashboard(hass: HomeAssistant, ulm: UlmBase):
else:
if dashboard_url in hass.data["lovelace"]["dashboards"]:
async_remove_panel(hass, "ui-lovelace-minimalist")

if ulm.configuration.advanced_ui_enabled:
hass.data["lovelace"]["dashboards"][adv_dashboard_url] = LovelaceYAML(
hass, adv_dashboard_url, adv_dashboard_config
)

_register_panel(hass, adv_dashboard_url, "yaml", adv_dashboard_config, True)
else:
if adv_dashboard_url in hass.data["lovelace"]["dashboards"]:
async_remove_panel(hass, "advanced-dash")
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
---
button_card_templates: !include_dir_merge_named "../../../custom_components/ui_lovelace_minimalist/__ui_minimalist__/ulm_templates/"

title: "UI Lovelace Minimalist"
theme: "minimalist-desktop"
background: "var(--background-image)"
views:
- type: "custom:grid-layout"
title: "home"
icon: "mdi:home"
path: "0"
layout:
grid-template-columns: "1fr 1fr"
grid-template-rows: "min-content"
grid-template-areas: |
"main popup"
mediaquery:
"(max-width: 1100px), (orientation: portrait)":
grid-template-columns: "100%"
grid-template-areas: "main"
cards:
- !include "views/main.yaml"
- !include "popup/popup-view.yaml"

- type: "custom:grid-layout"
title: "Livingroom"
icon: "mdi:sofa"
path: "Livingroom"
layout:
grid-template-columns: "1fr 1fr"
grid-template-rows: "min-content"
grid-template-areas: |
"livingroom popup"
mediaquery:
"(max-width: 1100px), (orientation: portrait)":
grid-template-columns: "100%"
grid-template-areas: "livingroom"
cards:
- !include "views/livingroom.yaml"
- !include "popup/popup-view.yaml"
Original file line number Diff line number Diff line change
@@ -0,0 +1,159 @@
---
type: "custom:state-switch"
view_layout:
grid-area: "popup"
show:
mediaquery: "(min-width: 1100px)"
entity:
default: "default"
transition: "slide-down"
transition_time: 500
states:
# Devices
## Lights
light 1:
type: "custom:button-card"
template: "popup_light_brightness"
variables:
ulm_popup_light_entity:
light 2:
type: "custom:button-card"
template: "popup_light_brightness"
variables:
ulm_popup_light_entity:
light 3:
type: "custom:button-card"
template: "popup_light_brightness"
variables:
ulm_popup_light_entity:
light 4:
type: "custom:button-card"
template: "popup_light_brightness"
variables:
ulm_popup_light_entity:
light 5:
type: "custom:button-card"
template: "popup_light_brightness"
variables:
ulm_popup_light_entity:
light 6:
type: "custom:button-card"
template: "popup_light_brightness"
variables:
ulm_popup_light_entity:
light 7:
type: "custom:button-card"
template: "popup_light_brightness"
variables:
ulm_popup_light_entity:
light 8:
type: "custom:button-card"
template: "popup_light_brightness"
variables:
ulm_popup_light_entity:
light 9:
type: "custom:button-card"
template: "popup_light_brightness"
variables:
ulm_popup_light_entity:
light 10:
type: "custom:button-card"
template: "popup_light_brightness"
variables:
ulm_popup_light_entity:

## Mediaplayers
mediaplayer 1:
type: "custom:button-card"
template: "popup_media_player_infos"
variables:
ulm_popup_media_player_entity:
mediaplayer 2:
type: "custom:button-card"
template: "popup_media_player_infos"
variables:
ulm_popup_media_player_entity:
mediaplayer 3:
type: "custom:button-card"
template: "popup_media_player_infos"
variables:
ulm_popup_media_player_entity:
mediaplayer 4:
type: "custom:button-card"
template: "popup_media_player_infos"
variables:
ulm_popup_media_player_entity:
mediaplayer 5:
type: "custom:button-card"
template: "popup_media_player_infos"
variables:
ulm_popup_media_player_entity:

## Thermostats
climate 1:
type: "custom:button-card"
template: "popup_thermostat_temperature"
variables:
ulm_popup_thermostat_entity:
climate 2:
type: "custom:button-card"
template: "popup_thermostat_temperature"
variables:
ulm_popup_thermostat_entity:
climate 3:
type: "custom:button-card"
template: "popup_thermostat_temperature"
variables:
ulm_popup_thermostat_entity:
climate 4:
type: "custom:button-card"
template: "popup_thermostat_temperature"
variables:
ulm_popup_thermostat_entity:
climate 5:
type: "custom:button-card"
template: "popup_thermostat_temperature"
variables:
ulm_popup_thermostat_entity:

## Power
power 1:
type: "custom:button-card"
template: "popup_power_outlet_stats"
variables:
ulm_popup_power_outlet_entity:
ulm_popup_power_outlet_sensor1:
ulm_popup_power_outlet_sensor2:
ulm_popup_power_outlet_graph_sensor:
power 2:
type: "custom:button-card"
template: "popup_power_outlet_stats"
variables:
ulm_popup_power_outlet_entity:
ulm_popup_power_outlet_sensor1:
ulm_popup_power_outlet_sensor2:
ulm_popup_power_outlet_graph_sensor:
power 3:
type: "custom:button-card"
template: "popup_power_outlet_stats"
variables:
ulm_popup_power_outlet_entity:
ulm_popup_power_outlet_sensor1:
ulm_popup_power_outlet_sensor2:
ulm_popup_power_outlet_graph_sensor:
power 4:
type: "custom:button-card"
template: "popup_power_outlet_stats"
variables:
ulm_popup_power_outlet_entity:
ulm_popup_power_outlet_sensor1:
ulm_popup_power_outlet_sensor2:
ulm_popup_power_outlet_graph_sensor:
power 5:
type: "custom:button-card"
template: "popup_power_outlet_stats"
variables:
ulm_popup_power_outlet_entity:
ulm_popup_power_outlet_sensor1:
ulm_popup_power_outlet_sensor2:
ulm_popup_power_outlet_graph_sensor:
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
---
type: "custom:layout-card"
layout_type: "custom:grid-layout"
layout:
grid-template-rows: "min-content"
grid-template-columns: "1fr 1fr 1fr"
grid-template-areas: >
"title title title"
"card1 card1 card1"
"card2 card3 card4"
"card5 card6 ."
"card7 card8 card9"
"card10 card11 card12"
"card13 card14 card15"
"card16 card17 card18"
mediaquery:
# Mobile
"(max-width: 800px)":
grid-template-columns: "1fr 1fr"
grid-template-areas: |
"title title"
"card1 card1"
"card2 card3"
"card4 card5"
"card6 card7"
"card8 card9"
"card10 card11"
"card12 card13"
"card14 card15"
"card16 card17"
"card18 card19"
view_layout:
grid-area: "livingroom"
cards:
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
---
type: "custom:layout-card"
layout_type: "custom:grid-layout"
layout:
# Tablet portrait
grid-template-columns: "1fr 1fr 1fr 1fr 1fr 1fr"
grid-template-areas: |
"text text text weather weather weather"
"person person person weather weather weather"
"welcome welcome welcome welcome welcome welcome"
"title1 title1 title1 title1 title1 title1"
"card1 card1 card2 card2 card3 card3"
"title2 title2 title2 title2 title2 title2"
"card4 card4 card5 card5 card6 card6"
mediaquery:
# Mobile
"(max-width: 800px)":
grid-template-columns: "1fr 1fr"
grid-template-areas: |
"welcome welcome"
"person person"
"title1 title1"
"card1 card2"
"card3 card4"
"title2 title2"
"card5 card6"
"card7 card8"
view_layout:
grid-area: "main"
cards:
Loading

0 comments on commit cda605c

Please sign in to comment.