Giter VIP home page Giter VIP logo

zway-mqtt's Introduction

MQTT Z-Way HA module

Publishes the status of devices to a MQTT topic and is able to set values based on subscribed topics.

It is possible to publish the status for single devices, or for devices which are tagged. Per publication you can customize the topic and decide if the message should be retained or not.

Installation

Make sure that the BaseModule is installed prior to installing this module.

The preferred way of installing this module is via the "Zwave.me App Store" available in 2.2.0 and higher. For stable module releases no access token is required. If you want to test the latest pre-releases use 'mqtt_beta' as app store access token.

For developers and users of older Z-Way versions installation via Git is recommended.

cd /opt/z-way-server/automation/userModules
git clone https://github.com/Edubits/Zway-MQTT.git MQTT --branch latest

To update or install a specific version

cd /opt/z-way-server/automation/userModules/MQTT
git fetch --tags
# For latest released version
git checkout tags/latest
# For a specific version
git checkout tags/1.0
# For development version
git checkout -b master --track origin/master

Usage

Add an instance of the app through and fill in the details about your MQTT broker. After this configure for which devices you want to publish the status to MQTT. You can either configure this for a single device or for all devices tagged with a certain tag at once.

Defining the publication topic

You can define the topic used for publication. It's constructed from the following parts:

  • Topic Prefix – The start of each topic
  • Topic – Per publication defined topic

In each of these you can use %deviceId%, %deviceName% and %roomName% as variables. For example having Foo/bar as prefix and %roomName%/%deviceName% as topic can result in a message published on the topic Foo/bar/livingRoom/dimmer. Both %deviceName% and %roomName% will be camelcased.

Interacting through MQTT

You can also publish to certain topics to interact with Z-Way. For this the two postfixes are used:

  • Status postfix (default: status)
  • Set postfix (default: set)

Taking the same example as before, when you publish an empty message to Foo/bar/livingRoom/dimmer/status the current value will be published again. When you publish a value (for example on, off or 87) to Foo/bar/livingRoom/dimmer/set the dimmer will be set to that level.

Acknowledgements

I want to thank @goodfield for finding and fixing a fully JavaScript MQTTClient which I could use in this module as well. His module can be found at https://github.com/goodfield/zway-mqtt.

License

Copyright 2019 Robin Eggenkamp - Edubits

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

zway-mqtt's People

Contributors

duiffie avatar edubits avatar i8beef avatar isaksson avatar nlsrchtr avatar pastukhov avatar vectah0 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

zway-mqtt's Issues

mqtt reconnection logic still broken

Hello

i updated this plugin to the new v1.1 version and the reconnection logic appears to still be broken.
my zway server is behind a sometimes unstable 4g connection and mqtt server on other side of the link, so connection tends to go down from time to time and this plugin cant recover properly.

it looks like it is trying to reconnect a few times but then eventually gives up.

i don't know how it is done in this plugin but it needs to keep retrying the connection indefinitely possibly with a user configurable delay between tries.
right now it is not reliable which means i can unfortunately not use this plugin and need to come up with another solution

Timeout on connecting

It seems that 10s is not always enough to connect, causing timeouts and reconnects. Also noticed that _connect_timeout_timer is calling _onClose directly instead of _onTimeout. The latter actually closes the socket, instead of just cleaning up.

Cannot read property 'write' of undefined

I'm getting tons of these errors (about 4000 under a 24h period) in my z-way-server.log

[2017-01-05 15:01:10.706] [E] [core] Callback execution error: TypeError: Cannot read property 'write' of undefined
at MQTTClient.ping (automation/userModules/MQTT/lib/mqtt.js:578:18)
at Function. (automation/userModules/MQTT/lib/mqtt.js:164:14)
[2017-01-05 15:01:11.106] [I] [core] [MQTT_45] Error: Error: Timeout
at MQTT.BaseModule.error (automation/userModules/BaseModule/index.js:122:17)
at null._errorCallback (automation/userModules/MQTT/index.js:105:8)
at MQTTClient._onError (automation/userModules/MQTT/lib/mqtt.js:449:10)
at MQTTClient._onTimeout (automation/userModules/MQTT/lib/mqtt.js:443:8)
at Function. (automation/userModules/MQTT/lib/mqtt.js:575:12)
[2017-01-05 15:01:11.110] [I] [core] [MQTT_45] Error: Disconnected, will retry to connect...
at MQTT.BaseModule.error (automation/userModules/BaseModule/index.js:122:17)
at null._disconnectCallback (automation/userModules/MQTT/index.js:109:8)
at MQTTClient._onClose (automation/userModules/MQTT/lib/mqtt.js:459:10)
at MQTTClient._onTimeout (automation/userModules/MQTT/lib/mqtt.js:444:8)
at Function. (automation/userModules/MQTT/lib/mqtt.js:575:12)

I'm currently trying to find out why my entire z-way-server crashes at intermittent intervals and I noticed these error messages in the log. Please note that these messages appear even when the z-way-server is working.

ThermostatSetPoint not working as expected

When setting a Thermostat SetPoint (HRT4-ZW) via the set topic in MQTT, the result in the z-way-server log is:

[2016-11-28 09:00:58.277] [I] [core] --- ZWayVDev_zway_6-0-67-1 performCommand processing: {"0":"20.5"}
[2016-11-28 09:00:58.281] [I] [zway] Job 0x13 (SwitchMultilevel Set): Delivered
[2016-11-28 09:00:58.282] [I] [core] Notification: error (module): Error during perform command execution: TypeError: Cannot read property 'level' of undefined
[2016-11-28 09:00:58.282] [I] [zway] Removing job: SwitchMultilevel Set
[2016-11-28 09:00:58.313] [I] [core] TypeError: Cannot read property 'level' of undefined
at t_vDev.(anonymous function).self.controller.devices.create.handler (automation/modules/ZWave/index.js:3040:52)
at .extend.performCommand (automation/classes/VirtualDevice.js:291:37)
at automation/userModules/MQTT/index.js:94:15
at automation/userModules/MQTT/index.js:144:6
at Function.
.each..forEach (automation/lib/underscore.js:146:17)
at MQTT.processPublicationsForDevice (automation/userModules/MQTT/index.js:140:4)
at automation/userModules/MQTT/index.js:75:10
at Function.
.each._.forEach (automation/lib/underscore.js:146:17)
at _.extend.each (automation/classes/DevicesCollection.js:181:18)
at Object.zway/# (automation/userModules/MQTT/index.js:74:28)

it looks like it tries to set the thermostat as a SwitchMultilevel, which won't work.

My z-way version is v2.2.5

Luminiscence and temperature error

Using z-way 2.3.8 with latest MQTT app.
Config it with my mosquitto, everything work as expected with dimmers - states publishes to topic "smarthome/%roomName%/%deviceName%" for devices with specific tag. But when I try to add that tag to Philio Multi-Sensor for luminiscence or temperature, I've nothing in topics and error in log:

[2019-01-25 12:00:56.037] [I] [core] Notification: device-info (device-luminiscence): {"dev":"Luminiscence (#11)","l":"71 %","location":1}
[2019-01-25 12:00:56.103] [I] [core] [MQTT-15] Socket connection closed.
[2019-01-25 12:00:56.106] [I] [core] [MQTT_15] Error: Disconnected, will retry to connect...
at MQTT.BaseModule.error (automation/userModules/BaseModule/index.js:122:17)
at MQTT.onDisconnect (automation/userModules/MQTT/index.js:173:7)
at MQTTClient._disconnectCallback (automation/userModules/MQTT/index.js:110:46)
at MQTTClient._onClose (automation/userModules/MQTT/lib/mqtt.js:303:10)
at tcp._connection.onclose (automation/userModules/MQTT/lib/mqtt.js:173:10)
[2019-01-25 12:00:56.107] [I] [core] [BaseModule-12] Set lastLevel to 71 for ZWayVDev_zway_11-0-49-3 (was 66)
[2019-01-25 12:00:56.163] [I] [core] [MQTT-15] Trying to reconnect (0)
[2019-01-25 12:00:56.165] [I] [core] [MQTT-15] Reconnect attempt finished
[2019-01-25 12:00:57.064] [I] [core] [MQTT-15] Socket connection opened.
[2019-01-25 12:00:57.065] [I] [core] [MQTT-15] Connected to localhost as zway

Am I doing something wrong or there is an error in module?

Cannot instantiate module: MQTT:

I get this error when trying to set up the config.

Any suggestion how to solve this?

[2016-08-02 20:18:47.626] [I] [core] --- Starting module Base Module
[2016-08-02 20:18:47.636] [I] [core] [BaseModule-10] Init callbacks
[2016-08-02 20:20:40.731] [I] [core] Notification: error (core): Cannot instantiate module: MQTT: TypeError: undefined is not a function
[2016-08-02 20:20:40.741] [I] [core] TypeError: undefined is not a function
at AutomationController.instantiateModule (automation/classes/AutomationController.js:369:24)
at AutomationController.createInstance (automation/classes/AutomationController.js:671:14)
at ZAutomationAPIWebRequest._.extend.createInstance (automation/ZAutomationAPIProvider.js:1119:40)
at ZAutomationAPIWebRequest.ZAutomationWebRequest.handleRequest (automation/WebserverRequestRouter.js:258:41)
at automation/WebserverRequestRouter.js:32:35
at WebServer.document_root (automation/Webserver.js:29:11)

deleted devices, configs still active

I have installed the app and it was working , but not very stable (missing values).
Have used 4 temperature sensors (battery devices) in one configuration.
So I have added an other device (plug) with reporting voltage.

Plug was reported and I have removed the plug from device list.
Plug still have send the values to the MQTT server.
I made a copy of this configuration and disabled the first - same result.

I have disabled (stopped) the first and second configuration.
Devices still were reporting the values !!

So I had to remove the app for stopping all this reports.
And - still are coming values from the Z-Way server!!

Rebooted the Z-Way server (so restarting z-way, could not login via ssh to this server) - and now all is removed.

So something could be optimized here ;)

Thanks!
Michael

app still active supported?

@Edubits
Hi, do you support still this app?

I would like to extend the app for multilevel sensors (HTTP device,..) .
Will you still merge PR in futue ?

(if not, I could fork the repo and make changes in modified app)

Thanks!
Michael

Splitting dimmers into two mqtt objects

Currently dimmers are exposed with both on/off and dimmer level on the same attribute.
Looking at other solutions they split these two objects into two groups.

Example
server/room/Dimmer/switch (on/off)
server/room/Dimmer/level (dim level)

Might it be beneficial to use an similar approach? Making the mqtt plugin more friendly for other systems.

Zway-MQTT disappeared from git and Z-Wave-me app store

Some days ago there was an update to version 1.3.1 of the Zway MQTT app. After the update, the stability seemed to have been fixed and communication was stable. After a couple of days, i have suddenly been sent back to version 1.3 and the app has disappeared from Z-Wave-me app store. The unstability issues has returned. I am not able to get the updated version via git either. Anyone who knows what has happend?

Timeout causes disconnect?

I'm seeing an issue where when an MQTT client timeout (onTimeout event) is triggered, it simply calls onError for the client, which this module then just punts to self.onError. The module is setup to reconnect on an explicit onDisconnect, but I'm not sure a timeout event triggers that.

What I'm seeing at a macro level, is the MQTT connection in the module either goes down and doesn't come back, or just in general doesn't respond to MQTT published events anymore.

Excessive reconnects

Hey man. I'm definitely still seeing excessive reconnects on my system, and I have a theory because I'm seeing a pattern. I suspect you have a race condition in your ping handling.

Your alive_timer and ping_timer have a relationship where ping_timer is 0.6 * alive_timer. This means, with the defaults of 30 second alive_timer timeout, you are sending a ping once every 18 seconds (ish, since it sets up the next timeout AFTER a successful response). In addition, when a ping is sent, you set a timeout to check for a successful ping response at "alive_timer" (30 seconds). However, on a successful ping response you don't CLEAR the original ping check, so it STILL fires after 30 seconds. As pings continue to run, and more of these checks are queued up to run every 30 seconds, eventually I think you can see an overlap where an old ping check runs in between a much later ping being sent and the corresponding ping response clearing the this._wait_for_pingresp. This triggers an (incorrect) Timeout, and then reconnect, and all those ping timeouts never get cleared, and continue running, and the problem just gets worse and worse as time goes on.

Recommendation: Instead of checking for a variable's value (this._wait_for_pingresp), set the variable to a timeout of the ping timeout check itself (this._wait_for_pingresp = setTimeout()). Then in the ping response, clearTimeout this var (clearTimeout(this._wait_for_pingresp)) instead of what you are doing. I believe this would be a nice concise way of stopping the proliferation of orphaned ping timeout checks causing incorrect timeouts. I'd probably actually rename that var if you did this to something more descriptive.

Shelly Configuration only via workaround

The Latest Firmware of the Shelly 2.5 accepts commands via

shellies/shellyswitch25-/relay//command

which can be configured as topic and Zway-MQTT can control the relay. But Zway-MQTT misses the status updates which are given on

shellies/shellyswitch25-/relay/

Workaround is instantiating two Zway-MQTT which map the same Zway device and configure one as setter for the correct command to the shelly and the other one as getter with the correct topic to catch the status in case any other mqtt client updates the value on the mqtt server. But this results in useless mqtt traffic

A solution would be to provide two field to fully specify the requesting status topic and setting value topic and not specify a postfix for requesting status and one postfix for setting the value

Feature request: System notifications / System Errors

Thanks for your MQTT I'm using it and it works great. I would like to request if it's in anyway possible to also publish System notifications and System errors to MQTT? The use case is that if a sensor fails I would like to see that on MQTT so I can be notified by my monitoring system to fix it. In Z-way this usually manifests as the following in the events list:

System Error:
10:18 | Connection lost to Z-Wave device ID: 2

System Notification:
10:19 | Z-Wave device ID is back to life: 2

Would this be at all possible to add? Thanks!

Authenticated MQTT broker

Hi Robin

Firstly i would like to say a massive thanks for this tool. It is working really well and i have managed to get it to automate my Home Assistant in ways i never thought possible.

I just have one little issue. For some reason (probably my own stupidity) i cant seem to get thiis app working when my MQTT broker does not allow guest access. I have looked through the modules.json and mqtt.js files but dont really see anywhere where to authenticate this app to the broker. As soon as i allow guest access to the broker all works perfectly. I really hope it is something stupid that i am doing and not the design of the application.

I have entered my user credentials into the modules.json file but it has not resolved the issue.

Thanks

Terry

License

could you please add a license to the project?
without we wont be able to use your code.

add simply a LICENSE.txt to the root of your project

https://choosealicense.com/

thx

Support for Last Will + Connected state

Any interest in allowing for last will + connect notification? Something like adopting the "Connected status" of this semi-standard? https://github.com/mqtt-smarthome/mqtt-smarthome/blob/master/Architecture.md

With the current approach to topics, you actually could just automatically set up the last will topic at topicPrefix/connected with payload 0 and retain, and then just publish to the same topic but with 1 on successful connect.

This could actually have an added benefit of allowing some of us to monitor connections a bit more actively.

Problems with popp hub

I downloaded the Base module App and the MQTT App on my Popp hub but it seems that something is working wrong. Can I know if the App or the Popp Hub is correctly connected to my MQTT broker in some way? I can see the App active but not if the app or the Pop hub is correctly connected to the mosquitto broker that is running on my computer..

I also installed the mqttspy to send and see which commands are running through the mqtt server. I know that my mqtt server is correctly running because the mqttspy is connected to it and I tried it with other devices with node-red.

I saw a message before downloading the MQTT App telling that this does not work with the Popp hub. Is this message right?

When configuring the MQTT App I can´t leave in blackor in "none" mode the Topic prefix. Can I only send Tag_20B? instead of /zway/Tag_20B?

Thanks

Exception when loading module

[2016-07-19 20:04:16.576] [I] [core] [MQTT_14] Error: Error: Message type error: 6
at MQTT.BaseModule.error (automation/userModules/BaseModule/index.js:122:17)
at null._errorCallback (automation/userModules/MQTT/index.js:103:8)
at MQTTClient._onError (automation/userModules/MQTT/lib/mqtt.js:442:10)
at MQTTClient._onData (automation/userModules/MQTT/lib/mqtt.js:468:14)
at tcp.connection.onrecv (automation/userModules/MQTT/lib/mqtt.js:322:10)

Tokenized, discrete message topics

A thought I had... I don't really need this right now, but I might introduce something like this in some of my other projects soon, and thought it would be a good fit for the project... I use the same topic format that you do by default here, but there are some proposed standards like the mqtt-smarthome projects, etc. that look to use other standards like "device/status/all/the/rest" and "device/set/all/the/rest", etc. While I prefer the topic structure you use, it might open up some options for people trying to follow those proposals if they had more options for configuring topics.

So I propose a tokenized message topic option, where someone could setup the entire topic pattern as desired using tokens. Each of your topic options then would become a full topic string like "zway/{room}/{device}/set", or maybe I want to do "mySillyName/set/{room}/{device}", etc.

Tokenizing would allow for a lot of options here for people. I'm not sure what an upgrade path looks like for that for those of us already running the module though, i.e., could you take the existing settings and generate the defaults for these fields easily?

Typo in Readme

The read me lists the deviceName variable as: %deviceName and is missing the 2nd %

Battery status

Is there one or another way to have the battery status published of the Zwave node?

MQTT error in zway log

Good afternoon,
Zway server - v2.3.7, mosquitto - v1.5., again a mistake in away logs:

[2018-06-17 18:57:42.284] [I] [core] [MQTT-68] Socket connection closed.
[2018-06-17 18:57:42.287] [I] [core] [MQTT_68] Error: Disconnected, will retry to connect...
at MQTT.BaseModule.error (automation/userModules/BaseModule/index.js:122:17)
at MQTT.onDisconnect (automation/userModules/MQTT/index.js:150:7)
at MQTTClient._disconnectCallback (automation/userModules/MQTT/index.js:103:46)
at MQTTClient._onClose (automation/userModules/MQTT/lib/mqtt.js:302:10)
at tcp._connection.onclose (automation/userModules/MQTT/lib/mqtt.js:172:10)
[2018-06-17 18:57:42.308] [I] [core] [MQTT-68] Trying to reconnect (0)
[2018-06-17 18:57:42.318] [I] [core] [MQTT-68] Reconnect attempt finished
[2018-06-17 18:57:42.341] [I] [core] [MQTT-68] Socket connection opened.
[2018-06-17 18:57:42.341] [I] [core] [MQTT-68] Connected to 192.168.10.4 as Smarthome

in my opinion something similar already was, or am I mistaken? How can you get rid of this error? Thank you.

Socket error on client

Hello.
I have been running this Module on my raspberry and it is working but now I have moved to Z-Way for Windows instead and now I cant get your module running.
I hope you have some solution to this because this app is very critical in my installation, i use it for all logic, rules and control of all my z-wave devices.

This is what i get in the z-way log (not much)

[2017-01-01 23:46:18.051] [I] [core] --- Starting module MQTT
[2017-01-01 23:46:18.058] [I] [core] Executing script: /*** Buffer ******************************************************************* ...
[2017-01-01 23:46:18.061] [I] [core] Executing script: /*** MQTTClient ************************************************************** ...

And this is from my mosquitto brokers log file

1483310778: New connection from 10.0.0.6 on port 1883.
1483310779: Socket error on client , disconnecting.

I see that this is not much helpful information from the logs but maybe you have some idea what could cause this, i am running your latest version 1.1

zway installation

zway App Store: Version 1.41 is not installed. After the installation, 1.3 is still displayed. The error with Connection still exists. As soon as the network is disconnected there is a MQTT Connection error. The same happens after a change in the APP.

z-way crash after plugin error?

Z-Way was closed - last entries I found in the log:

[2020-05-01 18:51:23.548] [E] [core] Callback execution error: RangeError: Maximum call stack size exceeded
    at new Buffer (automation/userModules/MQTT/lib/buffer.js:33:15)
    at Function.MQTTClient.buildMessage (automation/userModules/MQTT/lib/mqtt.js:116:13)
    at MQTTClient._onData (automation/userModules/MQTT/lib/mqtt.js:313:29)
    at MQTTClient._onData (automation/userModules/MQTT/lib/mqtt.js:313:10)
    at MQTTClient._onData (automation/userModules/MQTT/lib/mqtt.js:313:10)
    at MQTTClient._onData (automation/userModules/MQTT/lib/mqtt.js:313:10)
    at MQTTClient._onData (automation/userModules/MQTT/lib/mqtt.js:313:10)
    at MQTTClient._onData (automation/userModules/MQTT/lib/mqtt.js:313:10)
    at MQTTClient._onData (automation/userModules/MQTT/lib/mqtt.js:313:10)
    at MQTTClient._onData (automation/userModules/MQTT/lib/mqtt.js:313:10)

Any idea?

Thanks,
Michael

Logs keeps spamming with errors

I get my z-way log file spammed with:
[2020-06-05 10:56:01.712] [I] [core] [MQTT-21] Socket connection opened. [2020-06-05 10:56:01.712] [I] [core] [MQTT-21] Connected to mosquitto.compiler.se [2020-06-05 10:56:01.713] [I] [core] [MQTT-21] ----------------- undefined [2020-06-05 10:56:01.713] [I] [core] [MQTT-21] +++++++++++++++++ {"first_start_up":"2019-11-02T12:06:52.325Z","count_of_reconnects":40,"emailInitialActivated":true,"firstaccess":false} [2020-06-05 10:56:02.726] [I] [core] [MQTT-21] Trying to reconnect (0) [2020-06-05 10:56:03.750] [I] [core] [MQTT-21] Socket connection closed. [2020-06-05 10:56:03.753] [I] [core] [MQTT_21] Error: Disconnected, will retry to connect... at MQTT.BaseModule.error (automation/userModules/BaseModule/index.js:122:17) at MQTT.onDisconnect (automation/userModules/MQTT/index.js:139:7) at MQTTClient._disconnectCallback (automation/userModules/MQTT/index.js:92:46) at MQTTClient._onClose (automation/userModules/MQTT/lib/mqtt.js:303:10) at tcp._connection.onclose (automation/userModules/MQTT/lib/mqtt.js:173:10) [2020-06-05 10:56:03.753] [I] [core] [MQTT-21] Socket connection opened. [2020-06-05 10:56:03.753] [I] [core] [MQTT-21] Connected to mosquitto.compiler.se [2020-06-05 10:56:03.754] [I] [core] [MQTT-21] ----------------- undefined [2020-06-05 10:56:03.754] [I] [core] [MQTT-21] +++++++++++++++++ {"first_start_up":"2019-11-02T12:06:52.325Z","count_of_reconnects":40,"emailInitialActivated":true,"firstaccess":false} [2020-06-05 10:56:04.770] [I] [core] [MQTT-21] Trying to reconnect (0) [2020-06-05 10:56:05.792] [I] [core] [MQTT-21] Socket connection closed. [2020-06-05 10:56:05.797] [I] [core] [MQTT_21] Error: Disconnected, will retry to connect... at MQTT.BaseModule.error (automation/userModules/BaseModule/index.js:122:17) at MQTT.onDisconnect (automation/userModules/MQTT/index.js:139:7) at MQTTClient._disconnectCallback (automation/userModules/MQTT/index.js:92:46) at MQTTClient._onClose (automation/userModules/MQTT/lib/mqtt.js:303:10) at tcp._connection.onclose (automation/userModules/MQTT/lib/mqtt.js:173:10) [2020-06-05 10:56:05.798] [I] [core] [MQTT-21] Socket connection opened. [2020-06-05 10:56:05.798] [I] [core] [MQTT-21] Connected to mosquitto.compiler.se [2020-06-05 10:56:05.798] [I] [core] [MQTT-21] ----------------- undefined [2020-06-05 10:56:05.798] [I] [core] [MQTT-21] +++++++++++++++++ {"first_start_up":"2019-11-02T12:06:52.325Z","count_of_reconnects":40,"emailInitialActivated":true,"firstaccess":false} [2020-06-05 10:56:06.812] [I] [core] [MQTT-21] Trying to reconnect (0) [2020-06-05 10:56:07.835] [I] [core] [MQTT-21] Socket connection closed. [2020-06-05 10:56:07.839] [I] [core] [MQTT_21] Error: Disconnected, will retry to connect... at MQTT.BaseModule.error (automation/userModules/BaseModule/index.js:122:17) at MQTT.onDisconnect (automation/userModules/MQTT/index.js:139:7) at MQTTClient._disconnectCallback (automation/userModules/MQTT/index.js:92:46) at MQTTClient._onClose (automation/userModules/MQTT/lib/mqtt.js:303:10) at tcp._connection.onclose (automation/userModules/MQTT/lib/mqtt.js:173:10) [2020-06-05 10:56:07.840] [I] [core] [MQTT-21] Socket connection opened. [2020-06-05 10:56:07.840] [I] [core] [MQTT-21] Connected to mosquitto.compiler.se [2020-06-05 10:56:07.840] [I] [core] [MQTT-21] ----------------- undefined [2020-06-05 10:56:07.841] [I] [core] [MQTT-21] +++++++++++++++++ {"first_start_up":"2019-11-02T12:06:52.325Z","count_of_reconnects":40,"emailInitialActivated":true,"firstaccess":false} [2020-06-05 10:56:08.855] [I] [core] [MQTT-21] Trying to reconnect (0)

I also gets a "%" inserted somehow into the topic and i do now know where to look and its only when the mqtt app in z-way is listening/sending.. I really dont know were to begin to look.

%roomName% and %deviceName% CamelCased

In the Topic field you can use %roomName% and %deviceName%. These names will camel cased (more accurately lowerCamelCased).
It would be preferable to use UpperCamelCased as you can see in these examples:

%roomName%/%deviceName% > with lowerCamelCased > with UpperCamelCased
Room/Device - Energy > room/device-Energy > room/device-Energy (1)
ROOM/DEVICE - Energy > rOOM/dEVICE-Energy > ROOM/DEVICE-Energy (2)

1).- no differences
2).- better understanding when there are words in capital letters

Is this change possible?
To avoid compatibility problems, new variables could be used (%RoomName% and %DeviceName%) for the UpperCamelCased.

Thanks.

MQTT with Bluemix MQTT iothub

Hello Robin,

I am trying to use your MQTT module to connect my MQTT server in the bluemix. I got some initial problem with username and password. Why it should be less than 12 simbols ? I removed that limit but anyway have

[2017-03-07 01:09:58.106] [I] [core] [MQTT-12] Trying to reconnect (NaN)

Could you help me to solve the problem ? I created MQTT for your testing and sent all credential in the email.

Connection loss on Event Update

Hey,

I recently startet to play around with mosquitto and this MQTT module.
If I request #/example/status by sending a 0 msg everything is fine, if I just wait for the device Events I only see errors in the log, no device update is pushed automatically into MQ.

For Example a Power Meter reporting it WATT:

[2017-08-09 20:49:37.869] [D] [zway] SENT ACK
[2017-08-09 20:49:37.869] [D] [zway] SETDATA devices.8.data.lastReceived = 0 (0x00000000)
[2017-08-09 20:49:37.869] [D] [zway] SETDATA devices.8.instances.0.commandClasses.49.data.4.deviceScale = 0 (0x00000000)
[2017-08-09 20:49:37.869] [D] [zway] SETDATA devices.8.instances.0.commandClasses.49.data.4.scale = 0 (0x00000000)
[2017-08-09 20:49:37.871] [D] [zway] SETDATA devices.8.instances.0.commandClasses.49.data.4.scaleString = "W"
[2017-08-09 20:49:37.871] [D] [zway] SETDATA devices.8.instances.0.commandClasses.49.data.4.val = 26.900000
[2017-08-09 20:49:37.871] [D] [zway] SETDATA devices.8.instances.0.commandClasses.49.data.4 = Empty
[2017-08-09 20:49:37.928] [I] [core] Notification: device-info (device-power): {"dev":"Power #8","l":"26.9 W","location":""}
[2017-08-09 20:49:37.998] [I] [core] [BaseModule-16] Set lastLevel to 26.9 for ZWayVDev_zway_8-0-49-4 (was 258.7000064)
[2017-08-09 20:49:38.021] [I] [core] [MQTT-17] Socket connection closed.
[2017-08-09 20:49:38.025] [I] [core] [MQTT_17] Error: Disconnected, will retry to connect...
at MQTT.BaseModule.error (automation/userModules/BaseModule/index.js:122:17)
at MQTT.onDisconnect (automation/userModules/MQTT/index.js:139:7)
at MQTTClient._disconnectCallback (automation/userModules/MQTT/index.js:92:46)
at MQTTClient._onClose (automation/userModules/MQTT/lib/mqtt.js:303:10)
at tcp._connection.onclose (automation/userModules/MQTT/lib/mqtt.js:173:10)
[2017-08-09 20:49:38.046] [I] [core] [MQTT-17] Trying to reconnect (0)

Doesn't matter if Report is 0 or > 1 always disconnect. No Error in mosquitto log.

Duplicate values not ignored as requested in module instance settings

This is an extremely useful module.
It seems the option "Ignore duplicate values" doesn't work. I subscribe to multiple devices using a common tag and have the topic defined as %roomName%/%deviceName%. And this is what I get:

zway/malaPracovna/teplota 21.9
zway/malaPracovna/svetlo 21
zway/malaPracovna/teplota 21.9
zway/malaPracovna/svetlo 21
zway/malaPracovna/teplota 21.9
zway/malaPracovna/svetlo 21

Potential issue with non-unique clientId

As mentioned by Lars in the comments:

After having some problems with the script trying to reconnect, I debugged and fixed that problem.I changed the line 89 in MQTT/index.js to: var mqttOptions = client_id: self.config.clientId + Math.random().toString(16).substr(2, 6); That is adding a random ending to the clientId to get the mqqt-client to stop trying to reuse the old connection. I'm not that skilled and rather new to mosquitto so it might not be the correct fix. But it worked for me.

Timestamp for mqtt messages

Hi everyone, for a retained mqtt topic i can use %deviceName% or %roomName% as dynamic variables - is there a %timestamp% tag or any other way to publish the timestamp of the last on/off toggle?
cheers

time out

Dont see this issue anywhere reported.

[2021-02-20 15:31:34.659] [I] [core] [MQTT_15] Error: Error: Timeout
at MQTT.BaseModule.error (automation/userModules/BaseModule/index.js:122:17)
at MQTTClient._errorCallback (automation/userModules/MQTT/index.js:109:46)
at MQTTClient._onError (automation/userModules/MQTT/lib/mqtt.js:276:10)
at MQTTClient._onTimeout (automation/userModules/MQTT/lib/mqtt.js:307:8)
at Function. (automation/userModules/MQTT/lib/mqtt.js:472:40)

On Mosquitto side it looks like:
1611934649: New connection from 127.0.0.1:54531 on port 1883.
1611934650: Client closed its connection.

I had it posted here as well. My nick was zwaFisher
https://forum.z-wave.me/viewtopic.php?f=3422&t=33756

Subscription

I was just wondering how do i solve the subscription part for a device based on a topic?

For now i just have a dummy device which i only get publish to work but not subscription. I have set the device and set a topic to "livingroom/dht/temperature" and then i take it the whole topic by the app will be "zway/livingroom/dht/temperature/set" ? Im using default values for postfix.

I just took your explanation when it said it could set values based on subscriptions =)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.