resoai / TileBoard

A simple yet highly configurable Dashboard for HomeAssistant
MIT License
1.63k stars 278 forks source link

Automation to launch screensaver #499

Open Poli88 opened 4 years ago

Poli88 commented 4 years ago

Hello, I wanted to make a simple automation to start the screensaver at certain hours. So I added the below in my:

  1. automation.yaml:
- alias: 'Screensaver'
  initial_state: false
  trigger:
    - platform: time_pattern
      minutes: '/1'
  action:
    - event: tileboard
      event_data:
        command: >
          {% if is_state('sensor.time', '08:00') %} 'screen_on'
          {% elif is_state('sensor.time', '00:00') %} 'screen_off'
          {% endif %}
  1. config.js (events)

    {
               command: 'screen_off',
               action: function(e) {
                 if (window.fully) {
                    window.fully.startScreensaver();
                }
               },
             },
             {
              command: 'screen_on',
              action: function(e) {
                if (window.fully) {
                  window.fully.stopScreensaver();
                  window.fully.bringToForeground();
                }
              },
            },
  2. config.js

 screensaver: {
      slidesTimeout: 10, // 10s for one slide
      styles: { fontSize: '50px' },
      leftBottom: [{ type: SCREENSAVER_ITEMS.DATETIME }],
      slides: [
         { bg: 'images/night.jpg' }
      ]
   }, 

Could you help me to understand why the automation cannot send the screensaver command ?

resoai commented 4 years ago

First of allow need to establish if you are actually receiving the event, please try adding alert(1); right after action: function(e) {.

I've also noticed that your automation is tuned off by default (initial_state: false).

And lastly, window.fully.stopScreensaver(); is a function calling internal screensaver of Fully Kiosk browser, not TileBoard one.

Poli88 commented 4 years ago

still nothing. I removed the initial_state and added the alert. But nothing happens. Even if I trigger manually the automation through "Developers tools".

  1. Automation (I modified it in order to manually fire the event):
- alias: 'Screensaver'
  trigger:
    platform: state
    entity_id: input_boolean.home_mode
    from: "on"
    to: "off"
  action:
    - event: tileboard
      event_data:
        command: 'screen_off
  1. Config.js (events)
    {
               command: 'screen_off',
               action: function(e) {
                 alert(1);
                 if (window.fully) {
                    window.fully.startScreensaver();
                }
               },
             },
             {
              command: 'screen_on',
              action: function(e) {
                alert(1);
                if (window.fully) {
                  window.fully.stopScreensaver();
                  window.fully.bringToForeground();
                }
              },

    I'm actually running home assistant on 7" display in kiosk mode. But I would like to trigger the screensaver of tileboard... So no event received...what could be the issue ?