From 650d8cdc8708c3fbb506ca12073d7448c4ef193a Mon Sep 17 00:00:00 2001 From: kyle Date: Wed, 31 Dec 2025 04:26:21 -0800 Subject: [PATCH] Add browser-mod-automation.yaml --- browser-mod-automation.yaml | 77 +++++++++++++++++++++++++++++++++++++ 1 file changed, 77 insertions(+) create mode 100644 browser-mod-automation.yaml diff --git a/browser-mod-automation.yaml b/browser-mod-automation.yaml new file mode 100644 index 0000000..cc1f9fd --- /dev/null +++ b/browser-mod-automation.yaml @@ -0,0 +1,77 @@ +# Browser Mod Auto-Scroll Automation +# Add this to your Home Assistant automations.yaml or create via UI + +automation: + - alias: "Kiosk Dashboard Auto-Scroll" + description: "Auto-scroll dashboard cards every 5 seconds" + trigger: + - platform: state + entity_id: browser_mod.browser_kiosk + to: "on" + - platform: homeassistant + event: start + condition: + - condition: state + entity_id: browser_mod.browser_kiosk + state: "on" + action: + - delay: "00:00:03" # Wait 3 seconds for page to load + - service: browser_mod.execute_script + target: + entity_id: browser_mod.browser_kiosk + data: + command: | + (function() { + 'use strict'; + console.log('Auto-scroll script starting...'); + + // Get all cards + const cards = Array.from(document.querySelectorAll('ha-card')); + console.log(`Found ${cards.length} cards`); + + if (cards.length === 0) { + console.error('No cards found!'); + return; + } + + // Ensure each card takes full viewport height + cards.forEach((card, index) => { + card.style.minHeight = window.innerHeight + 'px'; + card.style.scrollMarginTop = '0px'; + console.log(`Card ${index + 1}: Set min-height to ${window.innerHeight}px`); + }); + + // Scroll to first card + window.scrollTo({ top: 0, behavior: 'smooth' }); + + let currentIndex = 0; + + // Function to scroll to next card + function scrollToNext() { + currentIndex = (currentIndex + 1) % cards.length; + const targetCard = cards[currentIndex]; + + if (targetCard) { + targetCard.scrollIntoView({ + behavior: 'smooth', + block: 'start', + inline: 'nearest' + }); + console.log(`Scrolled to card ${currentIndex + 1} of ${cards.length}`); + } + } + + // Start auto-scrolling every 5 seconds + const intervalId = setInterval(scrollToNext, 5000); + console.log('Auto-scroll enabled: scrolling every 5 seconds'); + + // Store interval ID for cleanup + window.dashboardScrollInterval = intervalId; + + // Cleanup function (optional) + window.stopAutoScroll = function() { + clearInterval(intervalId); + console.log('Auto-scroll stopped'); + }; + + })();