vdomos / domogik-plugin-mqtt

Domogik Plugin for send or receive MQTT messages
2 stars 0 forks source link

Can't start plugin #6

Closed tikismoke closed 7 years ago

tikismoke commented 7 years ago
2017-01-22 11:20:12,076 domogik-mqtt INFO Looking for launched instances of 'mqtt'
2017-01-22 11:20:12,093 domogik-mqtt INFO No existing process.
2017-01-22 11:20:12,097 domogik-mqtt DEBUG watcher fork
2017-01-22 11:20:12,097 domogik-mqtt INFO ----------------------------------
2017-01-22 11:20:12,099 domogik-mqtt INFO Starting client 'mqtt' (new manager instance)
2017-01-22 11:20:12,099 domogik-mqtt INFO Python version is sys.version_info(major=2, minor=7, micro=3, releaselevel='final', serial=0)
2017-01-22 11:20:12,101 domogik-mqtt DEBUG Send client status : starting
2017-01-22 11:20:12,102 domogik-mqtt DEBUG Send client status : starting
2017-01-22 11:20:12,106 domogik-mqtt DEBUG Write pid file for pid '22017' in file '/var/run/domogik/mqtt.pid'
2017-01-22 11:20:12,107 domogik-mqtt INFO Read the json file and validate id
2017-01-22 11:20:12,112 domogik-mqtt INFO The json file is valid
2017-01-22 11:20:12,126 domogik-mqtt INFO Check if there are pictures for the defined products
2017-01-22 11:20:12,126 domogik-mqtt INFO There is no products defined for this client
2017-01-22 11:20:12,127 domogik-mqtt INFO End init of the global client part
2017-01-22 11:20:12,127 domogik-mqtt DEBUG Init config query(mq) instance
2017-01-22 11:20:12,129 domogik-mqtt INFO Request query config for client mqtt : key configured
2017-01-22 11:20:12,130 domogik-mqtt DEBUG Process informations|python_version=2.7|psutil_version=4.3.1|domogik_version=0.5.2|component=plugin-mqtt|component_version=1.0|pid=22017|cpu_percent_usage=0.0|memory_total=16084.0|memory_percent_usage=0.1|memory_rss=12.0|memory_vsz=198.0|num_threads=5|num_file_descriptors_used=16|platform=x86_64|num_core=8|git_branch=develop|git_revision=5b28833
2017-01-22 11:20:12,140 domogik-mqtt DEBUG Query config : successfull response : <MQMessage(action=config.result, data='{u'status': True, u'name': u'mqtt', u'reason': u'', u'value': True, u'host': u'domogik', u'key': u'configured', u'type': u'plugin'}')>
2017-01-22 11:20:12,140 domogik-mqtt INFO The client is configured. Continuing (hoping that the user applied the appropriate configuration ;)
2017-01-22 11:20:12,141 domogik-mqtt INFO Request query config for client mqtt : key mqtt_host
2017-01-22 11:20:12,148 domogik-mqtt DEBUG Query config : successfull response : <MQMessage(action=config.result, data='{u'status': True, u'name': u'mqtt', u'reason': u'', u'value': u'mosquitto', u'host': u'domogik', u'key': u'mqtt_host', u'type': u'plugin'}')>
2017-01-22 11:20:12,149 domogik-mqtt INFO Value for 'mqtt_host' is : mosquitto
2017-01-22 11:20:12,149 domogik-mqtt INFO Casting value for key 'mqtt_host' in type 'string'...
2017-01-22 11:20:12,149 domogik-mqtt INFO Value is : mosquitto
2017-01-22 11:20:12,149 domogik-mqtt INFO Request query config for client mqtt : key mqtt_port
2017-01-22 11:20:12,156 domogik-mqtt DEBUG Query config : successfull response : <MQMessage(action=config.result, data='{u'status': True, u'name': u'mqtt', u'reason': u'', u'value': u'1883', u'host': u'domogik', u'key': u'mqtt_port', u'type': u'plugin'}')>
2017-01-22 11:20:12,156 domogik-mqtt INFO Value for 'mqtt_port' is : 1883
2017-01-22 11:20:12,156 domogik-mqtt INFO Casting value for key 'mqtt_port' in type 'integer'...
2017-01-22 11:20:12,157 domogik-mqtt INFO Value is : 1883.0
2017-01-22 11:20:12,157 domogik-mqtt INFO Retrieve the devices list for this client...
2017-01-22 11:20:12,170 domogik-mqtt INFO - id : 407  /  name : buanderie_temp  /  device type id : mqtt.sensor_temperature
2017-01-22 11:20:12,171 domogik-mqtt INFO   xpl_stats features :
2017-01-22 11:20:12,171 domogik-mqtt INFO   xpl_commands features :
2017-01-22 11:20:12,171 domogik-mqtt DEBUG Get parameter 'topic'
2017-01-22 11:20:12,171 domogik-mqtt DEBUG Parameter value found: domogik/sensor/buanderie_temp
2017-01-22 11:20:12,172 domogik-mqtt DEBUG Get parameter 'qos'
2017-01-22 11:20:12,172 domogik-mqtt DEBUG Parameter value found: 0
2017-01-22 11:20:12,172 domogik-mqtt INFO ==> Device 'buanderie_temp', id '407', type 'mqtt.sensor_temperature', topic 'domogik/sensor/buanderie_temp', qos '0'
2017-01-22 11:20:12,172 domogik-mqtt INFO ==> MQTT topic 'domogik/sensor/buanderie_temp' from server 'mosquitto:1883' will be subscribed for 'buanderie_temp' device Sensor
2017-01-22 11:20:12,173 domogik-mqtt INFO ==> Connecting to MQTT broquer ...
2017-01-22 11:20:12,187 domogik-mqtt INFO ==> Connected on MQTT broquer
2017-01-22 11:20:12,188 domogik-mqtt DEBUG ==> Listen Topic list:  [('domogik/sensor/buanderie_temp/#', 0)]
2017-01-22 11:20:12,189 domogik-mqtt ERROR ### Disconnecting from MQTT broquer.
2017-01-22 11:20:12,190 domogik-mqtt DEBUG Send client status : alive
2017-01-22 11:20:12,191 domogik-mqtt INFO ==> Stop listening MQTT message.
2017-01-22 11:20:12,191 domogik-mqtt INFO Start IOLoop for MQ : nothing else can be executed in the __init__ after this! Make sure that the self.ready() call is the last line of your init!!!!
tikismoke commented 7 years ago

From mosquitto server i've got this:


1485080695: New connection from 192.168.0.63.
1485080695: Invalid protocol "MQTT" in CONNECT from 192.168.0.63.
1485080695: Socket read error on client (null), disconnecting.
vdomos commented 7 years ago

can you give me mosquitto server and paho-mqtt version ?

Mine:

Mosquitto serveur:

# dpkg -l|grep mosquitto
ii  libmosquitto1:amd64            1.4.10-2                     amd64        MQTT version 3.1/3.1.1 client library
ii  mosquitto                      1.4.10-2                     amd64        MQTT version 3.1/3.1.1 compatible message broker
ii  mosquitto-clients              1.4.10-2                     amd64        Mosquitto command line MQTT clients

On Domogik server:

# pip list|grep paho
paho-mqtt (1.1)

Do you have configured mosquitto server with password ?

tikismoke commented 7 years ago

Sending all information in the evening.

tikismoke commented 7 years ago

on server:

root@mosquitto:~# dpkg -l|grep mosquitto
ii  libmosquitto0                   0.15-2                 amd64        MQTT version 3.1 client library
ii  mosquitto                       0.15-2                 amd64        MQTT version 3.1 compatible message broker
ii  mosquitto-clients               0.15-2                 amd64        Mosquitto command line MQTT clients
ii  python-mosquitto                0.15-2                 all          MQTT version 3.1 client library, python bindings

on client:

root@domogik:~# pip list|grep paho
Usage: pip COMMAND [OPTIONS]

pip: error: No command by the name pip list
  (maybe you meant "pip install list")
pip --version
pip 1.1 from /usr/lib/python2.7/dist-packages (python 2.7)
vdomos commented 7 years ago

your server mosquitto and domogik are not on Debian jessie ? => pas bien :) mosquitto is to old, it don't support MQTT version 3.1.1 protocol

Can you test with parameter protocol=MQTTv31 in lib/mqtt.py:

class MQTT:
    """ MQTT
    """

    def __init__(self, log, cb_send, stop, mqtthost, mqttport, mqtttopic, devicelist):
        ...        
        self.MQTTClient = mqtt.Client('mqtt2dmg_' + platform.node(), protocol=MQTTv31)
        ...
tikismoke commented 7 years ago

Yes still under wheezy.....

With self.MQTTClient = mqtt.Client('mqtt2dmg_' + platform.node(), protocol=MQTTv31) i get :

Traceback (most recent call last):
  File "bin/mqtt.py", line 183, in <module>
    MQTTManager()
  File "bin/mqtt.py", line 97, in __init__
    self.mqttClient = MQTT(self.log, self.send_pub_data, self.get_stop(), self.mqtthost, self.mqttport, self.mqtttopic, self.device_list)
  File "/var/lib/domogik/domogik_packages/plugin_mqtt/lib/mqtt.py", line 88, in __init__
    self.MQTTClient = mqtt.Client('mqtt2dmg_' + platform.node(), protocol=MQTTv31)
NameError: global name 'MQTTv31' is not defined

With self.MQTTClient = mqtt.Client('mqtt2dmg_' + platform.node(), protocol='MQTTv31') Plugin start but i get this in server side:

1485203511: Invalid protocol "MQTT" in CONNECT from 192.168.0.63.

tikismoke commented 7 years ago

i've tried a lot of thinks even with evil google but can't find the issue :(

tikismoke commented 7 years ago

protocol=3 allow plugin start

tikismoke commented 7 years ago

IT WORKS :)

vdomos commented 7 years ago

With:

self.MQTTClient = mqtt.Client('mqtt2dmg_' + platform.node(), protocol=3)

for old Mosquitto version, i't ok for you ?

thanks

tikismoke commented 7 years ago

Yes with a basic test ;) Will try to migrate my xpl arduinos and after somes asterisk things to mqtt in future ;)

Le 23 janvier 2017 22:55:09 GMT+01:00, vdomos notifications@github.com a écrit :

With:

self.MQTTClient = mqtt.Client('mqtt2dmg_' + platform.node(), protocol=3)

for old Mosquitto version, i't ok for you ?

thanks

-- You are receiving this because you authored the thread. Reply to this email directly or view it on GitHub: https://github.com/vdomos/domogik-plugin-mqtt/issues/6#issuecomment-274629892

-- Envoyé de mon appareil Android avec K-9 Mail. Veuillez excuser ma brièveté.

vdomos commented 7 years ago

me too, I replace old xPL sensors with MQTT.

For info., there is still a bug if network connexion lost, MQTT Client disconnect not properly. I have to find a better solution

tikismoke commented 7 years ago

Like mq in domodroid no way to know if connection is still alive?

jschaeke commented 7 years ago

Yep also replaced xpl in favor for mqtt on my arduino sensors... really like its support (eg espeasy, android mqtt dashboard, sonoff... ) and now domogik ;-)

vdomos commented 7 years ago

@tikismoke can you test the last push version (Not in prod in a first time). I added plugin parameter to choose the old protocol => MQTTv31 Domogik must be restarted after pull (info.json modified)

@tikismoke, @jschaeke: You can test also the reload new/update devices without restarting the plugin to test if it's ok for you.

thank,

tikismoke commented 7 years ago

Will have a look in the week no problems.

I can do it in prod I still not move anything to mq :(

jschaeke commented 7 years ago

Updated, added a new sensor and sent after that a value to it (with mosquitto_pub without restart of domogik) I saw it immediately in the history of the new sensor. So it's ok for me!

tikismoke commented 7 years ago

Same for me using the right version in conf seems to works :)

WELL DONE.