OBone-git / Cozytouch-domoticz

Python script for read/write data between the cozytouch server and domoticz on rpi
MIT License
17 stars 15 forks source link

No data after update to 4.35 #53

Closed poelie83 closed 1 year ago

poelie83 commented 1 year ago

I updated the script with the new 5.35 to make it work again, at least that's what I thought. After updating the script i get the following error messages:

¤¤¤¤ Demarrage script cozytouch <=> domoticz version 5.35 (debug :1)
Version python : 2.7.16
**** Test existence / creation configuration cozytouch (hardware domoticz + fichier de sauvegarde) ****
Fichier de sauvegarde de la configuration : /home/pi/cozytouch_save
idx hardware cozytouch dans le fichier de sauvegarde de la configuration : 19
GET->   http://192.168.0.105:8080/json.htm?type=hardware   :   200
idx hardware cozytouch dans domoticz : 19
**** Fin fonction test ****
Test présence du fichier de sauvegarde cozytouch et virtual hardware domoticz OK

**** Tentative interrogation serveur Cozytouch sans login, avec cookie login précédent ****
GET->   https://ha110-1.overkiz.com/enduser-mobile-web/enduserAPI/setup   :   200
Requete de test sans login reussie, bypass login

**** Decouverte devices ****
GET->   https://ha110-1.overkiz.com/enduser-mobile-web/enduserAPI/setup   :   200

Gateway Cozytouch : etat on / connexion : OK / version : 2022.7.4
**** Demarrage procedure d'ajout devices Cozytouch ****
GET->   http://192.168.0.105:8080/json.htm?type=command&param=addlogmessage&message=Cozytouch : Recherche des devices connectes ...    :   200
GET->   http://192.168.0.105:8080/json.htm?type=command&param=addlogmessage&message=Cozytouch : creation Bridge Cozytouch localisation inconnue ,url: internal://0841-6951-5503/pod/0   :   200
Ajout: Bridge Cozytouch localisation inconnue
GET->   http://192.168.0.105:8080/json.htm?type=command&param=addlogmessage&message=Cozytouch : Device avec classe io:StackComponent inconnu   :   200
GET->   http://192.168.0.105:8080/json.htm?type=createvirtualsensor&idx=19&sensorname=Etat chauffe DHWP All House+&sensortype=6   :   200
Traceback (most recent call last):
  File "cozytouch.py", line 1916, in <module>
    decouverte_devices()
  File "cozytouch.py", line 673, in decouverte_devices
    liste= Add_DHWP_THERM (save_idx,liste,url,x,(data[u'rootPlace'][u'label']),name) # label sur rootplace
  File "cozytouch.py", line 1029, in Add_DHWP_THERM
    DHWP_THERM[u'idx_on_off']= domoticz_add_virtual_device(idx,6,nom_switch_on_off)
  File "cozytouch.py", line 337, in domoticz_add_virtual_device
    idx=(data[u'idx'])
KeyError: u'idx'

Any idea what's going wrong? in domoticz I see the new hardware 5.35 but no new device already removed the _save file and all hardware within domoticz without any result.

Please find the dump file here click

Tatroxitum commented 1 year ago

I've made a lot of tests but could not reproduce this issue. I have a DHWP_THERM_V4_CETHI_IO and it's handled exactly as your DHWP_THERM_V2_MURAL_IO.

The only thing that I thought of is :

poelie83 commented 1 year ago

@Tatroxitum Many thanks for investigating this issue so far.

I tried all the steps as described, when I run the script cozytouch2.py the error is still the same.

¤¤¤¤ Demarrage script cozytouch <=> domoticz version 5.35 (debug :2)
Version python : 2.7.16
**** Test existence / creation configuration cozytouch (hardware domoticz + fichier de sauvegarde) ****
Fichier de sauvegarde de la configuration : /home/pi/cozytouch_save
Fichier de sauvegarde de la configuration inexistant, creation hardware cozytouch dans domoticz et nouveau fichier de sauvegarde
GET->   http://192.168.0.105:8080/json.htm?type=command&param=addhardware&htype=15&port=1&name=Cozytouch_V5.35&enabled=true   :   200
('    **** domoticz cozytouch hardware index : ', '19')
GET->   http://192.168.0.105:8080/json.htm?type=command&param=addlogmessage&message=Creation nouvelle configuration ...   :   200
Hardware cozytouch dans domoticz et nouveau fichier de sauvegarde de la configuration crees
**** Fin fonction test ****
Test présence du fichier de sauvegarde cozytouch et virtual hardware domoticz OK

**** Tentative interrogation serveur Cozytouch sans login, avec cookie login précédent ****
GET->   https://ha110-1.overkiz.com/enduser-mobile-web/enduserAPI/setup   :   401
Erreur HTTP 401 :
!!!! Echec interrogation serveur Cozytouch sans login, connexion serveur Cozytouch ****
 POST-> https://ha110-1.overkiz.com/enduser-mobile-web/enduserAPI/login | userId=****&userPassword=**** : 200
Authentification serveur cozytouch OK
Connexion serveur Cozytouch reussie
GET->   https://ha110-1.overkiz.com/enduser-mobile-web/enduserAPI/setup   :   200
Requete setup reussie
**** Decouverte devices ****
GET->   https://ha110-1.overkiz.com/enduser-mobile-web/enduserAPI/setup   :   200

Gateway Cozytouch : etat on / connexion : OK / version : 2022.7.4
**** Demarrage procedure d'ajout devices Cozytouch ****
GET->   http://192.168.0.105:8080/json.htm?type=command&param=addlogmessage&message=Cozytouch : Recherche des devices connectes ...    :   200
GET->   http://192.168.0.105:8080/json.htm?type=command&param=addlogmessage&message=Cozytouch : creation Bridge Cozytouch localisation inconnue ,url: internal://0841-6951-5503/pod/0   :   200
Ajout: Bridge Cozytouch localisation inconnue
GET->   http://192.168.0.105:8080/json.htm?type=command&param=addlogmessage&message=Cozytouch : Device avec classe io:StackComponent inconnu   :   200
GET->   http://192.168.0.105:8080/json.htm?type=createvirtualsensor&idx=19&sensorname=Etat chauffe DHWP All House+&sensortype=6   :   200
Traceback (most recent call last):
  File "./cozytouch2.py", line 1916, in <module>
    decouverte_devices()
  File "./cozytouch2.py", line 673, in decouverte_devices
    liste= Add_DHWP_THERM (save_idx,liste,url,x,(data[u'rootPlace'][u'label']),name) # label sur rootplace
  File "./cozytouch2.py", line 1029, in Add_DHWP_THERM
    DHWP_THERM[u'idx_on_off']= domoticz_add_virtual_device(idx,6,nom_switch_on_off)
  File "./cozytouch2.py", line 337, in domoticz_add_virtual_device
    idx=(data[u'idx'])
KeyError: u'idx'

Find the dump file here

Tatroxitum commented 1 year ago

Very strange. did you restarted domoticz ? I would try that after step 5 and before launching cozytouch2.py.

line 337, after

Lecture de l'idx attribué

please add print((' **** domoticz virtual sensor index : '+str(idx))) and repeat above steps.

poelie83 commented 1 year ago

Repeated all the steps and rebooted domoticz, still the same If usefull I can share you my SSH adres, port and login

¤¤¤¤ Demarrage script cozytouch <=> domoticz version 5.35 (debug :2)
Version python : 2.7.16
**** Test existence / creation configuration cozytouch (hardware domoticz + fichier de sauvegarde) ****
Fichier de sauvegarde de la configuration : /home/pi/cozytouch_save
Fichier de sauvegarde de la configuration inexistant, creation hardware cozytouch dans domoticz et nouveau fichier de sauvegarde
GET->   http://192.168.0.105:8080/json.htm?type=command&param=addhardware&htype=15&port=1&name=Cozytouch_V5.35&enabled=true   :   200
('    **** domoticz cozytouch hardware index : ', '19')
GET->   http://192.168.0.105:8080/json.htm?type=command&param=addlogmessage&message=Creation nouvelle configuration ...   :   200
Hardware cozytouch dans domoticz et nouveau fichier de sauvegarde de la configuration crees
**** Fin fonction test ****
Test présence du fichier de sauvegarde cozytouch et virtual hardware domoticz OK

**** Tentative interrogation serveur Cozytouch sans login, avec cookie login précédent ****
GET->   https://ha110-1.overkiz.com/enduser-mobile-web/enduserAPI/setup   :   401
Erreur HTTP 401 :
!!!! Echec interrogation serveur Cozytouch sans login, connexion serveur Cozytouch ****
 POST-> https://ha110-1.overkiz.com/enduser-mobile-web/enduserAPI/login | userId=****&userPassword=**** : 200
Authentification serveur cozytouch OK
Connexion serveur Cozytouch reussie
GET->   https://ha110-1.overkiz.com/enduser-mobile-web/enduserAPI/setup   :   200
Requete setup reussie
**** Decouverte devices ****
GET->   https://ha110-1.overkiz.com/enduser-mobile-web/enduserAPI/setup   :   200

Gateway Cozytouch : etat on / connexion : OK / version : 2022.7.4
**** Demarrage procedure d'ajout devices Cozytouch ****
GET->   http://192.168.0.105:8080/json.htm?type=command&param=addlogmessage&message=Cozytouch : Recherche des devices connectes ...    :   200
GET->   http://192.168.0.105:8080/json.htm?type=command&param=addlogmessage&message=Cozytouch : creation Bridge Cozytouch localisation inconnue ,url: internal://0841-6951-5503/pod/0   :   200
Ajout: Bridge Cozytouch localisation inconnue
GET->   http://192.168.0.105:8080/json.htm?type=command&param=addlogmessage&message=Cozytouch : Device avec classe io:StackComponent inconnu   :   200
GET->   http://192.168.0.105:8080/json.htm?type=createvirtualsensor&idx=19&sensorname=Etat chauffe DHWP All House+&sensortype=6   :   200
 **** domoticz virtual sensor index : 19
Traceback (most recent call last):
  File "./cozytouch2.py", line 1917, in <module>
    decouverte_devices()
  File "./cozytouch2.py", line 674, in decouverte_devices
    liste= Add_DHWP_THERM (save_idx,liste,url,x,(data[u'rootPlace'][u'label']),name) # label sur rootplace
  File "./cozytouch2.py", line 1030, in Add_DHWP_THERM
    DHWP_THERM[u'idx_on_off']= domoticz_add_virtual_device(idx,6,nom_switch_on_off)
  File "./cozytouch2.py", line 338, in domoticz_add_virtual_device
    idx=(data[u'idx'])
KeyError: u'idx'
Tatroxitum commented 1 year ago

what is strange is that your hardware sensor id is 19 and the device sensor id is also 19. should still work despite. Can you confirm you have 18 hardwares and 18 devices without cozytouch hardware/devices ?

Tatroxitum commented 1 year ago

line 337, after

Lecture de l'idx attribué

please add also : print(('req.text:',str(req.text))) To see if the response from domoticz is as expected despite the 200 response.

and please verify that there is no device with idx19 before launching script

poelie83 commented 1 year ago

I have over 100 devices, so no that's wrong. Any idea how to overrule this? >

Tatroxitum commented 1 year ago

this is interesting. please add print(('req.text:',str(req.text))) as i said earlier to see what returns. I'll check domoticz bugs if i can find something known

Tatroxitum commented 1 year ago

I think I have a good clue. if I change sensortype=6 to another value (for example 244) then i have exactly the same behavior. When you go to https://www.domoticz.com/wiki/Developing_a_Python_plugin#Available_Device_Types For an on/off switch they preconise to use value sensortype=244 with a sub value 73 and an additionnal value 0 (not possible as it is in cozytouch.py). The value 6 doesn't appear anymore in this documentation. But sensortype=6 still works as you are the only one with this problem. I've also checked with a newly installed version of domoticz and sensortype=6 is ok.

Moreover, things have changed in domoticz beta version in the JSON requests typically for these things, did you updated your version to beta and downgraded it by any chances ?

I'll make a modified version of cozytouch to be able to create sensortypes=244 and all the sub values needed ; should not change anything on my side but maybe on yours

whilst, please add the line mentionned above to confort me in my thoughts print(('req.text:',str(req.text)))

poelie83 commented 1 year ago

That makes sense, Yes I am running the Beta version. I added the line:

¤¤¤¤ Demarrage script cozytouch <=> domoticz version 5.35 (debug :2)
Version python : 2.7.16
**** Test existence / creation configuration cozytouch (hardware domoticz + fichier de sauvegarde) ****
Fichier de sauvegarde de la configuration : /home/pi/cozytouch_save
Fichier de sauvegarde de la configuration inexistant, creation hardware cozytouch dans domoticz et nouveau fichier de sauvegarde
GET->   http://192.168.0.105:8080/json.htm?type=command&param=addhardware&htype=15&port=1&name=Cozytouch_V5.35&enabled=true   :   200
('    **** domoticz cozytouch hardware index : ', '19')
GET->   http://192.168.0.105:8080/json.htm?type=command&param=addlogmessage&message=Creation nouvelle configuration ...   :   200
Hardware cozytouch dans domoticz et nouveau fichier de sauvegarde de la configuration crees
**** Fin fonction test ****
Test présence du fichier de sauvegarde cozytouch et virtual hardware domoticz OK

**** Tentative interrogation serveur Cozytouch sans login, avec cookie login précédent ****
GET->   https://ha110-1.overkiz.com/enduser-mobile-web/enduserAPI/setup   :   401
Erreur HTTP 401 :
!!!! Echec interrogation serveur Cozytouch sans login, connexion serveur Cozytouch ****
 POST-> https://ha110-1.overkiz.com/enduser-mobile-web/enduserAPI/login | userId=****&userPassword=**** : 200
Authentification serveur cozytouch OK
Connexion serveur Cozytouch reussie
GET->   https://ha110-1.overkiz.com/enduser-mobile-web/enduserAPI/setup   :   200
Requete setup reussie
**** Decouverte devices ****
GET->   https://ha110-1.overkiz.com/enduser-mobile-web/enduserAPI/setup   :   200

Gateway Cozytouch : etat on / connexion : OK / version : 2022.7.4
**** Demarrage procedure d'ajout devices Cozytouch ****
GET->   http://192.168.0.105:8080/json.htm?type=command&param=addlogmessage&message=Cozytouch : Recherche des devices connectes ...    :   200
GET->   http://192.168.0.105:8080/json.htm?type=command&param=addlogmessage&message=Cozytouch : creation Bridge Cozytouch localisation inconnue ,url: internal://0841-6951-5503/pod/0   :   200
Ajout: Bridge Cozytouch localisation inconnue
GET->   http://192.168.0.105:8080/json.htm?type=command&param=addlogmessage&message=Cozytouch : Device avec classe io:StackComponent inconnu   :   200
GET->   http://192.168.0.105:8080/json.htm?type=createvirtualsensor&idx=19&sensorname=Etat chauffe DHWP All House+&sensortype=6   :   200
 **** domoticz virtual sensor index : 19
('req.text:', '{\n\t"status" : "ERR"\n}\n')
Traceback (most recent call last):
  File "./cozytouch2.py", line 1918, in <module>
    decouverte_devices()
  File "./cozytouch2.py", line 675, in decouverte_devices
    liste= Add_DHWP_THERM (save_idx,liste,url,x,(data[u'rootPlace'][u'label']),name) # label sur rootplace
  File "./cozytouch2.py", line 1031, in Add_DHWP_THERM
    DHWP_THERM[u'idx_on_off']= domoticz_add_virtual_device(idx,6,nom_switch_on_off)
  File "./cozytouch2.py", line 339, in domoticz_add_virtual_device
    idx=(data[u'idx'])
KeyError: u'idx'
Tatroxitum commented 1 year ago

That's it, you should have said you were on the beta version earlier :) in beta version the call for creating virtual sensor devices has changed. You have to replace line 328 : myurl=url_domoticz+'createvirtualsensor&idx='+idx+'&sensorname='+nom+'+&sensortype='+typ+req_option by myurl=url_domoticz+'command&param=createvirtualsensor&idx='+idx+'&sensorname='+nom+'+&sensortype='+typ+req_option

Please change the issue name to precise that (and update the version number, it"s 5.35")

### careful, this change is not valid on stable version !!!! ### I won't make a pull request as it is not a problem on the stable version, we'll see when it become official

poelie83 commented 1 year ago

Whoop!! working perfectly! many thanks, please let met buy you a beer or wine ;-) I did mention my version number, unfortunately I didn't mention its beta :-( sorry about that.

Again, many thanks for investigating and helping me out.

Tatroxitum commented 1 year ago

You're welcome :)

Le mar. 20 juin 2023, 10:27, poelie83 @.***> a écrit :

Whoop!! working perfectly! many thanks, please let met buy you a beer or wine ;-) I did mention my version number, unfortunately I didn't mention its beta :-( sorry about that.

Again, many thanks for investigating and helping me out.

— Reply to this email directly, view it on GitHub https://github.com/OBone-git/Cozytouch-domoticz/issues/53#issuecomment-1598341382, or unsubscribe https://github.com/notifications/unsubscribe-auth/AGVKL7Z7T5RAEMV5ZOIHEZLXMFNF3ANCNFSM6AAAAAAZI24LPQ . You are receiving this because you were mentioned.Message ID: @.***>