zigpy / zha-device-handlers

ZHA device handlers bridge the functionality gap created when manufacturers deviate from the ZCL specification, handling deviations and exceptions by parsing custom messages to and from Zigbee devices.
Apache License 2.0
750 stars 686 forks source link

Add Profalux support (Covers) #348

Closed Warioly closed 3 years ago

Warioly commented 4 years ago

Hello

In HA, Profalux covers appear as a switch and not as a cover. I use Pi-Zigate, documentation and compatibility are describe here (but in french):

How can I change type of this entity or anything else to manage level of covers ?

Some informations are missing :

Basic (Endpoint id: 1, Id: 0x0000, Type: in)
    Attributes :
        manufacturer (id: 0x0004) : None
        model (id: 0x0005) : None
        stack_version (id: 0x0002) : None
        zcl_version (id: 0x0000) : 1
ManufacturerSpecificCluster (Endpoint id: 1, Id: 0xfc20, Type: in)
    No attribute
    No commands
ManufacturerSpecificCluster (Endpoint id: 1, Id: 0xfc21, Type: in)
    No attribute
    No commands
ManufacturerSpecificCluster (Endpoint id: 1, Id: 0xfc20, Type: out)
    No attribute
    No commands

But LevelControl and other commands to manage cover are presents :

LevelControl (Endpoint id: 1, Id: 0x0008, Type: in)
    Attributes :
        current_level (id: 0x0000)
        default_move_rate (id: 0x0014)
        off_transition_time (id: 0x0013)
        on_level (id: 0x0011)
        on_off_transition_time (id: 0x0010)
        on_transition_time (id: 0x0012)
        remaining_time (id: 0x0001)
    Commands :
        move (id: 0x0001)
        move_to_level (id: 0x0000)
        move_to_level_with_on_off (id: 0x0004)
        move_with_on_off (id: 0x0005)
        step (id: 0x0002)
        step_with_on_off (id: 0x0006)
        stop (id: 0x0003)
        stop (id: 0x0007)

Device signature

Cover

# <SimpleDescriptor
#     endpoint=1 profile=260 device_type=512 device_version=0
#     input_clusters=[0, 3, 4, 5, 6, 8, 10, 21, 256, 64544, 64545]
#     output_clusters=[3, 64544]
# >

Remote

# <SimpleDescriptor
#     endpoint=1 profile=260 device_type=513 device_version=0
#     input_clusters=[0, 3, 21]
#     output_clusters=[3, 4, 5, 6, 8, 256, 64544, 64545]
# >

Additional context I tried to add my own quircks but devices are always see as Switch and not Cover after delete and new add/join but new properties of quircks are acquires and display in properties of device.

Cover

"""Profalux device"""
from zigpy.profiles import zha
from zigpy.quirks import CustomDevice
from zigpy.zcl.clusters.general import (
    Basic,
    Groups,
    Identify,
    LevelControl,
    OnOff,
    Scenes,
    Time,
    Commissioning,
)

from zigpy.zcl.clusters.closures import Shade

from zhaquirks.const import (
    DEVICE_TYPE,
    ENDPOINTS,
    INPUT_CLUSTERS,
    OUTPUT_CLUSTERS,
    PROFILE_ID,
    SHORT_PRESS,
    DOUBLE_PRESS,
    TURN_ON,
    TURN_OFF,
    COMMAND,
    COMMAND_ON,
    COMMAND_OFF,
    COMMAND_STOP,
    COMMAND_TOGGLE,
    CLUSTER_ID,
    ENDPOINT_ID,
)

from . import (
    DEVICE_VERSION,
    DEVICE_MANUFACTURER,
    DEVICE_MODEL,
    MANUFACTURER_SPECIFIC_CLUSTER_ID_1,
    MANUFACTURER_SPECIFIC_CLUSTER_ID_2,
    PROFALUX_MANUFACTURER,
    PROFALUX_MODEL_COVER,
)

class ProfaluxCover(CustomDevice):
    """Profalux covers"""

    signature = {
        # <SimpleDescriptor
        #     endpoint=1 profile=260 device_type=512 device_version=0
        #     input_clusters=[0, 3, 4, 5, 6, 8, 10, 21, 256, 64544, 64545]
        #     output_clusters=[3, 64544]
        # >
        ENDPOINTS: {
            1: {
                PROFILE_ID: zha.PROFILE_ID, # profile = 260 - 0x104
                DEVICE_TYPE: zha.DeviceType.SHADE, # device_type = 512 - 0x200
                DEVICE_VERSION: 0x00, # device_version = 0
                INPUT_CLUSTERS: [
                    Basic.cluster_id, # 0
                    Identify.cluster_id, # 3
                    Groups.cluster_id, # 4
                    Scenes.cluster_id, # 5
                    OnOff.cluster_id, # 6
                    LevelControl.cluster_id, # 8
                    Time.cluster_id, # 10
                    Commissioning.cluster_id, # 21
                    Shade.cluster_id, # 256
                    MANUFACTURER_SPECIFIC_CLUSTER_ID_1, # 64544
                    MANUFACTURER_SPECIFIC_CLUSTER_ID_2, # 64545
                ],
                OUTPUT_CLUSTERS: [
                    Identify.cluster_id,
                    MANUFACTURER_SPECIFIC_CLUSTER_ID_1, # 64544
                ],
            },
        }
    }

    replacement = {
        DEVICE_MANUFACTURER: PROFALUX_MANUFACTURER,
        DEVICE_MODEL: PROFALUX_MODEL_COVER,
        ENDPOINTS: {
            1: {
                PROFILE_ID: zha.PROFILE_ID, # profile = 260 - 0x104
                DEVICE_TYPE: zha.DeviceType.SHADE, # device_type = 512 - 0x200
                DEVICE_VERSION: 0x00, # device_version = 0
                INPUT_CLUSTERS: [
                    Basic.cluster_id, # 0
                    Identify.cluster_id, # 3
                    Groups.cluster_id, # 4
                    Scenes.cluster_id, # 5
                    OnOff.cluster_id, # 6
                    LevelControl.cluster_id, # 8
                    Time.cluster_id, # 10
                    Commissioning.cluster_id, # 21
                    Shade.cluster_id, # 256
                    #MANUFACTURER_SPECIFIC_CLUSTER_ID_1,
                    #MANUFACTURER_SPECIFIC_CLUSTER_ID_2,
                ],
                OUTPUT_CLUSTERS: [
                    Identify.cluster_id,
                    #MANUFACTURER_SPECIFIC_CLUSTER_ID_1,
                ],
            },
        }
    }

Remote

"""Profalux device"""
from zigpy.profiles.zha import DeviceType
from zigpy.quirks import CustomDevice
from zigpy.zcl.clusters.general import (
    Basic,
    Groups,
    Identify,
    LevelControl,
    OnOff,
    Scenes,
    Time,
    Commissioning,
)

from zigpy.zcl.clusters.closures import Shade

from zhaquirks.const import (
    DEVICE_TYPE,
    ENDPOINTS,
    INPUT_CLUSTERS,
    OUTPUT_CLUSTERS,
    PROFILE_ID,
)

from . import (
    DEVICE_VERSION,
    DEVICE_MANUFACTURER,
    DEVICE_MODEL,
    MANUFACTURER_SPECIFIC_CLUSTER_ID_1,
    MANUFACTURER_SPECIFIC_CLUSTER_ID_2,
    PROFALUX_MANUFACTURER,
    PROFALUX_MODEL_REMOTE,
)

class ProfaluxRemote(CustomDevice):
    """Profalux covers"""

    signature = {
        # <SimpleDescriptor
        #     endpoint=1 profile=260 device_type=513 device_version=0
        #     input_clusters=[0, 3, 21]
        #     output_clusters=[3, 4, 5, 6, 8, 256, 64544, 64545]
        # >
        ENDPOINTS: {
            1: {
                PROFILE_ID: 0x0104, # profile = 260 - 0x104
                DEVICE_TYPE: DeviceType.SHADE_CONTROLLER, # device_type = 513 - 0x201
                DEVICE_VERSION: 0x00, # device_version = 0
                INPUT_CLUSTERS: [
                    Basic.cluster_id, # 0
                    Identify.cluster_id, # 3
                    Commissioning.cluster_id, # 21
                ],
                OUTPUT_CLUSTERS: [
                    Identify.cluster_id, # 3
                    Groups.cluster_id, # 4
                    Scenes.cluster_id, # 5
                    OnOff.cluster_id, # 6
                    LevelControl.cluster_id, # 8
                    Shade.cluster_id, # 256
                    MANUFACTURER_SPECIFIC_CLUSTER_ID_1, # 64544
                    MANUFACTURER_SPECIFIC_CLUSTER_ID_2, # 64545
                ],
            },
        }
    }

    replacement = {
        DEVICE_MANUFACTURER: PROFALUX_MANUFACTURER,
        DEVICE_MODEL: PROFALUX_MODEL_REMOTE,
        ENDPOINTS: {
            1: {
                PROFILE_ID: 0x0104, # profile = 260 - 0x104
                DEVICE_TYPE: DeviceType.SHADE_CONTROLLER, # device_type = 512 - 0x200 
                DEVICE_VERSION: 0x00, # device_version = 0
                INPUT_CLUSTERS: [
                    Basic.cluster_id, # 0
                    Identify.cluster_id, # 3
                    Commissioning.cluster_id, # 21
                ],
                OUTPUT_CLUSTERS: [
                    Identify.cluster_id, # 3
                    Groups.cluster_id, # 4
                    Scenes.cluster_id, # 5
                    OnOff.cluster_id, # 6
                    LevelControl.cluster_id, # 8
                    Shade.cluster_id, # 256
                    MANUFACTURER_SPECIFIC_CLUSTER_ID_1, # 64544
                    MANUFACTURER_SPECIFIC_CLUSTER_ID_2, # 64545
                ],
            },
        }
    }

Const

"""Module for Profalux quirks implementations."""
# TODO : Add in zhaquirks.const
DEVICE_VERSION = "device_version"
DEVICE_MANUFACTURER = "manufacturer"
DEVICE_MODEL = "model"

MANUFACTURER_SPECIFIC_CLUSTER_ID_1 = 0xFC20  # decimal = 64544
MANUFACTURER_SPECIFIC_CLUSTER_ID_2 = 0xFC21  # decimal = 64545
PROFALUX_MANUFACTURER = "PROFALUX"
PROFALUX_MODEL_COVER = "Cover / Volet roulant"
PROFALUX_MODEL_REMOTE = "Remote / Télécommande"
europrimus commented 4 years ago

Hello, I have profalux cover and there register as switch (off = closed, on = opened). I want to try your quirk, but i don't find where to put the files. With ssh , i can't find any zhaquirks directory. Could you help me to test?

I'm running home assistant on a raspberyPi 3 with zigate usb/ttl

arch | armv7l
dev | false
docker | true
hassio | true
host_os | HassOS 3.13
installation_type | Home Assistant
os_name | Linux
os_version | 4.19.114-v7
python_version | 3.7.7
supervisor | 226
version | 0.110.4
virtualenv | false
tube0013 commented 4 years ago

try HA beta shortly, this may be fixed there see the release notes re zha covers - https://rc.home-assistant.io/blog/2020/06/01/release-111/

On Wed, Jun 3, 2020 at 4:24 PM Didier C notifications@github.com wrote:

Hello, I have profalux cover and there register as switch (off = closed, on = opened). I want to try your quirk, but i don't find where to put the files. With ssh , i can't find any zhaquirks directory. Could you help me to test?

I'm running home assistant on a raspberyPi 3 with zigate usb/ttl

arch | armv7l dev | false docker | true hassio | true host_os | HassOS 3.13 installation_type | Home Assistant os_name | Linux os_version | 4.19.114-v7 python_version | 3.7.7 supervisor | 226 version | 0.110.4 virtualenv | false

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/zigpy/zha-device-handlers/issues/348#issuecomment-638441849, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACUSE7G5EABOCRBZDWSZ3MLRU2WPVANCNFSM4MYHSL6Q .

Warioly commented 4 years ago

Hi

Try bêta is better, my quircks doesn't work =( For the moment, I use many automation with HA called by button. Each automation call ZHA service zha.issue_zigbee_cluster_command in action menu. For close cover, you can try this data :

cluster_id: 6
cluster_type: in
command: 0
command_type: server
endpoint_id: 1
ieee: '20:91:8a:00:00:xx:xx:xx'

In zigbee panel settings, you can explore all cluster and command from your Zigbee device.

I think use Automation in HA is most powerfull. You can do everything with your home before any developper start himself idea.

If you want, I can help you with this tomorrow or this week-end in French. I will upgrade HA for use new ZHA cover on next release because my Home is not a lab ! =)

europrimus commented 4 years ago

Thanks for this information. I'll wait for the new release too.

europrimus commented 4 years ago

Now my profalux covers works. But they still shown as cover.unk_manufacturer_unk_model_56d60a00_level_on_off_shade Is the manufacturer and model are ID (like for USB) ? so there is a file for converting to human readable name?

Warioly commented 4 years ago

You can add my code in ZHA Quirck directory for add name, manufacturer and other informations.

glamirand commented 4 years ago

Hi! Glad to find this post, I'm actually having troubles trying to control my Profalux covers with a Zigate by HA. I managed to pair a first cover with the Zigate and control it using "ZigBee Gateway UI" provided as a test SW for the Zigate. My cover appears in HA as "unk_manufacturer unk_model", I have a lovelace card with up/down/stop buttons. I see things happening when I click these buttons as the USB adapter activity led shows up but with no effect on the shutter. Can anyone help me with ZHA quirks for those Profalux shutters as I think this is the best way to solve my problem? PS : I can speak french ;) Thanks!

pipiche38 commented 4 years ago

For more insight https://github.com/pipiche38/Domoticz-Zigate-Wiki/blob/master/en-eng/Profalux-corner.md

Warioly commented 4 years ago

Hi @glamirand

When you try to get attribut LevelControl of Profalux in Cluster Management, what's do you obtain ? Zigate-Cluster-LevelControl

You can try to set Toggle in command's Cluster (UP to DOWN or DOWN to UP) Zigate-Cluster-Toggle

If you doesn't get any activity on Zigbee log, the integration doesn't work and probably you need to add the WA join on top of thread.

pipiche38 commented 4 years ago

As mentioned in the wiki page I have put above, I do suggest to not provide a mapping to the OnOff as recommended by Profalux themselves

Warioly commented 4 years ago

Integration of Cover in HA doesn't work with LevelControl for use Up/Stop/Down. Without LevelControl, you can only use Slider for select the level of Cover. So in Lovelace you can'nt select action without extend Automation.

LevelControl

Edit : May be we need purpose evolution of Cover integration before remove OnOff Cluster in this Quirck

github-actions[bot] commented 3 years ago

There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates. Please make sure to update to the latest version and check if that solves the issue. Let us know if that works for you by adding a comment 👍 This issue has now been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.