[Python] [Obsolète] Récupération des données API Withings

Vous avez créé un script LUA dont vous êtes fier, un .sh génial, un programme Python hors du commun, un Tuto, c'est ici que vous pouvez les partager.
Neutrino
Messages : 2662
Inscription : 10 juil. 2015, 15:42
Localisation : Les Herbiers(85)

Re: PYTHON : recupération des données API Withings

Message par Neutrino »

tonejay a écrit : command not found
Bonjour,
essaye :

Code : Tout sélectionner

sudo apt-get install python-pip
puis

Code : Tout sélectionner

sudo pip install requests
Ma maison à plein d'IP ! :mrgreen:
SAV Bonjour. Vous avez vidé le cache ?
tonejay
Messages : 106
Inscription : 15 sept. 2017, 20:28

Re: PYTHON : recupération des données API Withings

Message par tonejay »

Neutrino a écrit :
tonejay a écrit : command not found
Bonjour,
essaye :

Code : Tout sélectionner

sudo apt-get install python-pip
puis

Code : Tout sélectionner

sudo pip install requests
Slt !

Erreur diffrente cette fois ...

Code : Tout sélectionner

sudo python /home/pi/domotique/domoticz/scripts/python/withings.py
Traceback (most recent call last):
  File "/home/pi/domotique/domoticz/scripts/python/withings.py", line 15, in <module>
    from get_withings_data import WithingsAuth, WithingsApi  # projet initial https://github.com/maximebf/python-withings
  File "/home/pi/domotique/domoticz/scripts/python/get_withings_data.py", line 38, in <module>
    from requests_oauthlib import OAuth1, OAuth1Session
ImportError: No module named requests_oauthlib
Neutrino
Messages : 2662
Inscription : 10 juil. 2015, 15:42
Localisation : Les Herbiers(85)

Re: PYTHON : recupération des données API Withings

Message par Neutrino »

Et bien en gardant la même logique, peut-être :

Code : Tout sélectionner

sudo pip install requests_oauthlib
Ma maison à plein d'IP ! :mrgreen:
SAV Bonjour. Vous avez vidé le cache ?
tonejay
Messages : 106
Inscription : 15 sept. 2017, 20:28

Re: PYTHON : recupération des données API Withings

Message par tonejay »

On continue d'avancer !

Cette fois j'ai bien l'URL générée mais apparemment avec le mauvais token...
J'ai pourtant verifié les clés renseignées dans mon withings.py...elles sont conforme a ce que j'ai chez Nokia...

Code : Tout sélectionner

bad oauth token
Miloune
Messages : 10
Inscription : 24 mai 2018, 23:40

Re: PYTHON : recupération des données API Withings

Message par Miloune »

Hello,

Pour ceux qui veulent, j'ai mis à jour le script :
https://gist.github.com/Miloune/d04cf96 ... b9c66b22df

A utiliser avec https://github.com/orcasgit/python-nokia :)
jackslayter
Messages : 1040
Inscription : 30 sept. 2014, 14:40
Localisation : Isère (38)

Re: PYTHON : recupération des données API Withings

Message par jackslayter »

merci ça marche enfin !!!!!!!!!!!!!
Raspberry Pi + RFLink + Domoticz Beta
Oregon - 3x Thgr122Nx / Chacon - micromodule 200w, télécommande 3b et 16b, 2x module 1000w, détecteur de fumée, contact de porte, 2x prise 3500w / OWL - CM180 / TRC02 v2 RGB 3M / Cheap - PIR, contact de porte
Miloune
Messages : 10
Inscription : 24 mai 2018, 23:40

Re: PYTHON : recupération des données API Withings

Message par Miloune »

Je viens de corriger le problème lié au CRON dans le script : https://gist.github.com/Miloune/d04cf96 ... b9c66b22df
jackslayter
Messages : 1040
Inscription : 30 sept. 2014, 14:40
Localisation : Isère (38)

Re: PYTHON : recupération des données API Withings

Message par jackslayter »

j'ai le script qui ne marche plus (URL error) depuis environ le 12 juin

Code : Tout sélectionner

python3 domoticz_nokia_health.py
Traceback (most recent call last):
  File "/usr/lib/python3.5/urllib/request.py", line 1254, in do_open
    h.request(req.get_method(), req.selector, req.data, headers)
  File "/usr/lib/python3.5/http/client.py", line 1107, in request
    self._send_request(method, url, body, headers)
  File "/usr/lib/python3.5/http/client.py", line 1152, in _send_request
    self.endheaders(body)
  File "/usr/lib/python3.5/http/client.py", line 1103, in endheaders
    self._send_output(message_body)
  File "/usr/lib/python3.5/http/client.py", line 934, in _send_output
    self.send(msg)
  File "/usr/lib/python3.5/http/client.py", line 877, in send
    self.connect()
  File "/usr/lib/python3.5/http/client.py", line 849, in connect
    (self.host,self.port), self.timeout, self.source_address)
  File "/usr/lib/python3.5/socket.py", line 712, in create_connection
    raise err
  File "/usr/lib/python3.5/socket.py", line 703, in create_connection
    sock.connect(sa)
OSError: [Errno 113] No route to host

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "domoticz_nokia_health.py", line 95, in <module>
    json_object = json.loads(domoticzrequest(domoticzurl))
  File "domoticz_nokia_health.py", line 90, in domoticzrequest
    response = urllib.request.urlopen(request)
  File "/usr/lib/python3.5/urllib/request.py", line 163, in urlopen
    return opener.open(url, data, timeout)
  File "/usr/lib/python3.5/urllib/request.py", line 466, in open
    response = self._open(req, data)
  File "/usr/lib/python3.5/urllib/request.py", line 484, in _open
    '_open', req)
  File "/usr/lib/python3.5/urllib/request.py", line 444, in _call_chain
    result = func(*args)
  File "/usr/lib/python3.5/urllib/request.py", line 1282, in http_open
    return self.do_open(http.client.HTTPConnection, req)
  File "/usr/lib/python3.5/urllib/request.py", line 1256, in do_open
    raise URLError(err)
urllib.error.URLError: <urlopen error [Errno 113] No route to host>
Raspberry Pi + RFLink + Domoticz Beta
Oregon - 3x Thgr122Nx / Chacon - micromodule 200w, télécommande 3b et 16b, 2x module 1000w, détecteur de fumée, contact de porte, 2x prise 3500w / OWL - CM180 / TRC02 v2 RGB 3M / Cheap - PIR, contact de porte
Miloune
Messages : 10
Inscription : 24 mai 2018, 23:40

Re: PYTHON : recupération des données API Withings

Message par Miloune »

Hello,
Il semblerait que ton script n'arrive pas à appeler l'api domoticz.
Vérifie que le serveur ou est installé ton script puisse bien appeler domoticz avec un curl par exemple.
jackslayter
Messages : 1040
Inscription : 30 sept. 2014, 14:40
Localisation : Isère (38)

Re: PYTHON : recupération des données API Withings

Message par jackslayter »

je croyais que j'avais modifié le script pour ma nouvelle config mais en fait non
merci
Raspberry Pi + RFLink + Domoticz Beta
Oregon - 3x Thgr122Nx / Chacon - micromodule 200w, télécommande 3b et 16b, 2x module 1000w, détecteur de fumée, contact de porte, 2x prise 3500w / OWL - CM180 / TRC02 v2 RGB 3M / Cheap - PIR, contact de porte
Répondre