Skip to content

Pull Request / Add MQTT and persistent connection for real time #7

@mrwiwi

Description

@mrwiwi

Hi, still haven't processed how to use github, so if you could have a look at my code here :

It's a WIP of your client interfaced with a mqtt broker (here on homeassistant), i'm still learning python and programming in general, but it's working :)

Hard time on parsing data, can't use the type arg anymore (websocket is listened permanently, so we can have real time update of our devices), we need or more adaptable function.

Please someone review it, we're not far from a clean client i think.

Auto reconnect is implemented.

Output sample :
`S C:\Users\lipit> & C:/bin/Python38-32/python.exe d:/Drive/Domotique/pydom/pydom.py
##################################
Websocket is closed or inexistant, trying....
"Attempting websocket connection..."
Tydom Websocket is Connected ! <websockets.client.WebSocketClientProtocol object at 0x0435C760>
Attempting MQTT connection...
##################################
MQTT is connected ! =)
Subscribing to : homeassistant/+/tydom/#
##################################
Requesting 1st data...
MQTT SUBSCRIBED

1234568029 Baie
1234568089 Panoramique
1234568149 Cosina
1234568209 Salle De Bain
1234568269 Chambre Parents
1234568329 Chambre Quentin
1234568389 Chambre 3
1234591388 Alarme
Cannot parse response
string indices must be integers

Cannot parse response
list indices must be integers or slices, not str

MQTT incoming: homeassistant/sensor/tydom/last_update b'2019-12-11 00:32:54.442518'

MQTT incoming: homeassistant/sensor/tydom/last_update b'2019-12-11 00:32:54.557796'

MQTT incoming: homeassistant/requests/tydom/update b'please'

1234568029 Baie
1234568089 Panoramique
1234568149 Cosina
1234568209 Salle De Bain
1234568269 Chambre Parents
1234568329 Chambre Quentin
1234568389 Chambre 3
1234591388 Alarme
Cannot parse response`

Here it is !

https://pastebin.com/xy9R2RGk

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions