Advertisement
Guest User

Untitled

a guest
Mar 31st, 2020
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.65 KB | None | 0 0
  1. #Set lovelace to YAML mode to make frontend completly from yaml files instead from gui editor
  2. lovelace:
  3. mode: yaml
  4. resources: !include_dir_merge_list ../../dwains-theme/resources/
  5. dashboards:
  6. dwains-theme:
  7. mode: yaml
  8. title: Dwains Theme
  9. icon: mdi:alpha-d-box
  10. show_in_sidebar: true
  11. filename: dwains-theme-lovelace.yaml
  12.  
  13. #Set frontend for themes and Font Awesome Icons (Note that you dont have frontend: in any other file)
  14. frontend:
  15. #Load dwain themes folder from your HA root folder.
  16. themes: !include_dir_merge_named ../../themes/
  17. extra_html_url:
  18. - /local/dwains-theme/fonts/fontawesome/hass-fontawesome-solid.html
  19. - /local/dwains-theme/fonts/fontawesome/hass-fontawesome-regular.html
  20. # - /local/dwains-theme/fonts/fontawesome/hass-fontawesome-light.html #If have Font Awesome Light uncomment this line
  21.  
  22. #Load browser_mod (https://github.com/thomasloven/hass-browser_mod)
  23. browser_mod:
  24.  
  25. #Dwains theme definitions (this is for doing all the jinja2 inside YAML files)
  26. #You need to have a folder called dwains-theme/configs with all the configuration files inside
  27. dwains_theme:
  28. global:
  29. version: '1.3.0'
  30. styles:
  31. padding-left: '10px'
  32. translations:
  33. !include_dir_merge_named ../../dwains-theme/translations/
  34. configuration:
  35. !include_dir_merge_named ../../dwains-theme/configs/
  36.  
  37. #Sensor for latest version
  38. sensor:
  39. - platform: scrape
  40. resource: https://dwains-theme.dwainscheeren.nl/version?v=1.3.0
  41. name: Dwains Theme Version
  42. select: ".current-version h1"
  43. value_template: '{{ value.split(":")[1] }}'
  44. scan_interval: 3600
  45.  
  46. #Input select
  47. input_select:
  48. #Theme selector
  49. theme_selector:
  50. name: Theme Selector
  51. options:
  52. - Auto Mode (Dark/Light)
  53. - Dark Mode
  54. - Light Mode
  55. - Auto Mode (Black/White)
  56. - Black Mode
  57. - White Mode
  58.  
  59. #Theme automations
  60. automation:
  61. #Theme Selector
  62. - alias: 'themes'
  63. initial_state: 'true'
  64. trigger:
  65. - platform: state
  66. entity_id: input_select.theme_selector
  67. - platform: homeassistant
  68. event: start
  69. - platform: state
  70. entity_id: sun.sun
  71. action:
  72. - service: frontend.set_theme
  73. data_template:
  74. name: >
  75. {% if (is_state('sun.sun', 'above_horizon')) and (is_state('input_select.theme_selector', 'Auto Mode (Dark/Light)')) %}
  76. dwains-theme-light
  77. {% elif (is_state('sun.sun', 'below_horizon')) and (is_state('input_select.theme_selector', 'Auto Mode (Dark/Light)')) %}
  78. dwains-theme-dark
  79. {% elif is_state('input_select.theme_selector', 'Dark Mode') %}
  80. dwains-theme-dark
  81. {% elif is_state('input_select.theme_selector', 'Light Mode') %}
  82. dwains-theme-light
  83. {% elif (is_state('sun.sun', 'above_horizon')) and (is_state('input_select.theme_selector', 'Auto Mode (Black/White)')) %}
  84. dwains-theme-white
  85. {% elif (is_state('sun.sun', 'below_horizon')) and (is_state('input_select.theme_selector', 'Auto Mode (Black/White)')) %}
  86. dwains-theme-black
  87. {% elif is_state('input_select.theme_selector', 'Black Mode') %}
  88. dwains-theme-black
  89. {% elif is_state('input_select.theme_selector', 'White Mode') %}
  90. dwains-theme-white
  91. {% else %}
  92. dwains-theme-light
  93. {% endif %}
  94. #Light Toast notification (Can be extended to all other domains!)
  95. - alias: Notify State Change Light
  96. initial_state: true
  97. trigger:
  98. - platform: event
  99. event_type: state_changed
  100. condition:
  101. - condition: template
  102. value_template: "{{ trigger.event.data.entity_id is not none }}"
  103. - condition: template
  104. value_template: >
  105. {% set domain = trigger.event.data.entity_id.split('.')[0] %}
  106. {% if domain == 'light' %} # << change this domain to get notificatons for other domains
  107. True
  108. {% else %}
  109. False
  110. {% endif %}
  111. - condition: template
  112. value_template: "{{ trigger.event.data.old_state.state != trigger.event.data.new_state.state }}"
  113. - condition: state
  114. entity_id: input_boolean.light_notify # turned on by default???
  115. state: 'on'
  116. action:
  117. - service: browser_mod.toast
  118. data_template:
  119. duration: 6000
  120. message: >-
  121. {% set e = trigger.event.data.entity_id %}
  122. {% set friendly_name = states[e.split('.')[0]][e.split('.')[1]].attributes.friendly_name %}
  123. {{ friendly_name }} turned {{ trigger.event.data.new_state.state }}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement