yukulehe / gazpar2mqtt

Python script to fetch GRDF's website data and publish data to a mqtt broker.
GNU General Public License v3.0
21 stars 9 forks source link

cannot connect to Mqtt #11

Closed yukulehe closed 2 years ago

yukulehe commented 2 years ago

I cannot connect to Mqtt, I don't know why for now.
I have tried to run the script directly on my Debian, I have the same issue. So it seems not related to the add-on.

Originally posted by @Minims in https://github.com/yukulehe/gazpar2mqtt/issues/5#issuecomment-972969423

Minims commented 2 years ago

So I have not the answer for now. but the error for the mqtt lib is [Errno -2] Name or service not known

I have print params and it seems OK. I usually used paho lib for MQTT so I have some difficulties to found the issue here.

I have tried to setup the mqtt host with IP or HOSTNAME, but same issue. Any idea ?

yukulehe commented 2 years ago

The error indicates clearly a problem of network. But hard to answer because I don't know your config. Your Mqtt broker is an add-on of HASS (so I guess on the same host) or a self hosted container ? Do you have the same issue with the enedisgateway2mqtt Hass add-on which, I suppose, target the same mqtt broker ?

Minims commented 2 years ago

It's the official mqtt broker available in HA Supervisor :

Mosquitto broker
Current version: 6.0.1 (Changelog)
logins:
  - username: *********
    password: *********
customize:
  active: false
  folder: mosquitto
certfile: fullchain.pem
keyfile: privkey.pem
require_certificate: false

I use it with for all my others add-on without issue. For example the enedisgateway use it without issue and the add-on is made by @alexbelgium too Yes Broker, gazpar2mqtt, enedisGW, etc are working on the same PI Host.

yukulehe commented 2 years ago

And I suppose you cannot see any logs on the mqtt broker side... (cause the add-on cannot reach him)

Minims commented 2 years ago

Yes. but I don't use the Docker, I just run the script with args. There is an issue too :

2021-11-18 21:47:03,411 Welcome to gazpar2mqtt
2021-11-18 21:47:03,411 -----------------------------------------------------------
2021-11-18 21:47:03,411 -----------------------------------------------------------
2021-11-18 21:47:03,412 Environement variable 'GRDF_USERNAME' is mandatory

so I comment the env part to bypass it.

Here is my fork for ssl working: https://github.com/Minims/gazpar2mqtt/commits/ssl But it ran outside of my home assistant. It's the only way I found for now. But I would prefer make it work as a local add-on like the Enedis one.

yukulehe commented 2 years ago

Ok I see I'll fix it.

Minims commented 2 years ago

And I suppose you cannot see any logs on the mqtt broker side... (cause the add-on cannot reach him)

No, nothing on mqtt side if it runs on HA.

yukulehe commented 2 years ago

Agree, I would prefer that the add-on works too. But I'm not able to test it.

alexbelgium commented 2 years ago

I don't understand, what is not working in the addon?

alexbelgium commented 2 years ago

If it works on your docker image there is no reason it wouldn't work on the addon...

Minims commented 2 years ago

For now I have only test docker in HA. On my Debian it just python without docker. I really don't understand the problem. I would like to test migrating to pho, but it seems a bit too long for now.

yukulehe commented 2 years ago

@Minims Did you check that the string representation of the host is correct when you lauchn it with the add-on ? I was thinking about your other issue on the port. Maybe the program try to reach the host with an additional quote as "'190.x.x.x'" instead of "190.x.x.x". You know what I mean ?

alexbelgium commented 2 years ago

Good idea - the addon shows in the log the text with which it is exported

alexbelgium commented 2 years ago

C'était bien ça, bien vu ! Nouvelle version pushée et je confirme que mqtt se connecte

yukulehe commented 2 years ago

Cool. Plus qu'à attendre la confirmation de @Minims . Et c'est très bien d'arrêter de parler en anglais :P

Minims commented 2 years ago

Alors oui c'est beaucoup mieux ! Je reçois bien les data dans mon Mqtt \o/. Merci !

1/ J'ai eu un petit soucis dans la conf entre true et True. Seul True avec la majuscule est compris. true tout en minuscule équivaut a False ici. Si y a moyen de remonter une erreur de conf ou de comprendre les 2 cas ça peut être bien.

2/ autre chose pour le HaDiscovery, il manque une partie device dans la conf des sensors pour que gazpar apparaisse comme un nouvel appareil dans homeassistant et relie toutes les entités:

"device": 
{"identifiers": ["gazpar_xxx"], 
"name": "Gazpar xxx", 
"model": "Gazpar", 
"manufacturer": "GRDF"}
}
alexbelgium commented 2 years ago

Super ! pour le true je pense que c'est l'interpréteur de l'app qui cherche un = "True"? Ce serait donc de ton côté @yukulehe ? Ou bien qu'il cherche un str (donc True) et qu'un bool ne marche pas (donc true)?

yukulehe commented 2 years ago

oui faut que je gère mieux les booleans, je vais faire un fix.

yukulehe commented 2 years ago

Du coup je clôture l'issue. La mise à jour d' @alexbelgium a corrigé. Merci à lui !