Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #Set lovelace to YAML mode to make frontend completly from yaml files instead from gui editor
- lovelace:
- mode: yaml
- resources: !include_dir_merge_list ../../dwains-theme/resources/
- dashboards:
- dwains-theme:
- mode: yaml
- title: Dwains Theme
- icon: mdi:alpha-d-box
- show_in_sidebar: true
- filename: dwains-theme-lovelace.yaml
- #Set frontend for themes and Font Awesome Icons (Note that you dont have frontend: in any other file)
- frontend:
- #Load dwain themes folder from your HA root folder.
- themes: !include_dir_merge_named ../../themes/
- extra_html_url:
- - /local/dwains-theme/fonts/fontawesome/hass-fontawesome-solid.html
- - /local/dwains-theme/fonts/fontawesome/hass-fontawesome-regular.html
- # - /local/dwains-theme/fonts/fontawesome/hass-fontawesome-light.html #If have Font Awesome Light uncomment this line
- #Load browser_mod (https://github.com/thomasloven/hass-browser_mod)
- browser_mod:
- #Dwains theme definitions (this is for doing all the jinja2 inside YAML files)
- #You need to have a folder called dwains-theme/configs with all the configuration files inside
- dwains_theme:
- global:
- version: '1.3.0'
- styles:
- padding-left: '10px'
- translations:
- !include_dir_merge_named ../../dwains-theme/translations/
- configuration:
- !include_dir_merge_named ../../dwains-theme/configs/
- #Sensor for latest version
- sensor:
- - platform: scrape
- resource: https://dwains-theme.dwainscheeren.nl/version?v=1.3.0
- name: Dwains Theme Version
- select: ".current-version h1"
- value_template: '{{ value.split(":")[1] }}'
- scan_interval: 3600
- #Input select
- input_select:
- #Theme selector
- theme_selector:
- name: Theme Selector
- options:
- - Auto Mode (Dark/Light)
- - Dark Mode
- - Light Mode
- - Auto Mode (Black/White)
- - Black Mode
- - White Mode
- #Theme automations
- automation:
- #Theme Selector
- - alias: 'themes'
- initial_state: 'true'
- trigger:
- - platform: state
- entity_id: input_select.theme_selector
- - platform: homeassistant
- event: start
- - platform: state
- entity_id: sun.sun
- action:
- - service: frontend.set_theme
- data_template:
- name: >
- {% if (is_state('sun.sun', 'above_horizon')) and (is_state('input_select.theme_selector', 'Auto Mode (Dark/Light)')) %}
- dwains-theme-light
- {% elif (is_state('sun.sun', 'below_horizon')) and (is_state('input_select.theme_selector', 'Auto Mode (Dark/Light)')) %}
- dwains-theme-dark
- {% elif is_state('input_select.theme_selector', 'Dark Mode') %}
- dwains-theme-dark
- {% elif is_state('input_select.theme_selector', 'Light Mode') %}
- dwains-theme-light
- {% elif (is_state('sun.sun', 'above_horizon')) and (is_state('input_select.theme_selector', 'Auto Mode (Black/White)')) %}
- dwains-theme-white
- {% elif (is_state('sun.sun', 'below_horizon')) and (is_state('input_select.theme_selector', 'Auto Mode (Black/White)')) %}
- dwains-theme-black
- {% elif is_state('input_select.theme_selector', 'Black Mode') %}
- dwains-theme-black
- {% elif is_state('input_select.theme_selector', 'White Mode') %}
- dwains-theme-white
- {% else %}
- dwains-theme-light
- {% endif %}
- #Light Toast notification (Can be extended to all other domains!)
- - alias: Notify State Change Light
- initial_state: true
- trigger:
- - platform: event
- event_type: state_changed
- condition:
- - condition: template
- value_template: "{{ trigger.event.data.entity_id is not none }}"
- - condition: template
- value_template: >
- {% set domain = trigger.event.data.entity_id.split('.')[0] %}
- {% if domain == 'light' %} # << change this domain to get notificatons for other domains
- True
- {% else %}
- False
- {% endif %}
- - condition: template
- value_template: "{{ trigger.event.data.old_state.state != trigger.event.data.new_state.state }}"
- - condition: state
- entity_id: input_boolean.light_notify # turned on by default???
- state: 'on'
- action:
- - service: browser_mod.toast
- data_template:
- duration: 6000
- message: >-
- {% set e = trigger.event.data.entity_id %}
- {% set friendly_name = states[e.split('.')[0]][e.split('.')[1]].attributes.friendly_name %}
- {{ friendly_name }} turned {{ trigger.event.data.new_state.state }}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement