Edubits / Zway-MQTT

Publishes the status of devices to a MQTT topic and is able to set values based on subscribed topics.
Apache License 2.0
29 stars 16 forks source link

Restart the module programmatically #12

Closed mcfanda closed 7 years ago

mcfanda commented 7 years ago

Hi is there a way to restart the module from HTTP request (curl) or command line? thanks

Edubits commented 7 years ago

Hi @mcfanda, Not that I know. For what reason do you need this?

pathec commented 7 years ago

Hi @mcfanda, you could try the following:

1.) load the instance via (replace 42 with your instance id): GET http://YOUR_IP:8083/ZAutomation/api/v1/instances/42, resulting in:

{
  "data": {
    "instanceId": "0",
    "moduleId": "MQTT",
    "active": true,
    "title": "MQTT",
    "params": {
      "clientId": "zway",
      "host": "localhost",
      "port": "1883",
      "topicPrefix": "zway",
      "topicPostfixStatus": "status",
      "topicPostfixSet": "set",
      "publications": [ ]
    },
    "id": 35,
    "creationTime": 1481005986
  },
  "code": 200,
  "message": "200 OK",
  "error": null
}

2.) take the content of data from the first request as body for following request (replace 42 with your instance id):

PUT http://localhost:8083/ZAutomation/api/v1/instances/42

{
  "instanceId": "0",
  "moduleId": "MQTT",
  "active": true,
  "title": "MQTT",
  "params": {
    "clientId": "zway",
    "host": "localhost",
    "port": "1883",
    "topicPrefix": "zway",
    "topicPostfixStatus": "status",
    "topicPostfixSet": "set",
    "publications": [ ]
  }
}

This restarts the module.

mcfanda commented 7 years ago

Thanks. I'm going to try. I need it because it seems that the module stops every now and then. I'm try to debug the reason. Since I'm setting up home assistant together with z-way, the house is full of mqtt topics and clients. Some of them seems to kill the module.

Edubits commented 7 years ago

Thanks @pathec and @mcfanda!

Could you try PR #10? It might be that you're receiving timeouts. I'll test the PR this weekend and then merge it to master.

mcfanda commented 7 years ago

Yes, i'll do and let you know

mcfanda commented 7 years ago

I've tired, but I got this fatal: Remote branch latest not found in upstream origin

Edubits commented 7 years ago

@mcfanda I've just merged the PR into master, can you try it again?