Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[feat] Ability to send a stop value to the same topic as position request #30

Closed
ODINServ opened this issue Nov 25, 2020 · 23 comments · Fixed by #40
Closed

[feat] Ability to send a stop value to the same topic as position request #30

ODINServ opened this issue Nov 25, 2020 · 23 comments · Fixed by #40
Assignees
Labels
enhancement New feature or request

Comments

@ODINServ
Copy link

Hi,

Im am slowly integrating into openhab, i want to use the openhab model "RollerShutter" to control my shutters.

It has 3 buttons -> up (value 99) -> stop ( value stop / or custom) -> down (value 0), i can also send a level in the form of a number between 0 - 100 (which is than mapped the openhab mqtt config to 0-99).

What is does is sending a request to the zwavejs2mqtt/study/switch_multilevel/endpoint_1/targetValue/set

In there model i cannot select a other topic to send the stop command to.
It would be nice that i can send the "stop" word or any other value op the targetValue/set topic to use the build in openhab model, i think home assistant is using the same approach.

openhab

Currenly i am using the "dimmer" model to send values and use a openhab switch to send stop (by means of sending false) the Up or Down topic.

Thnx!

@ODINServ ODINServ added the enhancement New feature or request label Nov 25, 2020
@robertsLando
Copy link
Member

@ODINServ YOu can do such things by using custom send/receive functions provided in gateway values table. You can write a function that parse the payload as you want

@ODINServ
Copy link
Author

I see i will give it a try, maybe the docs can be updated with an example?

I will figure it out and try to update them my self, that would be my first commit on github.

@robertsLando
Copy link
Member

robertsLando commented Nov 25, 2020

@ODINServ The function will be like:

if(value) return "start";

return "stop"

this is what you need to write inside the parse send function of gateway value, the value you see there is the value that is going to be sent from z2m

This will return "start" instead of 1 and "stop" instead of 0

@ODINServ
Copy link
Author

I'm not sure if this is what i want, but i can indeed use that for something else.

So when i press the stop button on the openhab interface, it should stop the movement of the blinds.
openhab will send "stop" to the /targetValue/set topic

So from your example and what is on the gateway values table.
I guess i need then the parse receive
Create a function that parse the received value from MQTT

So that would than be:

if (value == "stop") return something?
return value;

But what would the something than because i guess the only accepted values are 0-99.

@robertsLando
Copy link
Member

robertsLando commented Nov 26, 2020

If you need to parse the received commad from openhab and the command is "stop" the function will do the opposite of the one I have wrote:

if (value == "stop") return 1;
return 0;

But wait don't you have the other stop switch? You are working with the dimmer, you can't stop it in this way I think

@ODINServ
Copy link
Author

ODINServ commented Nov 29, 2020

Yes currently im using the dimmer as a work around which indeed has no stop button.

So i want to use this model:
Screenshot from 2020-11-29 16-05-00

When i press the STOP button it send STOP to the targetValue topic.
Which is translated to 0 by zwave-js, but that is equal to the "closed" value.

But what it should do is stop the movement of the shutters.

Is that possible?, if not it would be nice, since also openhab an home-assistant is using this approach.

@ODINServ
Copy link
Author

I have this python script now running in the background as a man in the middle and handles this model:

def on_message(client, userdata, msg): 
    item = str(msg.topic).split('/')[2]
    value = str(msg.payload.decode("utf-8"))
    if value == "STOP":
        client.publish('zwavejs2mqtt/{}/switch_multilevel/endpoint_1/Up/set'.format(item), payload="false")
    else:
        client.publish('zwavejs2mqtt/{}/switch_multilevel/endpoint_1/targetValue/set'.format(item), payload=value)

@robertsLando
Copy link
Member

But what it should do is stop the movement of the shutters.

Is there another valueId that could handle the stop?

@ODINServ
Copy link
Author

I guess, the answer could be yes? I found a spec but not sure if it is still valid, and if i look at the right versions of things.

I found a/some zwave spec (not sure of this is still a valid one?): https://www.silabs.com/documents/login/miscellaneous/SDS13781-Z-Wave-Application-Command-Class-Specification.pdf

It seems that 255 is a thing to set in the targetValue which means "Restore most recent (non-zero) level." -> Paragraph 4.69.1 table 81
This is not working aswell, it is converted to 99.

And it seems that stop is a complete different command: (Chapter 4.69.5)

Command Class = COMMAND_CLASS_SWITCH_MULTILEVEL
Command = SWITCH_MULTILEVEL_STOP_LEVEL_CHANGE

But i guess if you want to implement that generic that it would a stop topic right, which i personally don't like if i want to use the existing (openhab / hass) models.

I would like to send that STOP string to targetValue which then sends the actual "SWITCH_MULTILEVEL_STOP_LEVEL_CHANGE".

So i'm not sure if i look at the right things here.

@robertsLando
Copy link
Member

robertsLando commented Nov 30, 2020

This is not working aswell, it is converted to 99.

You mean that if you send 255 it will stop it?

Could you try to send 255 using the web ui and tell me if that works?

@ODINServ
Copy link
Author

Nope,

When sending 255 via mqtt it should also send 255 to the device, the device will (should) then return according to that spec it's previous position.

I would like to send the "STOP" string to targetValue, and then it would be nice that zwave-js is sending the "SWITCH_MULTILEVEL_STOP_LEVEL_CHANGE" command to the device.

It is also in the code in some:
Screenshot from 2020-11-30 15-36-01

@robertsLando
Copy link
Member

This is something that cannot (and shouldn't) be handled by zwave-js, is that valueId showing on ui? I mean the SWITCH_MULTILEVEL_STOP_LEVEL_CHANGE ?

@ODINServ
Copy link
Author

I looked in the node-zwave-js code i want to be able to call this: https://github.com/zwave-js/node-zwave-js/blob/master/packages/zwave-js/src/lib/commandclass/MultilevelSwitchCC.ts#L215

When "STOP" is received on the targetValue topic

HASS "cover" model stop button on UI: https://community-assets.home-assistant.io/original/3X/a/7/a734d7af96795576ddd092345f84e3f78971fe07.png
And the openhab "RollerShutter" model one is in the picture above.

Why should this than not be handled by zwavejs?

@robertsLando
Copy link
Member

Let's see what @AlCalzone think about this

@AlCalzone
Copy link
Member

Stopping should be possible with stopLevelChange, which is a different command. @robertsLando You are already exposing this as a switch (perform a level change) so it should just be a matter of setting the correct value.

The value 255 can be used to turn a light that was at 60 for example and then was turned off back on to 60.

@robertsLando
Copy link
Member

@AlCalzone could you show me an example of how I could trigger a stopLevelChange command?

@AlCalzone
Copy link
Member

AlCalzone commented Nov 30, 2020

e.g. by setting the value for value ID

{
  "commandClass": 38,
  "endpoint": 0,
  "property": "Open" // or however it is called on this node - zwave-js doesn't really care.
}

to false.

Or:

await node.commandClasses["Multilevel Switch"].stopLevelChange();

@robertsLando
Copy link
Member

@ODINServ Could you try #40 ?

@ODINServ
Copy link
Author

ODINServ commented Dec 1, 2020

I will try later today

@ODINServ
Copy link
Author

ODINServ commented Dec 1, 2020

I seem only to be able to add logging here: zwave-1979.txt

@ODINServ
Copy link
Author

ODINServ commented Dec 1, 2020

zwave-2466.log

@robertsLando
Copy link
Member

@ODINServ I have closed this for now but just to let you know I have reverted the change on code to use the stopLevelChange command. THis needs to be sorted on zwavejs side so don't use the code from master or it will not work.

@ODINServ
Copy link
Author

ODINServ commented Dec 2, 2020

zwave-4554.log

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants