basnijholt / lovelace-ios-themes

❤️📱🏠🤖 Themes inspired by iOS Dark ⬛️ and Light ◻️ Mode for Lovelace Home Assistant with different backgrounds
MIT License
635 stars 83 forks source link

Frontend automation does not want to work #32

Open anoril1979 opened 2 years ago

anoril1979 commented 2 years ago

Hi!

I've just installed ios-themes. Themes appear in the theme dropdown in the user parameters. Themes are well applied from there.

I then added your frontend automation file. Automations are well listed in my automation list. But when I click on "execute", nothing happens. I set the entities panel with the theme selector input, aside with dark mode toggle and alternative theme toggle. Every thing is well presented on my lovelace. But when I selected a theme from the drop down list, toggle the dark mode knob or the laternative knob, nothing happens.

Using HA 2021.8.8, User Interface 20210909.0

System Health

version core-2021.8.8
installation_type Home Assistant Core
dev false
hassio false
docker false
user sc-homeassistant
virtualenv true
python_version 3.8.11
os_name Linux
os_version 4.4.59+
arch aarch64
timezone Europe/Paris
Home Assistant Community Store GitHub API | ok -- | -- Github API Calls Remaining | 4951 Installed Version | 1.15.2 Stage | running Available Repositories | 877 Installed Repositories | 4
Home Assistant Cloud logged_in | false -- | -- can_reach_cert_server | ok can_reach_cloud_auth | ok can_reach_cloud | ok
Lovelace dashboards | 2 -- | -- resources | 2 error | /volume1/@appstore/homeassistant/var/config/ui-lovelace.yaml not found views | 2 mode | storage
metbril commented 2 years ago

Bas's frontend automations use a different set of theme files.

https://github.com/basnijholt/home-assistant-config/blob/ae69265f1b9bb904e884e985b99d5d2cbaa77f82/automations/frontend.yaml#L33

Try this instead:

automation:
  - alias: "Frontend: change theme"
    trigger:
      - platform: state
        entity_id: input_select.theme
      - platform: state
        entity_id: input_boolean.dark_mode
      - platform: state
        entity_id: input_boolean.theme_alternative
      - platform: homeassistant
        event: start
    action:
      - service: frontend.set_theme
        data:
          name: >
            {% set name = states("input_select.theme") -%}
            {% set mode = "dark" if is_state("input_boolean.dark_mode", "on") else "light" %}
            {% set suffix = "-alternative" if is_state("input_boolean.theme_alternative", "on") else "" -%}
            ios-{{ mode }}-mode-{{ name }}{{ suffix }}