From 30f0d170e57afcb722e232499d7e67e90ecf8c34 Mon Sep 17 00:00:00 2001 From: Erik Stambaugh Date: Sat, 30 Mar 2024 11:36:33 -0700 Subject: [PATCH] Make HASS button show a logo before loading --- ...ome-assistant-social-media-logo-square.png | Bin 0 -> 5400 bytes inkybot.py | 28 ++++++++++++------ 2 files changed, 19 insertions(+), 9 deletions(-) create mode 100644 img/home-assistant-social-media-logo-square.png diff --git a/img/home-assistant-social-media-logo-square.png b/img/home-assistant-social-media-logo-square.png new file mode 100644 index 0000000000000000000000000000000000000000..09929fab91e4dec378d2b175d0feac61b0f634a1 GIT binary patch literal 5400 zcmeHL=U-FH*4~Lx65#*=uLMDXfFPn0qzF@~A~v)6jo#M|R6f7^d( zKL7x~S)Dg?0079i;DPT0k;u>VC*TV~JpX$D00>J89te<`jRHYPfPtuob>YjDGgyU??N?{oZ#d)Zarf zo|TfUAc+mJH|wpxcW_JQ>(y z0zmeW0jLN7fuR5>{J(_%1Agd092@ftQ}BNEcc5R8YL47V+B+4;vxeIqLrq-Qn(a{a z$eruz-bP>TvfSpBpOS=cW$8yCjyZ^O@+(?a7KZx<8w}5ja=UUy1A`(SRpx!IeRcsV za=*Pda(8Z`X|q59kdf;n;c6DSclpDQ3o&ra7t|&9INFWa%q5+8>0(K+6v^rI9iIa13nr zI9(GhazmT|{~Sc}Fhj8r7+8D)=K&mh0ulrCa&wUGaf*yjWe$S5;#l%CY<^3K1?5=; zROGO#wqWk41mTAXTR{Ag3}8F>5`s_rz%k`7eFdOr9)Pvs9}JMR0sae-bG`lp0Q;y zqr)mc)F8B~KjVCp7dRYTUsr7ZkK}dHRnCLIr21M0r3&2oImJ!en@D%QkGprk4DpKg zf$KlGb$(HgN^j$7jtitLkK6}L;}2TAdNm|11x6i{_9s=*Y&zw(nCY9$tTgPF?+k7( zN)8Qd^xi|Ek@Id*+LyG!L<-p#N_JM6r?1^gH6_vRD)e|%5WX?*8Rvrppvyg$4( z#EBKCFHdAOZAJvzQt29yeqq)~_N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KpLvrih@k+-c5d8}d+kL0N#BFndc(s-OQc4X2*fUX!NyZ6M=kSiABi*PAdW#N`IpVL$kWtD`yYTk2}S?_ literal 0 HcmV?d00001 diff --git a/inkybot.py b/inkybot.py index 7e6c884..b411858 100755 --- a/inkybot.py +++ b/inkybot.py @@ -222,7 +222,7 @@ inkybot = Inkybot() class PictureMode(inkybot.StateClass): button_text = [ "󰸋", - "", + "󰟐", "", "󱧾" ] @@ -301,6 +301,8 @@ class HassMode(inkybot.StateClass): refresh_target = 0.0 screen_scale = 1.0 + hass_logo = "img/home-assistant-social-media-logo-square.png" + def button_b(self): self.change_state('picture') @@ -310,7 +312,17 @@ class HassMode(inkybot.StateClass): self.refresh_target = time.time() + 5 def enter(self): - #self.clear("blue") + # show the logo so we know the button worked! + # XXX refactor this stuff into a letterbox-from-file function somewhere + image = Image.open(self.hass_logo) + resizedimage = self.parent.resize_with_letterbox( + image, + self.parent.inky.resolution, + self.parent.average_outer_perimeter_color(image) + ) + self.parent.inky.set_image(resizedimage, saturation=self.saturation) + self.parent.inky.show() + url = "http://localhost:8123/lovelace/1?kiosk" print(f"launching selenium and loading {url}") @@ -322,20 +334,18 @@ class HassMode(inkybot.StateClass): options.add_argument('--disable-dev-shm-usage') # Overcome limited resource problems options.add_argument('--disable-extensions') # Disabling extensions can save resources options.add_argument('--disable-plugins') # Disable plugins - self.driver = webdriver.Chrome(service=service, options=options) + driver = webdriver.Chrome(service=service, options=options) width,height = [self.screen_scale * x for x in self.parent.inky.resolution] - #width -= self.font_size - self.driver.set_window_size(width,height) + driver.set_window_size(width,height) - self.driver.get(url) + driver.get(url) print("waiting for login button...") - login_button = WebDriverWait(self.driver, 5).until(EC.visibility_of_element_located((By.CSS_SELECTOR, "mwc-button"))) - #self.driver.execute_script("document.body.style.fontSize = 'larger';") # font scaling + login_button = WebDriverWait(driver, 5).until(EC.visibility_of_element_located((By.CSS_SELECTOR, "mwc-button"))) login_button.click() - self.update() self.refresh_target = time.time() + 5 + self.driver = driver def update(self): if self.driver is not None: