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

Zwave Cover not working with Garage Door opener #8323

Closed
firstof9 opened this issue Jul 3, 2017 · 15 comments
Closed

Zwave Cover not working with Garage Door opener #8323

firstof9 opened this issue Jul 3, 2017 · 15 comments

Comments

@firstof9
Copy link
Contributor

firstof9 commented Jul 3, 2017

Home Assistant release (hass --version): 0.48.0
Python release (python3 --version): Python 3.4.2
Component/platform: Cover.Zwave
Description of problem: Cover is expecting the zwave garage door cover to be a binary switch, when OpenZwave Lib is providing a list of states.

Expected: List of configurables to populate in zwave control panel and and cover UI card should have some type of display/list of available settings.

From zwcfg.xml file:

                    <CommandClass id="102" name="COMMAND_CLASS_BARRIER_OPERATOR" version="1" issecured="true">
                            <Instance index="1" />
                            <Value type="list" genre="user" instance="1" index="1" label="Barrier State Label" units="" read_only="false" write_only="false" verify_changes="false" poll_intensity="0" min="0" max="0" vindex="0" size="$
                                    <Item label="Closed" value="0" />
                                    <Item label="Closing" value="1" />
                                    <Item label="Stopped" value="2" />
                                    <Item label="Opening" value="3" />
                                    <Item label="Opened" value="4" />
                                    <Item label="Unknown" value="5" />
                            </Value>
                            <Value type="list" genre="config" instance="1" index="2" label="Supported Signals" units="" read_only="true" write_only="false" verify_changes="false" poll_intensity="0" min="0" max="0" vindex="3" size="4$
                                    <Item label="None" value="0" />
                                    <Item label="Audible" value="1" />
                                    <Item label="Visual" value="2" />
                                    <Item label="Both" value="3" />
                            </Value>
                            <Value type="bool" genre="config" instance="1" index="3" label="Audible Notification" units="" read_only="false" write_only="false" verify_changes="false" poll_intensity="0" min="0" max="0" value="False" $
                            <Value type="bool" genre="config" instance="1" index="4" label="Visual Notification" units="" read_only="false" write_only="false" verify_changes="false" poll_intensity="0" min="0" max="0" value="False" />
                    </CommandClass>
@turbokongen
Copy link
Contributor

Devices utilizing the barrier command class are not officially supported by OZW. If you want those devices to work with homeassistant you need to manually patch OZW. Here is info: http://community.home-assistant.io/t/linear-ngdz00-4-garage-door/2136

@firstof9
Copy link
Contributor Author

firstof9 commented Jul 4, 2017

I'm running OZW's dev version.
From OZW_Log.txt in /home/homeassistant/.homeassistant

2017-07-03 10:37:27.035 Always, OpenZwave Version 1.5.2717 Starting Up
2017-07-03 10:39:53.654 Info, Setting Up Provided Network Key for Secure Communications

They've changed it from a binary switch to a list of settings. In homeassistant it always shows the door as open right now and if you hit "close" an error shows in the log:

2017-07-04 10:03:40 ERROR (MainThread) [homeassistant.core] Error doing job: Task exception was never retrieved
Traceback (most recent call last):
  File "/usr/lib/python3.4/asyncio/tasks.py", line 233, in _step
    result = coro.throw(exc)
  File "/srv/homeassistant/homeassistant_venv/lib/python3.4/site-packages/homeassistant/core.py", line 1023, in _event_to_service_call
    yield from service_handler.func(service_call)
  File "/srv/homeassistant/homeassistant_venv/lib/python3.4/site-packages/homeassistant/components/cover/__init__.py", line 163, in async_handle_cover_service
    yield from getattr(cover, method['method'])(**params)
  File "/usr/lib/python3.4/asyncio/futures.py", line 388, in __iter__
    yield self  # This tells Task to wait for completion.
  File "/usr/lib/python3.4/asyncio/tasks.py", line 286, in _wakeup
    value = future.result()
  File "/usr/lib/python3.4/asyncio/futures.py", line 277, in result
    raise self._exception
  File "/usr/lib/python3.4/concurrent/futures/thread.py", line 54, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/srv/homeassistant/homeassistant_venv/lib/python3.4/site-packages/homeassistant/components/cover/zwave.py", line 128, in close_cover
    self.values.primary.data = False
  File "/srv/homeassistant/homeassistant_venv/lib/python3.4/site-packages/openzwave-0.4.0.35-py3.4.egg/openzwave/value.py", line 292, in data
    self._network.manager.setValue(self.value_id, value)
  File "src-lib/libopenzwave/libopenzwave.pyx", line 2875, in libopenzwave.PyManager.setValue (src-lib/libopenzwave/libopenzwave.cpp:22877)
TypeError: Expected str, got bool

@turbokongen
Copy link
Contributor

Can you paste the full data of the node from zwcfg? The error suggests that the binary switcheck is present, but is receiving the wrong type. I think maybe the primary value passed in is wrong.

@firstof9
Copy link
Contributor Author

firstof9 commented Jul 4, 2017

Sure thing here you go:



        <Node id="6" name="Garage_Door" location="Garage" basic="4" generic="64" specific="7" roletype="5" devicetype="3078" nodetype="0" type="Secure Barrier AddOn" listening="true" frequentListening="false" beaming="true" routing="true" max_baud_rate="40000" version="4" secured="true" configrevision="0" query_stage="Complete">
                <Manufacturer id="14f" name="Unknown: id=014f">
                        <Product type="4744" id="3530" name="Unknown: type=4744, id=3530">
                                <MetaData />
                        </Product>
                </Manufacturer>
                <CommandClasses>
                        <CommandClass id="32" name="COMMAND_CLASS_BASIC" version="1">
                                <Instance index="1" />
                                <Value type="byte" genre="basic" instance="1" index="0" label="Basic" units="" read_only="false" write_only="false" verify_changes="false" poll_intensity="0" min="0" max="255" value="0" />
                        </CommandClass>
                        <CommandClass id="34" name="COMMAND_CLASS_APPLICATION_STATUS" version="1" request_flags="4" issecured="true">
                                <Instance index="1" />
                        </CommandClass>
                        <CommandClass id="48" name="COMMAND_CLASS_SENSOR_BINARY" version="1">
                                <Instance index="1" />
                                <Value type="bool" genre="user" instance="1" index="0" label="Sensor" units="" read_only="true" write_only="false" verify_changes="false" poll_intensity="0" min="0" max="0" value="False" />
                        </CommandClass>
                        <CommandClass id="90" name="COMMAND_CLASS_DEVICE_RESET_LOCALLY" version="1" innif="true">
                                <Instance index="1" />
                        </CommandClass>
                        <CommandClass id="94" name="COMMAND_CLASS_ZWAVE_PLUS_INFO" version="1" request_flags="2" innif="true">
                                <Instance index="1" />
                                <Value type="byte" genre="system" instance="1" index="0" label="ZWave+ Version" units="" read_only="true" write_only="false" verify_changes="false" poll_intensity="0" min="0" max="255" value="1" />
                                <Value type="short" genre="system" instance="1" index="1" label="InstallerIcon" units="" read_only="true" write_only="false" verify_changes="false" poll_intensity="0" min="-32768" max="32767" value="3078" />
                                <Value type="short" genre="system" instance="1" index="2" label="UserIcon" units="" read_only="true" write_only="false" verify_changes="false" poll_intensity="0" min="-32768" max="32767" value="3078" />
                        </CommandClass>
                        <CommandClass id="102" name="COMMAND_CLASS_BARRIER_OPERATOR" version="1" issecured="true">
                                <Instance index="1" />
                                <Value type="list" genre="user" instance="1" index="1" label="Barrier State Label" units="" read_only="false" write_only="false" verify_changes="false" poll_intensity="0" min="0" max="0" vindex="0" size="6">
                                        <Item label="Closed" value="0" />
                                        <Item label="Closing" value="1" />
                                        <Item label="Stopped" value="2" />
                                        <Item label="Opening" value="3" />
                                        <Item label="Opened" value="4" />
                                        <Item label="Unknown" value="5" />
                                </Value>
                                <Value type="list" genre="config" instance="1" index="2" label="Supported Signals" units="" read_only="true" write_only="false" verify_changes="false" poll_intensity="0" min="0" max="0" vindex="3" size="4">
                                        <Item label="None" value="0" />
                                        <Item label="Audible" value="1" />
                                        <Item label="Visual" value="2" />
                                        <Item label="Both" value="3" />
                                </Value>
                                <Value type="bool" genre="config" instance="1" index="3" label="Audible Notification" units="" read_only="false" write_only="false" verify_changes="false" poll_intensity="0" min="0" max="0" value="False" />
                                <Value type="bool" genre="config" instance="1" index="4" label="Visual Notification" units="" read_only="false" write_only="false" verify_changes="false" poll_intensity="0" min="0" max="0" value="False" />
                        </CommandClass>
                        <CommandClass id="113" name="COMMAND_CLASS_ALARM" version="4" issecured="true">
                                <Instance index="1" />
                                <Value type="byte" genre="user" instance="1" index="2" label="SourceNodeId" units="" read_only="true" write_only="false" verify_changes="false" poll_intensity="0" min="0" max="255" value="0" />
                                <Value type="list" genre="user" instance="1" index="9" label="Access Control" units="" read_only="false" write_only="false" verify_changes="false" poll_intensity="0" min="0" max="0" vindex="0" size="8">
                                        <Item label="Not Active" value="0" />
                                        <Item label="Access Control - Manual Lock" value="1" />
                                        <Item label="Access Control - Manual Unlock" value="2" />
                                        <Item label="Access Control - RF Lock" value="3" />
                                        <Item label="Access Control - RF Unlock" value="4" />
                                        <Item label="Access Control - KeyPad Lock" value="5" />
                                        <Item label="Access Control - KeyPad Unlock" value="6" />
                                        <Item label="Access Control - Unknown" value="254" />
                                </Value>
                                <Value type="list" genre="user" instance="1" index="10" label="Burglar" units="" read_only="false" write_only="false" verify_changes="false" poll_intensity="0" min="0" max="0" vindex="0" size="8">
                                        <Item label="Not Active" value="0" />
                                        <Item label="Burglar Intrusion" value="1" />
                                        <Item label="Burglar Intrusion" value="2" />
                                        <Item label="Burglar Tamper - Cover Removed" value="3" />
                                        <Item label="Burglar Tamper - Invalid Code" value="4" />
                                        <Item label="Glass Breakage" value="5" />
                                        <Item label="Glass Breakage" value="6" />
                                        <Item label="Burglar - Unknown" value="254" />
                                </Value>
                        </CommandClass>
                        <CommandClass id="114" name="COMMAND_CLASS_MANUFACTURER_SPECIFIC" version="1" innif="true">
                                <Instance index="1" />
                                <Value type="int" genre="system" instance="1" index="0" label="Loaded Config Revision" units="" read_only="true" write_only="false" verify_changes="false" poll_intensity="0" min="-2147483648" max="2147483647" value="0" />
                                <Value type="int" genre="system" instance="1" index="1" label="Config File Revision" units="" read_only="true" write_only="false" verify_changes="false" poll_intensity="0" min="-2147483648" max="2147483647" value="0" />
                                <Value type="int" genre="system" instance="1" index="2" label="Latest Available Config File Revision" units="" read_only="true" write_only="false" verify_changes="false" poll_intensity="0" min="-2147483648" max="2147483647" value="0" />
                                <Value type="string" genre="system" instance="1" index="3" label="Device ID" units="" read_only="true" write_only="false" verify_changes="false" poll_intensity="0" min="0" max="0" value="" />
                                <Value type="string" genre="system" instance="1" index="4" label="Serial Number" units="" read_only="true" write_only="false" verify_changes="false" poll_intensity="0" min="0" max="0" value="" />
                        </CommandClass>
                        <CommandClass id="115" name="COMMAND_CLASS_POWERLEVEL" version="1" innif="true">
                                <Instance index="1" />
                                <Value type="list" genre="system" instance="1" index="0" label="Powerlevel" units="dB" read_only="false" write_only="false" verify_changes="false" poll_intensity="0" min="0" max="0" vindex="0" size="1">
                                        <Item label="Normal" value="0" />
                                        <Item label="-1dB" value="1" />
                                        <Item label="-2dB" value="2" />
                                        <Item label="-3dB" value="3" />
                                        <Item label="-4dB" value="4" />
                                        <Item label="-5dB" value="5" />
                                        <Item label="-6dB" value="6" />
                                        <Item label="-7dB" value="7" />
                                        <Item label="-8dB" value="8" />
                                        <Item label="-9dB" value="9" />
                                </Value>
                                <Value type="byte" genre="system" instance="1" index="1" label="Timeout" units="seconds" read_only="false" write_only="false" verify_changes="false" poll_intensity="0" min="0" max="255" value="0" />
                                <Value type="button" genre="system" instance="1" index="2" label="Set Powerlevel" units="" read_only="false" write_only="true" verify_changes="false" poll_intensity="0" min="0" max="0" />
                                <Value type="byte" genre="system" instance="1" index="3" label="Test Node" units="" read_only="false" write_only="false" verify_changes="false" poll_intensity="0" min="0" max="255" value="0" />
                                <Value type="list" genre="system" instance="1" index="4" label="Test Powerlevel" units="dB" read_only="false" write_only="false" verify_changes="false" poll_intensity="0" min="0" max="0" vindex="0" size="1">
                                        <Item label="Normal" value="0" />
                                        <Item label="-1dB" value="1" />
                                        <Item label="-2dB" value="2" />
                                        <Item label="-3dB" value="3" />
                                        <Item label="-4dB" value="4" />
                                        <Item label="-5dB" value="5" />
                                        <Item label="-6dB" value="6" />
                                        <Item label="-7dB" value="7" />
                                        <Item label="-8dB" value="8" />
                                        <Item label="-9dB" value="9" />
                                </Value>
                                <Value type="short" genre="system" instance="1" index="5" label="Frame Count" units="" read_only="false" write_only="false" verify_changes="false" poll_intensity="0" min="-32768" max="32767" value="0" />
                                <Value type="button" genre="system" instance="1" index="6" label="Test" units="" read_only="false" write_only="true" verify_changes="false" poll_intensity="0" min="0" max="0" />
                                <Value type="button" genre="system" instance="1" index="7" label="Report" units="" read_only="false" write_only="true" verify_changes="false" poll_intensity="0" min="0" max="0" />
                                <Value type="list" genre="system" instance="1" index="8" label="Test Status" units="" read_only="true" write_only="false" verify_changes="false" poll_intensity="0" min="0" max="0" vindex="0" size="1">
                                        <Item label="Failed" value="0" />
                                        <Item label="Success" value="1" />
                                        <Item label="In Progress" value="2" />
                                </Value>
                                <Value type="short" genre="system" instance="1" index="9" label="Acked Frames" units="" read_only="true" write_only="false" verify_changes="false" poll_intensity="0" min="-32768" max="32767" value="0" />
                        </CommandClass>
                        <CommandClass id="133" name="COMMAND_CLASS_ASSOCIATION" version="1" issecured="true">
                                <Instance index="1" />
                                <Associations num_groups="1">
                                        <Group index="1" max_associations="1" label="Group 1" auto="true">
                                                <Node id="1" />
                                        </Group>
                                </Associations>
                        </CommandClass>
                        <CommandClass id="134" name="COMMAND_CLASS_VERSION" version="1" issecured="true">
                                <Instance index="1" />
                                <Value type="string" genre="system" instance="1" index="0" label="Library Version" units="" read_only="true" write_only="false" verify_changes="false" poll_intensity="0" min="0" max="0" value="3" />
                                <Value type="string" genre="system" instance="1" index="1" label="Protocol Version" units="" read_only="true" write_only="false" verify_changes="false" poll_intensity="0" min="0" max="0" value="4.05" />
                                <Value type="string" genre="system" instance="1" index="2" label="Application Version" units="" read_only="true" write_only="false" verify_changes="false" poll_intensity="0" min="0" max="0" value="2.01" />
                        </CommandClass>
                        <CommandClass id="152" name="COMMAND_CLASS_SECURITY" version="1" innif="true">
                                <Instance index="1" />
                                <Value type="bool" genre="system" instance="1" index="0" label="Secured" units="" read_only="true" write_only="false" verify_changes="false" poll_intensity="0" min="0" max="0" value="True" />
                        </CommandClass>
                </CommandClasses>
        </Node>

@turbokongen
Copy link
Contributor

This was implemented last year, given that it is based on OZW dev branch it can change again. At that time the barrier devices had binary switch that controlled the operation. How does the barrier devices get controlled now? Is this device the gd00z-4 ? PR is welcome.😊 My educated guess is that in the cover/zwave.py file we need to identify that the device is a barrier command class and set the value labels for opening/opened to open the garage door. Set closing/closed valur label for closing the garage door. But again just guessing since I do not own such a device.

@firstof9
Copy link
Contributor Author

firstof9 commented Jul 5, 2017

When controlling via OZWCP you set it the label to "opened" to open and "closed" to close it. The labels then update their status to indicate that the door is in motion via "opening" and "closing". Yes this is one of the GD00Z-4 devices. I havn't advanced my python skills enough to work on a PR yet. :(

@firstof9
Copy link
Contributor Author

firstof9 commented Jul 5, 2017

From what I can tell the vindex in this line:
<Value type="list" genre="user" instance="1" index="1" label="Barrier State Label" units="" read_only="false" write_only="false" verify_changes="false" poll_intensity="0" min="0" max="0" vindex="0" size="6">

corresponds to
<Item label="Closed" value="0" />

is how to determine the state of the door now. Unfortunately I do not know how to modify the code to do this.

@firstof9
Copy link
Contributor Author

firstof9 commented Jul 6, 2017

I was able to get this working mostly with a modification to the zwave.py:

    @property
    def is_closed(self):
        """Return the current position of Zwave garage door."""
        return self._state

    def close_cover(self):
        """Close the garage door."""
        self.values.primary.data = "Closed"

    def open_cover(self):
        """Open the garage door."""
        self.values.primary.data = "Opened"

However the entity_id does not update in home assistant.
I added a _LOGGER to the update_properties function and the data is returning as expected "Opening" "Opened" "Closing" "Closed".

@turbokongen
Copy link
Contributor

turbokongen commented Jul 6, 2017

The state is defined by the is_closed method. So you need to define inside that method. It is only true or false.If you want all the states, you should add that to device_state_attributes method. It will then appear as an attribute for the entity. Look at climate/zwave.py

@firstof9
Copy link
Contributor Author

firstof9 commented Jul 6, 2017

Thank you for the pointer, I think I have a quick dirty fix in place that I'll test when I get home. Then I'll look into a more elegant update using the climate component as a guide.

@hawk259
Copy link
Contributor

hawk259 commented Jul 18, 2017

@firstof9 is this the only change you needed to get the dev branch of ozw working?

https://raw.githubusercontent.com/firstof9/home-assistant/dev/homeassistant/components/cover/zwave.py

I can build a docker image with the ozw dev branch, all the switch and garage door opener show up in the ozwcache_0xf4f3c6ae.xml (dev renamed it), but only my switches show up in HA.

I see the zwave. entity for the opener, but not a cover. entity. I do see a few sensor. entities for the opener.

@firstof9
Copy link
Contributor Author

firstof9 commented Jul 19, 2017

@hawk259 I made changes to __init__.py as well, I'll link them.

https://raw.githubusercontent.com/firstof9/home-assistant/proper-patch/homeassistant/components/cover/zwave.py

https://raw.githubusercontent.com/firstof9/home-assistant/proper-patch/homeassistant/components/cover/__init__.py

Kinda a placeholder till I can get the states to change with the list as well, still working on that bit, but it does register "open" and "closed" in HA.

@hawk259
Copy link
Contributor

hawk259 commented Jul 19, 2017

I got everything working with those files.

One thing I noticed was the dev branch of OZW couldn't find the manufacturer:

% grep Manufacturer *.xml | grep 14f
ozwcache_0xf4f3c6ae.xml:		<Manufacturer id="14f" name="Unknown: id=014f">
zwcfg_0xf4f3c6ae.xml:		<Manufacturer id="14f" name="Linear">

so I had to change all the identities in the all the .yaml files. What is weird is both the master and dev branch have the same entry for linear stuff in manufacturer_specific.xml.

What else needs to be done for the HA patches?

I have a template senors using states.cover.ID.attributes.door_state and it shows opened, opening, closing and closed as they move through.

@firstof9
Copy link
Contributor Author

I'm working on having that door_state translate as the main state, but that may break the UI in some fashion, do you think it's working well enough to submit a PR for?

@emlove
Copy link
Contributor

emlove commented Jul 27, 2017

Fixed by #8574

@emlove emlove closed this as completed Jul 27, 2017
@home-assistant home-assistant locked and limited conversation to collaborators Dec 11, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants