I would like to employ this python script which runs nicely on my Windows PC also in HA (2022.7.3):
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.chrome.service import Service as ChromeService
from webdriver_manager.chrome import ChromeDriverManager
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
chrome_options = Options()
chrome_options.add_argument('--headless')
chrome_options.add_argument('--no-sandbox')
chrome_options.add_argument('--disable-gpu')
chrome_options.add_argument('--disable-dev-shm-usage')
driver = webdriver.Chrome(service=ChromeService(ChromeDriverManager().install()), options=chrome_options)
driver.get('http://192.168.2.1/html/login/status.html')
try:
element = WebDriverWait(driver, 20).until(
EC.visibility_of_element_located((By.ID, 'var_dsl_downstream'))
)
finally:
print(element.text)
driver.quit()
I tried doing this will AppDaemon (0.9.0) but even this short script::
import hassapi as hass
from selenium import webdriver
from selenium.webdriver.chrome.service import Service as ChromeService
from webdriver_manager.chrome import ChromeDriverManager
class SpeedRead(hass.Hass):
def initialize(self):
driver = webdriver.Chrome(service=ChromeService(ChromeDriverManager().install()))
fails with these errors:
2022-07-12 23:54:09.944709 WARNING Speed_Read: ------------------------------------------------------------
2022-07-12 23:54:09.945267 WARNING Speed_Read: Unexpected error running initialize() for Speed_Read
2022-07-12 23:54:09.945575 WARNING Speed_Read: ------------------------------------------------------------
2022-07-12 23:54:09.954721 WARNING Speed_Read: Traceback (most recent call last):
File â/usr/lib/python3.10/site-packages/appdaemon/app_management.pyâ, line 165, in initialize_app
await utils.run_in_executor(self, init)
File â/usr/lib/python3.10/site-packages/appdaemon/utils.pyâ, line 337, in run_in_executor
response = future.result()
File â/usr/lib/python3.10/concurrent/futures/thread.pyâ, line 58, in run
result = self.fn(*self.args, **self.kwargs)
File â/config/appdaemon/apps/speedread.pyâ, line 23, in initialize
driver = webdriver.Chrome(service=ChromeService(ChromeDriverManager().install()))
File â/usr/lib/python3.10/site-packages/selenium/webdriver/chrome/webdriver.pyâ, line 69, in init
super().init(DesiredCapabilities.CHROME[âbrowserNameâ], âgoogâ,
File â/usr/lib/python3.10/site-packages/selenium/webdriver/chromium/webdriver.pyâ, line 89, in init
self.service.start()
File â/usr/lib/python3.10/site-packages/selenium/webdriver/common/service.pyâ, line 71, in start
self.process = subprocess.Popen(cmd, env=self.env,
File â/usr/lib/python3.10/subprocess.pyâ, line 966, in init
self._execute_child(args, executable, preexec_fn, close_fds,
File â/usr/lib/python3.10/subprocess.pyâ, line 1842, in _execute_child
raise child_exception_type(errno_num, err_msg, err_filename)
OSError: [Errno 8] Exec format error: â/root/.wdm/drivers/chromedriver/linux64/103.0.5060/chromedriverâ
2022-07-12 23:54:09.955187 WARNING Speed_Read: ------------------------------------------------------------
I also tried with ChromiumService plus the chrome type information (which also works on my PC) but same problem. What am I doing wrong? Any help would be highly appreciated!
Added later:
Add-on: AppDaemon
Python Apps and Dashboard using AppDaemon 4.x for Home Assistant
Add-on version: 0.9.0
You are running the latest version of this add-on.
System: Home Assistant OS 8.2 (aarch64 / odroid-n2)
Home Assistant Core: 2022.7.3
Home Assistant Supervisor: 2022.07.0