Skip to content

Commit

Permalink
Merge pull request #677 from basbruss/tab-view
Browse files Browse the repository at this point in the history
Add Adaptive Dashboard
  • Loading branch information
basbruss authored Jun 20, 2022
2 parents 6e37db9 + 62ad3e2 commit a6b5737
Show file tree
Hide file tree
Showing 32 changed files with 940 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
adaptive_ui_enabled: bool = DEFAULT_SIDEPANEL_ENABLED
adaptive_ui_icon: str = DEFAULT_SIDEPANEL_ICON
adaptive_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 adaptive dashboard if not exists and is selected as option
if ulm.configuration.adaptive_ui_enabled:
if not os.path.exists(
hass.config.path(f"{DOMAIN}/dashboard/adaptive-dash")
):
shutil.copytree(
hass.config.path(
f"custom_components/{DOMAIN}/lovelace/adaptive-dash"
),
hass.config.path(f"{DOMAIN}/dashboard/adaptive-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 = "adaptive_ui_enabled"
CONF_SIDEPANEL_ADV_TITLE = "adaptive_ui_title"
CONF_SIDEPANEL_ADV_ICON = "adaptive_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 = "adaptive-dash"
adv_dashboard_config = {
"mode": "yaml",
"icon": ulm.configuration.adaptive_ui_icon,
"title": ulm.configuration.adaptive_ui_title,
"filename": "ui_lovelace_minimalist/dashboard/adaptive-dash/adaptive-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.adaptive_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, "adaptive-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.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.yaml"
Original file line number Diff line number Diff line change
@@ -0,0 +1,169 @@
---
type: "custom:state-switch"
view_layout:
grid-area: "popup"
show:
# only show when screen-width is larger than 1100px
mediaquery: "(min-width: 1100px)"
# add your input_select
entity:
default: "default"
transition: "slide-down"
transition_time: 500
# options set in the input_select
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:

## Rooms
livingroom: !include "../views/livingroom.yaml"
# bedroom: !include "../views/bedroom.yaml"
# bathroom: !include "../views/bathroom.yaml"
# garage: !include "../views/garage.yaml"
# lights: !include "../views/lights.yaml"
Loading

0 comments on commit a6b5737

Please sign in to comment.