zwave-js-ui
zwave-js-ui copied to clipboard
[feat] Standarized Topics
Is your feature request related to a problem? Please describe. I'm developing a client library for use with zwavejs2mqtt's MQTT API. I'd like the client to be able to set values of ZWave nodes via the MQTT API.
The client is able to discover nodes and their attributes using the getNodes
API. Using the getNodes
response, I'd like to know how to set values. The issues is that, depending on the "Gateway: Type" setting, e.g. ValueId Topics
or Named Topics
, the topic to set values changes. There's no way for the client to know which is in use.
<mqtt_prefix>/<?node_location>/<nodeId>/<commandClass>/<endpoint>/<property>/<propertyKey>
OR
<mqtt_prefix>/<?node_location>/<node_name>/<class_name>/<?endpoint>/<propertyName>/<propertyKey>
Describe the solution you'd like
One suggestion would be to support both APIs, e.g. ValueId
and Named
topics. Another suggestion would be to expose via MQTT which mode the gateway is in.
The mode wouldn't be enought as there are also some flags like use node name instead numeric id
or ignore location
that could change the topic.
Also support both topic formats isn't really an option. What I can suggest is to make the settings strict and tell your users to use those settings when using with your library. Otherwise you could get the configuration using an api request to get all settings: https://github.com/zwave-js/zwavejs2mqtt/blob/master/app.js#L667
BTW If you tell me what is your goal with this api I could suggest the best way to integrate it with z2m.
Since version 2.0.0 it will also support plugins and that could make it even easier for you: https://zwave-js.github.io/zwavejs2mqtt/#/guide/plugins
Thanks for the information.
BTW If you tell me what is your goal with this api I could suggest the best way to integrate it with z2m.
My goal is to provide a simple client for z2m. Specifically,
- I'd like to use the
getNodes
API to populate the client with a list of nodes + values. - I'd like the client to have a method to set node values. For example:
This is difficult to implement, as described in the original issue, since the topic to set values depends on how Zwavejs2Mqtt is configured. Ideally, there would be a standard MQTT topic to set values, maybe even one underz2mClient.Set("node-name", "property-name", 42)
zwave/_CLIENTS/ZWAVE_GATEWAY-$name/api
.
As I said I really suggest you to use Plugins for this
Thanks for the suggestion. I imagine that a plugin would work, but I'd rather not go that route for two reasons:
- This would force users of my client library to install a plugin, which I'd like to avoid
- It would be a significant effort on my part to maintain, in addition to the client library (which is not written in Javascript), a plugin for z2m
I've started to use the writeValue(valueId, value)
MQTT API and I think it will work for my use cases.
Hummm I don't get your points, with a plugin you can directly access all the instances of z2m like the client, mqtt and also the express instance and use the express instance to create the apis and the client to have a direct access to zwave stuff. IMO this is the easier solution but it's your choice I don't mind sincerly do what you prefer and ask me if you need some other help :)