-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Probleme configuration yaml #1
Comments
Bonjour, Aujourd'hui, j'utilise un script qui tourne sur un autre serveur, il se connecte tous les jours à la Sieva, télécharge en csv la consommation de chaque jour, fait la somme globale et envoie à mon instance Home Assistant la valeur totale en m3 grâce à l'API Home Assistant. Je vous mets le code ici, si ça peut aider ou si vous avez la motivation de recréer une intégration Home Assistant. import base64
import functions_framework
from os import getenv
import csv
from requests_html import HTMLSession
import time
import requests
def get_consumption():
sieva = Sieva(getenv("LOGIN"), getenv("PASSWORD"), getenv("PI"))
m3 = sieva.get_consumption()
print(m3)
post_state(m3)
class Sieva:
def __init__(self, login, password, delivery_point):
"""Init sieva class
Args:
login: login
password: password
delivery_point: delivery point identifier
"""
self.login = login
self.password = password
self.delivery_point = delivery_point
def get_consumption(self):
session = HTMLSession(verify=False)
# Login
login_page = session.get("https://ael.sieva.fr/Portail/fr-FR/Connexion/Login")
verification = login_page.html.xpath('//*[@id="out_container"]/div[2]/form/input')
verification_token = verification[0].attrs['value']
time.sleep(10)
session.post('https://ael.sieva.fr/Portail/fr-FR/Connexion/Login', data={
'Login': self.login,
'MotDePasse': self.password,
'__RequestVerificationToken': verification_token
})
time.sleep(10)
# Get data from csv export
csv_response = session.get(f"https://ael.sieva.fr/Portail/fr-FR/Usager/Abonnement/ExportGraphReleveDataCSV?pointDInstallationId={self.delivery_point}&dateDebut=&dateFin=&granularite=Jour")
decoded_csv_response = csv_response.content.decode('utf-8')
print(f"Csv response : {decoded_csv_response}")
cr = csv.reader(decoded_csv_response.splitlines(), delimiter=';')
lines = list(cr)
lines.pop(0) # Remove header
index_m3 = 0
for row in lines:
index_m3 += float(row[2])
return index_m3
def post_state(state_value):
url = "https://[YOUR_HA_URL].ui.nabu.casa/api/states/sensor.sieva_m3"
bearer_token = getenv("BEARER")
headers = {
"Authorization": f"Bearer {bearer_token}",
"Content-Type": "application/json",
}
data = {
"state": state_value,
"attributes": {
"unit_of_measurement": "m³",
"icon": "mdi:water",
"device_class": "water",
"state_class": "total_increasing"
},
}
response = requests.post(url, json=data, headers=headers, verify=False)
print(response.status_code)
print(response.text) requirements.txt
|
Bonjour
J'ai installé via depot personnalisé l'intégration Sieva.
j'ai modifié mon fichier de conf.yaml
lorsque je vérifie la conf j'ai ce message erreur : Platform error 'sensor' from integration 'sieva' - Exception importing custom_components.sieva.sensor
Pouvez-vous m'aider
Merci bcp
The text was updated successfully, but these errors were encountered: