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

Add support for different Paulmann manufacturer name #2695

Merged
merged 1 commit into from Nov 1, 2023

Conversation

MattFromGer
Copy link
Contributor

Proposed change

Add support for slightly different Paulmann manufacturer name. Some switches have Paulmann LichtGmbH, newer models have Paulmann Licht GmbH as manufacturer name.

Additional information

Fixes #2662

Checklist

  • The changes are tested and work correctly
  • pre-commit checks pass / the code has been formatted using Black
  • Tests have been added to verify that the new code works

Copy link

codecov bot commented Nov 1, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (d1a1b59) 86.90% compared to head (7849f9a) 86.90%.

Additional details and impacted files
@@           Coverage Diff           @@
##              dev    #2695   +/-   ##
=======================================
  Coverage   86.90%   86.90%           
=======================================
  Files         282      282           
  Lines        8637     8638    +1     
=======================================
+ Hits         7506     7507    +1     
  Misses       1131     1131           
Files Coverage Δ
zhaquirks/paulmann/__init__.py 100.00% <100.00%> (ø)
zhaquirks/paulmann/fourbtnremote.py 100.00% <100.00%> (ø)

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Collaborator

@TheJulianJES TheJulianJES left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Thanks!

@TheJulianJES TheJulianJES changed the title Add support for slightly different Paulmann manufacturer name Add support for different Paulmann manufacturer name Nov 1, 2023
@TheJulianJES TheJulianJES merged commit 8382404 into zigpy:dev Nov 1, 2023
14 checks passed
@drueppela
Copy link

@MattFromGer & @TheJulianJES & @javicalle:

If I did no mistake 8382404 does NOT solve #2662

WORKING FIX: #2662 (comment)

/config/zha_custom_quirks/paulmann/init.py

"""Paulmann module."""
PAULMANN = "Paulmann LichtGmbH"

/config/zha_custom_quirks/paulmann/fourbtnremote.py

"""Device handler for Paulmann 4-button remote control."""
from zigpy.profiles import zha
from zigpy.quirks import CustomDevice
from zigpy.zcl.clusters.general import (
    Basic,
    Groups,
    Identify,
    LevelControl,
    OnOff,
    Ota,
    PowerConfiguration,
    Scenes,
)
from zigpy.zcl.clusters.homeautomation import Diagnostic
from zigpy.zcl.clusters.lighting import Color
from zigpy.zcl.clusters.lightlink import LightLink

from zhaquirks.const import (
    BUTTON_1,
    BUTTON_2,
    BUTTON_3,
    BUTTON_4,
    CLUSTER_ID,
    COMMAND,
    COMMAND_MOVE_ON_OFF,
    COMMAND_OFF,
    COMMAND_ON,
    COMMAND_STOP_ON_OFF,
    DEVICE_TYPE,
    ENDPOINT_ID,
    ENDPOINTS,
    INPUT_CLUSTERS,
    LONG_PRESS,
    LONG_RELEASE,
    MODELS_INFO,
    OUTPUT_CLUSTERS,
    PARAMS,
    PROFILE_ID,
    SHORT_PRESS,
)
from zhaquirks.paulmann import PAULMANN


class PaulmannRemote4Btn(CustomDevice):
    """Custom device representing Paulmann 4-button 501.34 remote control."""

    signature = {
        # <SimpleDescriptor endpoint=1 profile=260 device_type=1
        # device_version=0
        # input_clusters=[0, 1, 3, 2821, 4096]
        # output_clusters=[3, 4, 5, 6, 8, 25, 768, 4096]>
        MODELS_INFO: [
            (PAULMANN, "501.34"),
            ("Paulmann Licht GmbH", "501.34"),
        ],
        ENDPOINTS: {
            1: {
                PROFILE_ID: zha.PROFILE_ID,
                DEVICE_TYPE: zha.DeviceType.LEVEL_CONTROL_SWITCH,
                INPUT_CLUSTERS: [
                    Basic.cluster_id,
                    Diagnostic.cluster_id,
                    Identify.cluster_id,
                    LightLink.cluster_id,
                    PowerConfiguration.cluster_id,
                ],
                OUTPUT_CLUSTERS: [
                    Color.cluster_id,
                    Groups.cluster_id,
                    Identify.cluster_id,
                    LevelControl.cluster_id,
                    LightLink.cluster_id,
                    OnOff.cluster_id,
                    Ota.cluster_id,
                    Scenes.cluster_id,
                ],
            },
            2: {
                PROFILE_ID: zha.PROFILE_ID,
                DEVICE_TYPE: zha.DeviceType.LEVEL_CONTROL_SWITCH,
                INPUT_CLUSTERS: [
                    Basic.cluster_id,
                    Diagnostic.cluster_id,
                    Identify.cluster_id,
                    LightLink.cluster_id,
                    PowerConfiguration.cluster_id,
                ],
                OUTPUT_CLUSTERS: [
                    Color.cluster_id,
                    Groups.cluster_id,
                    Identify.cluster_id,
                    LevelControl.cluster_id,
                    LightLink.cluster_id,
                    OnOff.cluster_id,
                    Ota.cluster_id,
                    Scenes.cluster_id,
                ],
            },
        },
    }

    replacement = {
        ENDPOINTS: {
            1: {
                INPUT_CLUSTERS: [
                    Basic.cluster_id,
                    Diagnostic.cluster_id,
                    Identify.cluster_id,
                    LightLink.cluster_id,
                    PowerConfiguration.cluster_id,
                ],
                OUTPUT_CLUSTERS: [
                    Color.cluster_id,
                    Groups.cluster_id,
                    Identify.cluster_id,
                    LevelControl.cluster_id,
                    LightLink.cluster_id,
                    OnOff.cluster_id,
                    Ota.cluster_id,
                    Scenes.cluster_id,
                ],
            },
            2: {
                INPUT_CLUSTERS: [
                    Basic.cluster_id,
                    Diagnostic.cluster_id,
                    Identify.cluster_id,
                    LightLink.cluster_id,
                    PowerConfiguration.cluster_id,
                ],
                OUTPUT_CLUSTERS: [
                    Color.cluster_id,
                    Groups.cluster_id,
                    Identify.cluster_id,
                    LevelControl.cluster_id,
                    LightLink.cluster_id,
                    OnOff.cluster_id,
                    Ota.cluster_id,
                    Scenes.cluster_id,
                ],
            },
        }
    }

    device_automation_triggers = {
        (SHORT_PRESS, BUTTON_1): {COMMAND: COMMAND_ON, CLUSTER_ID: 6, ENDPOINT_ID: 1},
        (LONG_PRESS, BUTTON_1): {
            COMMAND: COMMAND_MOVE_ON_OFF,
            CLUSTER_ID: 8,
            ENDPOINT_ID: 1,
            PARAMS: {"move_mode": 0, "rate": 50},
        },
        (LONG_RELEASE, BUTTON_1): {
            COMMAND: COMMAND_STOP_ON_OFF,
            CLUSTER_ID: 8,
            ENDPOINT_ID: 1,
        },
        (SHORT_PRESS, BUTTON_2): {COMMAND: COMMAND_OFF, CLUSTER_ID: 6, ENDPOINT_ID: 1},
        (LONG_PRESS, BUTTON_2): {
            COMMAND: COMMAND_MOVE_ON_OFF,
            CLUSTER_ID: 8,
            ENDPOINT_ID: 1,
            PARAMS: {"move_mode": 1, "rate": 50},
        },
        (LONG_RELEASE, BUTTON_2): {
            COMMAND: COMMAND_STOP_ON_OFF,
            CLUSTER_ID: 8,
            ENDPOINT_ID: 1,
        },
        (SHORT_PRESS, BUTTON_3): {
            COMMAND: COMMAND_ON,
            CLUSTER_ID: 6,
            ENDPOINT_ID: 2,
        },
        (LONG_PRESS, BUTTON_3): {
            COMMAND: COMMAND_MOVE_ON_OFF,
            CLUSTER_ID: 8,
            ENDPOINT_ID: 2,
            PARAMS: {"move_mode": 0, "rate": 50},
        },
        (LONG_RELEASE, BUTTON_3): {
            COMMAND: COMMAND_STOP_ON_OFF,
            CLUSTER_ID: 8,
            ENDPOINT_ID: 2,
        },
        (SHORT_PRESS, BUTTON_4): {
            COMMAND: COMMAND_OFF,
            CLUSTER_ID: 6,
            ENDPOINT_ID: 2,
        },
        (LONG_PRESS, BUTTON_4): {
            COMMAND: COMMAND_MOVE_ON_OFF,
            CLUSTER_ID: 8,
            ENDPOINT_ID: 2,
            PARAMS: {"move_mode": 1, "rate": 50},
        },
        (LONG_RELEASE, BUTTON_4): {
            COMMAND: COMMAND_STOP_ON_OFF,
            CLUSTER_ID: 8,
            ENDPOINT_ID: 2,
        },
    }

@MattFromGer
Copy link
Contributor Author

If I did no mistake 8382404 does NOT solve #2662

I guess you did a mistake ;-)

@TheJulianJES
Copy link
Collaborator

@drueppela The fix isn't in HA yet. It'll likely only be in 2023.12.x
If you want to test it as a custom quirk, you'll also have to modify the imports (and copy the main file or just remove the important for the alternative manufacturer name and put it in the quirk manually).

elupus pushed a commit to elupus/zha-device-handlers that referenced this pull request Jan 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[BUG] Paulmann 501.34 Wall Switch (sw_build_id (id: 0x4000) 2.7.6_r25) cannot be used in HASSIO automations
3 participants