Show dashboards during the day

Having more dashboards configured, is there a way to show automatically them based on the time of the day?
I mean, one for the morning, one for the eventing and so on?

that is possible on several ways.

  1. you could create an app (programming in python) that changes the dashboard
  2. you could create a javascript in the head with a custom skin that changes the dashboard
  3. you could create a custom event in HA that changes the dashboard

Cause of i am completely not a python or javascript programmer at all i will choose the third choice, but i need a little example about it…

all i can give you in that case is the docs.
https://appdaemon.readthedocs.io/en/dev/DASHBOARD_CREATION.html#external-commands

i really have no experience with yaml programming or with HA events or anything like that.

I use an appdaemon app for this.
Create a file named day_night.py in the conf/apps folder and add the following to the file and save it.

import appdaemon.plugins.hass.hassapi as hass

class Navigate(hass.Hass):
# Listen for state changes for the sensor
    def initialize(self):
        self.listen_state(self.day_night_change, self.args["day_night_sensor"])

    def day_night_change(self, entity, attribute, old, new, kwargs):
        # Check if the sensor state is on or off.
        if  new == "on":
            self.dash_navigate("/" + self.args["day_dashboard"])
        elif new == "off":
            self.dash_navigate("/" + self.args["night_dashboard"])

Create a file named apps.yaml in the conf/apps folder and add the following to the file.

day_night_nav:
  class: Navigate
  module: day_night
  day_night_sensor: input_boolean.day_night
  day_dashboard: NAME_OF_DAY_DASHBOARD
  night_dashboard: NAME_OF_NIGHT_DASHBOARD

Create an input_boolean named day_night in Home Assistant.

When you change the state of the input_boolean, the dashboard will navigate to either DayDashboard or NightDashboard. I leave it up to you to make an automation in Home Assistant to change the state of the input_boolean according to the time of day.

This require that you have enabled appdaemon apps in your appdaemon.yaml which I think is the default.

2 Likes

Thanks… in appdaemon.yaml i have as default “disable_apps: 1”.
Must i set this to 0 or what?
And more may i change the name of the dashboards based on mine in the day_night.py app?

Remove the disable_apps line from appdemon.yaml. See the updated script above. Now you can set the name of the night and day dashboards in the apps.yaml file instead of changing the code.

Is this a type or not:
night_daysboard: NAME_OF_NIGHT_DASHBOARD

must be night_daysboard or night_dayboard?

Yes, a typo. See above.

And there is a convenience function in Appdaemon to use for determining if its day or night so it’s strictly not neccesary to use an entity in Home Assistant.

Ah… can you learn me how to have this?

You can use run_at_sunrise() and run_at_sunset() in the initialize function with something like:

self.run_at_sunrise(self.start_day_dashboard)
self.run_at_sunset(self.start_night_dashboard)

You then need functions named start_day_dashboard and start_night_dashboard that calls the dash_navigate function.

If you use fully kiosk browser to view you HADashboard, you could create a command line switch in HA if you just have two dashboards you want to switch between,

- platform: command_line
  switches:
    dashboards:
      command_on: /usr/bin/curl -k "http://192.168.0.2:2323/?cmd=loadURL&url=http://192.168.0.1:5050/Dashboard1?password=password"
      command_off: /usr/bin/curl -k "http://192.168.0.2:2323/?cmd=loadURL&url=http://192.168.0.1:5050/Dashboard2?password=password"

This is the ip of the tablet fully is running on, and then the url of the dashboard you want to load.

If you have more dashboards you want to use, can just setup some more switches. Then just setup automations to run them at whatever times you want.

Very useful, thanks