OpenZWave / Zwave2Mqtt

Fully configurable Zwave to MQTT gateway and Control Panel using NodeJS and Vue
MIT License
351 stars 93 forks source link

[bug]roller shutter detected as light dimmers #329

Closed rflx18 closed 3 years ago

rflx18 commented 4 years ago

Version

Build/Run method

Zwave2Mqtt version: v3.0.2 Openzwave Version: 1.6.1061

Describe the bug all of my shutters are detected as light_dimmers, the function works but they are detected as light dimmers in homeassistant aswell. i already have remove and readded the node since they where coming from homeassistant zwave integration that work in 1.4 openzwave.

any ideia how to fix the bug? also, can i change the hass device json so at least they are detected as rollers in homeassistant?

{ "type": "light", "object_id": "dimmer", "discovery_payload": { "schema": "template", "brightness_template": "{{ (value_json.value / 99 255) | round(0) }}", "state_topic": "zwave2mqtt/37/38/1/0", "state_template": "{{ \"off\" if value_json.value == 0 else \"on\" }}", "command_topic": "zwave2mqtt/37/38/1/0/set", "command_on_template": "{{ ((brightness / 255 99) | round(0)) if brightness is defined else 255 }}", "command_off_template": "0", "device": { "identifiers": [ "zwave2mqtt_0xddaa6b5c_node37" ], "manufacturer": "FIBARO System", "model": "FGRM222 Roller Shutter Controller 2 (0x1000)", "name": "nodeID_37", "sw_version": "Unknown" }, "name": "nodeID_37_dimmer", "unique_id": "zwave2mqtt_0xddaa6b5c_37-38-1-0" }, "discoveryTopic": "light/nodeID_37/dimmer/config", "values": [ "38-1-0" ], "persistent": false, "id": "light_dimmer" }

robertsLando commented 4 years ago

@rflx18 Unfortunally that's not a bug, actually I have no way to identify the roller shutter, It is a switch multilevel and that class is also used for lights. The only thing you can do is to manually edit the discovery payload with the configuration you want and make it persistent by pressing on store. In this way once z2m starts it will use your configuration instead of using its auto-detect algorithm.

If you successfully make it work as a cover please paste here the discovery payload so other users can use it :)

rflx18 commented 4 years ago

i have been trying that without sucess, at least with lovelace custom card i can manage it fairly well, i pledge the same, if anyone have a sucess payload for HA please share.

robertsLando commented 4 years ago

Did you try to follow this ?

Try with something like this:

 {
   type: 'cover',
   object_id: 'position',
   values: ['38-1-0'],
   discovery_payload: {
     command_topic: "zwave2mqtt/37/38/1/0",
     position_topic: "zwave2mqtt/37/38/1/0",
     set_position_topic: "zwave2mqtt/37/38/1/0",
     value_template: "{{ (value_json.value / 99 * 100) | round(0) }}",
     position_open: 99,
     position_closed: 0,
     payload_open: "99",
     payload_close: "0"
   }
}
rflx18 commented 4 years ago

thats doesnt work it says JSON test failed, i dont have enought knowledge to create that :(

robertsLando commented 4 years ago

@rflx18 Because it is js not json.

{
  "type":"cover",
  "object_id":"position",
  "values":["38-1-0"],
  "discovery_payload":{
    "command_topic":"zwave2mqtt/37/38/1/0",
    "position_topic":"zwave2mqtt/37/38/1/0",
    "set_position_topic":"zwave2mqtt/37/38/1/0",
    "value_template":"{{ (value_json.value / 99 * 100) | round(0) }}",
    "position_open":99,
    "position_closed":0,
    "payload_open":"99",
    "payload_close":"0"
  }
}
rflx18 commented 4 years ago

no luck, didnt appeared :(

robertsLando commented 4 years ago

You have to press on rediscover

rflx18 commented 4 years ago

i did, no luck there, im trying creating it from HA but not having luck also thought

robertsLando commented 4 years ago

You have to check on hass logs what is wrong with the payload. Paste the error here

rflx18 commented 4 years ago

i just dont see anything in HA once i publish the new code.

here is how the code stays, the last lines are always added automatically

{ "type": "cover", "object_id": "position", "values": [ "38-1-0" ], "discovery_payload": { "command_topic": "zwave2mqtt/37/38/1/0", "position_topic": "zwave2mqtt/37/38/1/0", "set_position_topic": "zwave2mqtt/37/38/1/0", "value_template": "{{ (value_json.value / 99 * 100) | round(0) }}", "position_open": 99, "position_closed": 0, "payload_open": "99", "payload_close": "0" }, "persistent": true, "id": "light_dimmer" }

if i try like this, { "type": "cover", "object_id": "position", "values": [ "38-1-0" ], "discovery_payload": { "command_topic": "zwave2mqtt/37/38/1/0", "position_topic": "zwave2mqtt/37/38/1/0", "set_position_topic": "zwave2mqtt/37/38/1/0", "value_template": "{{ (value_json.value / 99 * 100) | round(0) }}", "position_open": 99, "position_closed": 0, "payload_open": "99", "payload_close": "0", "device": { "identifiers": [ "zwave2mqtt_0xddaa6b5c_node37" ], "manufacturer": "FIBARO System", "model": "FGRM222 Roller Shutter Controller 2 (0x1000)", "name": "Escritorio-Janela-Escritorio", "sw_version": "Unknown" }, "name": "Escritorio-Janela-Escritorio_dimmer", "unique_id": "zwave2mqtt_0xddaa6b5c_37-38-1-0" }, "discoveryTopic": "light/Escritorio-Janela-Escritorio/dimmer/config", "persistent": true, "id": "light_dimmer" }

then i get this output

File "/usr/src/homeassistant/homeassistant/components/mqtt/light/schema_template.py", line 146, in discovery_update
config = PLATFORM_SCHEMA_TEMPLATE(discovery_payload)
File "/usr/local/lib/python3.7/site-packages/voluptuous/schema_builder.py", line 272, in call
return self._compiled([], data)
File "/usr/local/lib/python3.7/site-packages/voluptuous/schema_builder.py", line 594, in validate_dict
return base_validate(path, iteritems(data), out)
File "/usr/local/lib/python3.7/site-packages/voluptuous/schema_builder.py", line 432, in validate_mapping
raise er.MultipleInvalid(errors)
voluptuous.error.MultipleInvalid: extra keys not allowed @ data['position_topic']

rflx18 commented 4 years ago

ok, some sucess,

{ "type": "cover", "object_id": "position", "values": [ "38-1-0" ], "discovery_payload": { "command_topic": "zwave2mqtt/37/38/1/0/set", "position_topic": "zwave2mqtt/37/38/1/0/set", "set_position_topic": "zwave2mqtt/37/38/1/0/set", "value_template": "{{ (value_json.value / 99 * 100) | round(0) }}", "position_open": 99, "position_closed": 0, "payload_open": "99", "payload_close": "0", "device": { "identifiers": [ "zwave2mqtt_0xddaa6b5c_node37" ], "manufacturer": "FIBARO System", "model": "FGRM222 Roller Shutter Controller 2 (0x1000)", "name": "Escritorio-Janela-Escritorio", "sw_version": "Unknown" }, "name": "Escritorio-Janela-Escritorio_dimmer", "unique_id": "zwave2mqtt_0xddaa6b5c_37-38-1-0" }, "discoveryTopic": "cover/Escritorio-Janela-Escritorio/cover/config", "persistent": true, "id": "light_dimmer" }

but still i have a error when i press

2020-03-26 22:24:51 ERROR (MainThread) [homeassistant.helpers.template] Error parsing value: 'int object' has no attribute 'value' (value: 88, template: {{ (value_json.value / 99 * 100) | round(0) }})

rflx18 commented 4 years ago

new update, im having some degree of sucess by manually adding the cover in homeassistant and not by the discorey. if some brain can now help with the stop button, it would be perfect, so far position, up and down is working, stop button just close the shutter.

here is the code for homeassistant.

the payload_stop: could be a template that read the current position and issue that position to stop, i have no ideia how to do it, but i know is possible, any help :) i tried payload_stop: "50" and it stoped halfway.

"{{ states.cover.blackout_escritorio.attributes.current_position }}" this return the current position, so how can i load this in the payload_stop: ?

Matt-PMCT commented 4 years ago

@robertsLando I spent sometime this morning figuring out the JSON payload for discovery. This seems to work for me, including ability to control with up or down arrows and set the position with a slider.

{
  "type": "cover",
  "object_id": "level",
  "discovery_payload": {
    "state_topic": "zwave2mqtt/cover_office/38/1/0",
    "position_topic": "zwave2mqtt/cover_office/38/1/0",
    "value_template": "{{ (value_json['value']) | round(0) }}",
    "command_topic": "zwave2mqtt/cover_office/38/1/0/set",
    "set_position_topic": "zwave2mqtt/cover_office/38/1/0/set",
    "position_open": 99,
    "position_closed": 0,
    "payload_open": "99",
    "payload_close": "0",
    "unique_id": "zwave2mqtt_0xc082b237_15-38-1-0",
    "device": {
      "identifiers": [
        "zwave2mqtt_0xc082b237_node15"
      ],
      "manufacturer": "Springs Window Fashions (Graber)",
      "model": "CSZ1 Cellular Shade (0x5a31)",
      "name": "cover_office",
      "sw_version": "11.02"
    },
    "name": "cover_office_level"
  },
  "discoveryTopic": "cover/cover_office/config",
  "values": [
    "38-1-0"
  ],
  "persistent": true,
  "id": "light_dimmer"
}

I cannot seem change the "id" at bottom though, it always reverts to light_dimmer. And I'm not sure how to use this across all of my devices other than manually changing each one (I started learning this yesterday, so very new).

But since you have a "type" for "Window Covering Position/Endpoint Aware", could we set the Home Assistant Discovery tool to use this payload structure automatically when that type of Z-wave device is added? If you want me to do some more work, I'll help out if you could point me where I should be looking to do this modification :)

robertsLando commented 4 years ago

@Lopton Could you send a PR for that?

Matt-PMCT commented 4 years ago

@rflx18 you were saying that the stop command is not working for you, it is also not working for me. I did find though that if I sent a position value of 100 the shade stops. Any chance you can try get the shade moving and then send a position of value of 100 to it and see if your shade also stops moving? I used MQTT explorer to publish the 100 value I needed for testing to the right topic.

P-Verbrugge commented 4 years ago

Same issue happens here with Forest Shuttle L Z-Wave. I see the device as "Window Covering Position/Endpoint Aware" but is also returned as a light dimmer. :-( The zwave implementation of HomeAssistant makes a cover with the correct functionality.

robertsLando commented 4 years ago

@P-Verbrugge https://github.com/OpenZWave/Zwave2Mqtt#question-faq

squiddity commented 4 years ago

I was poking around on the slack on this topic but figured I'd leave a note to future searchers here regarding stop command on shutters. This may be different for each roller shutter provider but for Somfy ZRTSI zwave to RTS bridge, a multilevel switch "stop level change" command will recreate the stop button on the remote. One way I can tell to send it via openzwave is a false on 38-1-1 (more detail at https://github.com/OpenZWave/open-zwave/issues/851), which zwave2mqtt can do via the setting the particular topic. So like the other shutters here, the Somfy is detected as a switch and a dimmer, and with a template cover sending a specific zwave command for stop is possible. This works for a given Somfy shutter with zwave node 19, delegating to the switch for open/close and the custom zwave call to node 19 for stop:

cover:
        platform: template
        covers:
                cover_room:
                        device_class: shade
                        friendly_name: 'room cover'
                        value_template: "{{is_state('switch.nodeid_19_switch', 'on')}}"
                        open_cover:
                                service: switch.turn_on
                                entity_id: switch.nodeid_19_switch
                        close_cover:
                                service: switch.turn_off
                                entity_id: switch.nodeid_19_switch
                        stop_cover:
                                service: mqtt.publish
                                data:
                                        topic: discoveryprefix/nodeID_19/38/1/1/set
                                        payload: "false"

If you can find the specific zwave setValue call for stop for your shades, this technique may work, changing the topic and payload to setl. I'm stuck migrating this to a mqtt hass discovery template because I'm using two different topics / zwave profiles within the device, 37/1/0 for the switch open close and false to 38/1/1 for the stop command, and afaict the hass mqtt discovery api only allows for one command topic.

rflx18 commented 3 years ago

with the new version, 4.0.0 my fibaros are detected as covers and working as expected but the philio pan08-1 still remains as light dimmers, @robertsLando can we rollout the same solution implemented for the fibaros for the other covers?

robertsLando commented 3 years ago

@rflx18 the problem is just one: how can I say that a specific Multilevel Switch value of a device is of a cover and not a light dimmer?

If you find me an answer to this I would be glad to implement the solution and extend that template to all covers

rflx18 commented 3 years ago

@robertsLando that is far from my knowledge :( i wish i could help, i was trying to help by stating that the fibaro are now recognized as covers but this philio model are not, is there something i can do to help?

robertsLando commented 3 years ago

@rflx18 I understand but actually the question I have asked to you is the reason that doesn't allow me to do what you have asked, there could be a solution but detect the type of a device is always be a problem (you can see many questions about this in issues).

Could you check if you have any command class that is specific to covers? Like 0x6A (COMMAND_CLASS_WINDOW_COVERING) ? If so I could use them to detect covers

rflx18 commented 3 years ago

i dont know if this is what you asked for, this is for the non corrected detection.

image

robertsLando commented 3 years ago

@rflx18 nope, I'm looking for the nodes command classes. You see them in node tab when you select a node, the id you see on all nodes is composed by <commandClass>-<instance>-<index>. You need to find an id with command class 106 (0x6A)

rflx18 commented 3 years ago

@robertsLando something like this?"zwave2mqtt_0xddaa6b5c_node29"

robertsLando commented 3 years ago

Nope

rflx18 commented 3 years ago

@robertsLando sorry, i have no ideia where i can find that, i have searched everything, even in the correct covers without sucess.

robertsLando commented 3 years ago

You haven't to search in the code, it's in the UI. Go to control panel, select a node and go to node tab, check values, near values label there is the valueid with the command class

rflx18 commented 3 years ago

@robertsLando i have searched for valueid and nothing, i went trought all menus under values and didnt find that. image

robertsLando commented 3 years ago

Open the user/configuration/system sections and you will see the values


Daniel

On 31 Jul 2020, at 19:14, rflx18 notifications@github.com wrote:

 @robertsLando i have searched for valueid and nothing, i went trought all menus under values and didnt find that.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or unsubscribe.

rflx18 commented 3 years ago

Device ID: 316-21-1 Name: Portada-Sala New name Portada-Sala Location: Sala New Location Sala Values User Turn On/Off Device Level (30-38-1-0) 99 Step Size (30-38-1-6) 0 Scene (30-43-1-0) 0 Duration (30-43-1-1) 0 Electric - kWh (30-50-1-0) 0 kWh Electric - W (30-50-1-2) 0.4 W Electric - V (30-50-1-4) 231.6 V Electric - A (30-50-1-5) 0 A Electric - PF (30-50-1-6) 0 PF Exporting (30-50-1-256) false Alarm Type (30-113-1-512) 0 Alarm Level (30-113-1-513) 0

Configuration Watt meter report period (30-112-1-1) 720 kWh meter report period (30-112-1-2) 6 Threshold of Watt for Load Caution (30-112-1-3) 1100 Threshold of kWh for Load Caution (30-112-1-4) 10000 External switch type (30-112-1-5) 1 Level report mode (30-112-1-6) 1 Automatically Clear Events (30-113-1-514) 5000 ms System Ignore the Start Level of the Device when increasing/decreasing brightness Start Level (30-38-1-4) 0 Dimming Duration (30-38-1-5) 15300 ZWave+ Version (30-94-1-0) 1 InstallerIcon (30-94-1-1) 6656 UserIcon (30-94-1-2) 6656 Loaded Config Revision (30-114-1-0) 7 Config File Revision (30-114-1-1) 7 Latest Available Config File Revision (30-114-1-2) 7 Serial Number (30-114-1-4) 00061594 Powerlevel (30-115-1-0) Normal Timeout (30-115-1-1) 0 seconds Test Node (30-115-1-3) 0 Test Powerlevel (30-115-1-4) Normal Frame Count (30-115-1-5) 0 Test Status (30-115-1-8) Failed Acked Frames (30-115-1-9) 0 Library Version (30-134-1-0) 3 Protocol Version (30-134-1-1) 4.38 Application Version (30-134-1-2) 1.05

robertsLando commented 3 years ago

Ok that’s correct, I don’t see anything that could help to detect it’s a cover and not a light based on those values


Daniel

On 31 Jul 2020, at 19:53, rflx18 notifications@github.com wrote:

 Device ID: 316-21-1 Name: Portada-Sala New name Portada-Sala Location: Sala New Location Sala Values User Turn On/Off Device Level (30-38-1-0) 99 Step Size (30-38-1-6) 0 Scene (30-43-1-0) 0 Duration (30-43-1-1) 0 Electric - kWh (30-50-1-0) 0 kWh Electric - W (30-50-1-2) 0.4 W Electric - V (30-50-1-4) 231.6 V Electric - A (30-50-1-5) 0 A Electric - PF (30-50-1-6) 0 PF Exporting (30-50-1-256) false Alarm Type (30-113-1-512) 0 Alarm Level (30-113-1-513) 0

Configuration Watt meter report period (30-112-1-1) 720 kWh meter report period (30-112-1-2) 6 Threshold of Watt for Load Caution (30-112-1-3) 1100 Threshold of kWh for Load Caution (30-112-1-4) 10000 External switch type (30-112-1-5) 1 Level report mode (30-112-1-6) 1 Automatically Clear Events (30-113-1-514) 5000 ms System Ignore the Start Level of the Device when increasing/decreasing brightness Start Level (30-38-1-4) 0 Dimming Duration (30-38-1-5) 15300 ZWave+ Version (30-94-1-0) 1 InstallerIcon (30-94-1-1) 6656 UserIcon (30-94-1-2) 6656 Loaded Config Revision (30-114-1-0) 7 Config File Revision (30-114-1-1) 7 Latest Available Config File Revision (30-114-1-2) 7 Serial Number (30-114-1-4) 00061594 Powerlevel (30-115-1-0) Normal Timeout (30-115-1-1) 0 seconds Test Node (30-115-1-3) 0 Test Powerlevel (30-115-1-4) Normal Frame Count (30-115-1-5) 0 Test Status (30-115-1-8) Failed Acked Frames (30-115-1-9) 0 Library Version (30-134-1-0) 3 Protocol Version (30-134-1-1) 4.38 Application Version (30-134-1-2) 1.05

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or unsubscribe.

rflx18 commented 3 years ago

@robertsLando hehe, i was getting crazy searching for something that does not exist then :)

robertsLando commented 3 years ago

I’m sorry for that, it was a try :(

Atm you could replicate the same cover config and add it to customDevices.js so it will work


Daniel

On 31 Jul 2020, at 20:07, rflx18 notifications@github.com wrote:

 @robertsLando hehe, i was getting crazy searching for something that does not exist then :)

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or unsubscribe.

p4p3r commented 3 years ago

@rflx18 the problem is just one: how can I say that a specific Multilevel Switch value of a device is of a cover and not a light dimmer?

If you find me an answer to this I would be glad to implement the solution and extend that template to all covers

Hi @robertsLando, I'd like to help on this but I'm new on HomeAssistant/OpenZwave/Zwave2Mqtt and I'm still getting up to speed and exploring the code/architecture.

In my case I'm using the Aeotec NanoShutter (https://github.com/OpenZWave/open-zwave/blob/master/config/aeotec/zw141.xml). Is there any way to get the "Specific Device Type" of a device? For the NanoShutter that would be "SPECIFIC_TYPE_CLASS_C_MOTOR_CONTROL (0x07)" which might be a good way to differentiate from a light dimmer.

Regarding the "STOP" command. I don't see the "Switch Multilevel Stop Level Change" command exposed in the zwave2mqtt UI (command class 0x26, command 0x05). That would be the right way to make the shutter stop. Would that be an enhancement on zwave2mqtt side or open-zwave? I'm not very familiar with the code base, would you mind pointing me in the right direction? (btw, we can move this discussion in a different bug or email)

squiddity commented 3 years ago

@rflx18 the problem is just one: how can I say that a specific Multilevel Switch value of a device is of a cover and not a light dimmer? If you find me an answer to this I would be glad to implement the solution and extend that template to all covers

Hi @robertsLando, I'd like to help on this but I'm new on HomeAssistant/OpenZwave/Zwave2Mqtt and I'm still getting up to speed and exploring the code/architecture.

In my case I'm using the Aeotec NanoShutter (https://github.com/OpenZWave/open-zwave/blob/master/config/aeotec/zw141.xml). Is there any way to get the "Specific Device Type" of a device? For the NanoShutter that would be "SPECIFIC_TYPE_CLASS_C_MOTOR_CONTROL (0x07)" which might be a good way to differentiate from a light dimmer.

Regarding the "STOP" command. I don't see the "Switch Multilevel Stop Level Change" command exposed in the zwave2mqtt UI (command class 0x26, command 0x05). That would be the right way to make the shutter stop. Would that be an enhancement on zwave2mqtt side or open-zwave? I'm not very familiar with the code base, would you mind pointing me in the right direction? (btw, we can move this discussion in a different bug or email)

Are you looking for STOP to work in home assistant or a custom application? See my June 8 reply in thread how to issue a "stop level change" via a specific topic through zwave2mqtt, in particular the 38/1/1 topic like "discoveryprefix/nodetopicname/38/1/1/set" with payload "false". My code snippet there goes into the HA config yaml file and shows how you can use a HA "template cover" to make a fully functional open/close/stop cover device in HA even though zwave2mqtt doesn't export one via auto discovery.

p4p3r commented 3 years ago

@squiddity sorry I should have been more precise. Yes I'm trying to make it work with HomeAssistant+Zwave2Mqtt. I tried your code snippet before posting my comment and it didn't work... but now I played with it a bit more and it worked! I cannot use the same exact solution as you did because (and I should file a separate bug) with the Aeotec NanoShutter the "switch" entity doesn't work (the device doesn't respond to the command at all, looking at OpenZWave logs). Using the "dimmer" entity instead does the trick.

Now I'm wondering, could that be at all migrated to a discovery template? I'm looking at https://github.com/OpenZWave/Zwave2Mqtt/blob/master/hass/configurations.js and https://github.com/OpenZWave/Zwave2Mqtt/blob/master/hass/devices.js for examples. I can do something similar to what is done for the Fibaro Shutter (near the bottom of devices.js) and it works just fine using my device id. But your cover template is a bit more complex and I suspect zwave2mqtt just doesn't support defining this kind of custom device.

squiddity commented 3 years ago

The challenge I ran into mentioned above is that using the openzwave/zwave2mqtt topic structure leads to two different command topics for open/close vs stop (i.e. different instance ids in valueId topics). It's not that zwave2mqtt doesn't support this, it does through the topic structure, but that HA autodiscovery doesn't support different command topics for open, close and stop. Specifically per https://www.home-assistant.io/integrations/cover.mqtt/, there's one command_topic, that gets sent payload_close, payload_open, payload_stop etc. So the topic structure with different topics per zwave node instance id doesn't fit well to the mqtt cover entity.

That said I think there's a route forward you could try via zwave2mqtt discovery templates, using the 'setValue' api directly, as zwave2mqtt also allows the full openzwave api to be exposed. Instead of using valueid topics like discoveryprefix/nodetopicname/38/1/1/set, use the API topic described at https://github.com/OpenZWave/Zwave2Mqtt#zwave-apis, roughly like "/_CLIENTS/ZWAVE_GATEWAY-/api/setValue/set" and vary the JSON payload to have the right payload. Then, you'd have just the API topic map to the HA command_topic, and specific API payloads for each action. I played around with this just a bit back in June, here's one example, whereas using valueId topics as above STOP is roughly topic "discoveryprefix/nodeID_19/38/1/1/set" and payload "false", using setValue API topic the same would be roughly topic "discoveryprefix/_CLIENTS/ZWAVE_GATEWAY-zwavename/api/setValue/set" and payload "{ \"args\": [19, 38, 1, 1, false] }""

robertsLando commented 3 years ago

Is there any way to get the "Specific Device Type" of a device? For the NanoShutter that would be "SPECIFIC_TYPE_CLASS_C_MOTOR_CONTROL (0x07)" which might be a good way to differentiate from a light dimmer.

Do all covers have this?

p4p3r commented 3 years ago

Do all covers have this?

I just double-checked in cd-jackson/opensmarthouse database and all the devices that have

In terms of cover though they belongs to different "device classes" (in terms of the hass cover integration), mostly blind, curtain, shutter and window. The "category" field in cd-jackson's seems to categorize most devices in a way that could be used to map to hass cover device classes, even though I see at least a couple of miscategorized devices (window opener listed as window blind). The "description" field seems to capture the right information though.

There are other kinds of "cover" (i.e. garage door openers and motor actuators) which are not GENERIC_TYPE_SWITCH_MULTILEVEL but they seem to be a very small minority (and not very well classified).

robertsLando commented 3 years ago

Could you list me the command classes number of:

SPECIFIC_TYPE_CLASS_A_MOTOR_CONTROL or SPECIFIC_TYPE_CLASS_B_MOTOR_CONTROL or SPECIFIC_TYPE_CLASS_C_MOTOR_CONTROL or SPECIFIC_TYPE_MOTOR_MULTIPOSITION?

I could simply add an if that checks for this cmd classes and if they exists create a cover instead of a dimmer

p4p3r commented 3 years ago

This is the best source of info I found https://github.com/home-assistant/core/blob/dev/homeassistant/components/zwave/const.py#L286

SPECIFIC_TYPE_CLASS_A_MOTOR_CONTROL = 5
SPECIFIC_TYPE_CLASS_B_MOTOR_CONTROL = 6
SPECIFIC_TYPE_CLASS_C_MOTOR_CONTROL = 7
SPECIFIC_TYPE_MOTOR_MULTIPOSITION = 3

These are not command classes but another property of the zwave node. I can try to come up with a PR myself if you want I've been reading through the code of node-openzwave-shared and zwave2mqtt, I just need to figure out a few more details... and how to easily debug on the hassio addon instance of zwave2mqtt i have running here (because that's where my zwave network lives and where I can hope to debug with real devices). Suggestions welcome! :-)

robertsLando commented 3 years ago

@p4p3r

Essentially this function is the one that is called for each value of a device to try to guess the right discovery.

Here It's the specific case where you should put the code to check for the existing command class and try to apply the correct configuration (cover or light dimmer).

There is already some commented code from a try I did some time ago to support covers: https://github.com/OpenZWave/Zwave2Mqtt/blob/master/lib/Gateway.js#L1098-L1102

I place all configurations in hass/configurations.js file, there is already something defined for covers but I let you dig into this.

Command classes are here

If you have any questions feel free to ask :)

p4p3r commented 3 years ago

Sounds good, I forked and setting up my dev environment. I'll ping you if I need anything. I should be able to work on this in the next couple of days. Thanks for you help!

rflx18 commented 3 years ago

Sounds good, I forked and setting up my dev environment. I'll ping you if I need anything. I should be able to work on this in the next couple of days. Thanks for you help!

please do share your findings, im interested :D

robertsLando commented 3 years ago

If you need any help just ask me, I think this is really easy to implement (it's an if check) but I would need some devices to test this

rflx18 commented 3 years ago

i have fibaro cover that are already detected and Philio PAN08-1 that are detected as light dimmers.

p4p3r commented 3 years ago

@rflx18 the changes just merged should fix the discovery for the Philio too. FYI, you will likely still need to additionally do something along the lines of what @squiddity suggested in his comment above (https://github.com/OpenZWave/Zwave2Mqtt/issues/329#issuecomment-640687938) to get the all the controls working.

In my case (Aeotec NanoShutter ZW141) I'm using the following configuration in Homeassistant to get up/stop/down and position controls:

cover:
  platform: template
  covers:
    my_window_shutter:
      device_class: shutter
      friendly_name: 'LivingRoom'
      position_template: "{{ state_attr('cover.my_window_shutter_position', 'current_position') | int }}"
      availability_template: "{% if is_state('cover.my_window_shutter_position', 'unavailable') %} false {% else %} true {% endif %}"
      open_cover:
        # Send up command directly to mqtt
        service: mqtt.publish
        data:
          topic: zwave2mqtt/My_Window_Shutter/38/1/1/set
          payload: "true"
      close_cover:
        # Send down command directly to mqtt
        service: mqtt.publish
        data:
          topic: zwave2mqtt/My_Window_Shutter/38/1/2/set
          payload: "true"
      stop_cover:
        # Same topic as up command but with "false" payload
        service: mqtt.publish
        data:
          topic: zwave2mqtt/My_Window_Shutter/38/1/1/set
          payload: "false"
      set_cover_position:
        service: cover.set_cover_position
        data:
          entity_id: cover.my_window_shutter_position
          position: "{{ position }}"