Hi Everyone,
all I wanted is to have a sensor that reads a value from a website.
url: https://www.bonbast.com
CSS_Selector: #eur1
I did not succeed with Scrape and Multriscrape.
I have written a python script in studio code server and it works there. (I had to install the chrome and chromedriver in order to get selenium worked and I was so doom that I didnt noticed it that its an Ubuntu and HA is based on alpine)
I have changed a little bit in order to use the script in AppDaemon but I can see in AppDaemon Log that I have there still dependencies problems.
Is there any way to ssh in AppDaemon? (in order to install chrome and chromedriver)
Or could you guys suggest me another solutions?
my python script looks like this:
import appdaemon.plugins.hass.hassapi as hass
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.common.by import By
class bonbast(hass.Hass):
def initialize(self):
self.log("Bonbast scrape started")
self.run_in(self.update, 0)
# update every minute
self.run_every(self.update, "now", 60)
def update(self, kwargs):
self.log("Bonbast update started")
chrome_options = webdriver.ChromeOptions()
chrome_options.add_argument('--no-sandbox')
chrome_options.add_argument('--headless')
chrome_options.add_argument('--disable-dev-shm-usage')
driver = webdriver.Chrome(options=chrome_options)
driver.get('https://www.bonbast.com')
eur = driver.find_element(By.CSS_SELECTOR, '#eur1').get_attribute("innerHTML")
usd = driver.find_element(By.CSS_SELECTOR, '#usd1').get_attribute("innerHTML")
driver.quit()
entity = "sensor.bonbast_eur"
self.set_state(entity, state=eur)
entity = "sensor.bonbast_usd"
self.set_state(entity, state=usd)
Best Regards, Shahram