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

Added ZHA support for Philips929002398602LightController #580

Merged
merged 3 commits into from
Dec 31, 2022

Conversation

cznewt
Copy link
Contributor

@cznewt cznewt commented Sep 27, 2022

No description provided.

@codecov
Copy link

codecov bot commented Sep 27, 2022

Codecov Report

Base: 96% // Head: 96% // Decreases project coverage by -0% ⚠️

Coverage data is based on head (321455a) compared to base (6390b98).
Patch coverage: 60% of modified lines in pull request are covered.

Additional details and impacted files
@@         Coverage Diff         @@
##           main   #580   +/-   ##
===================================
- Coverage    96%    96%   -0%     
===================================
  Files        63     63           
  Lines      2590   2595    +5     
===================================
+ Hits       2486   2489    +3     
- Misses      104    106    +2     
Impacted Files Coverage Δ
apps/controllerx/cx_devices/philips.py 96% <60%> (-4%) ⬇️

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

@cznewt cznewt changed the title Added ZHA support for Philips929002398602LightController WIP: Added ZHA support for Philips929002398602LightController Sep 27, 2022
@xaviml
Copy link
Owner

xaviml commented Sep 27, 2022

Thank you @cznewt for the PR. Let me know once the PR is ready to be reviewed, I see you changed it to "work in progress".

@ScratMan
Copy link

Hi, how to test this PR ? I own two Hue Dimmer V2 (model 9290023986), I copied the added content to the <ha_config_folder>/appdaemon/apps/controllerx/cx_devices/philips.py and created the following app in my docker/appdaemon/conf/apps/apps.yaml

plafonnier_chambre_apolline:
  module: controllerx
  class: Philips929002398602LightController
  controller: 00:17:88:01:09:aa:62:86
  integration: zha
  automatic_steps: 10
  light: light.lampe_bureau_gauche_391098fe_level_light_color_on_off

But it doesn't work. The app appears as terminated in the appdaemon apps dashboard. HA still receives the button events, but nothing happens. When using standard automations the remote works fine, but I'd like to make the long press on brightness button control the light's brightness level smoothly.

@ScratMan
Copy link

ScratMan commented Dec 27, 2022

Nevermind, the issue was due to wrong installation of AppDaemon. After fixing the install I could make it work, but the device class should be changed as the OFF button of the Hue Dimmer V1 became a HUE button on Hue Dimmer V2 which is used in Hue ecosystem to change the scenes between Read, Relax, Concentrate and Energize (looks lime some preset colors). The ON button is now used for ON/OFF.

image

So I changed the class to reflect these changes:

    def get_zha_actions_mapping(self) -> DefaultActionsMapping:
        return {
            "off_long_release": Light.RELEASE,
            "off_hold": Light.HOLD_COLOR_DOWN,
            "off_short_release": Light.CLICK_COLOR_UP,
            "down_long_release": Light.RELEASE,
            "down_hold": Light.HOLD_BRIGHTNESS_DOWN,
            "down_short_release": Light.CLICK_BRIGHTNESS_DOWN,
            "up_long_release": Light.RELEASE,
            "up_hold": Light.HOLD_BRIGHTNESS_UP,
            "up_short_release": Light.CLICK_BRIGHTNESS_UP,
            "on_long_release": Light.RELEASE,
            "on_hold": Light.TOGGLE,
            "on_short_release": Light.TOGGLE,
        }

It's working really well with these changes.
I could personnalize the behavior in my apps adding double and triple press to directly switch on the light with minimum or maximum brightness.

plafonnier_chambre_apolline:
  module: controllerx
  class: Philips929002398602LightController
  controller: 00:17:88:01:09:aa:62:86
  integration: zha
  automatic_steps: 10
  light: light.chambre_apolline_plafonnier
  merge_mapping:
    on_double_press:
      service: light.turn_on
      data:
        brightness_pct: 1
        entity_id: light.chambre_apolline_plafonnier
    on_triple_press:
      service: light.turn_on
      data:
        brightness_pct: 100
        entity_id: light.chambre_apolline_plafonnier

@xaviml
Copy link
Owner

xaviml commented Dec 30, 2022

Hi @ScratMan ,

Thank you for the detailed explanation. I will change @cznewt PR to reflect your changes as well as change the default mapping for the Z2M and deCONZ since it is not correct either.

EDIT: wouldn't it make sense to change "on_hold" to "Light.HOLD_COLOR_UP", instead of "Light.TOGGLE". What do you think?

Regards,
Xavi M.

@ScratMan
Copy link

wouldn't it make sense to change "on_hold" to "Light.HOLD_COLOR_UP", instead of "Light.TOGGLE". What do you think?

I thought about it when changing the file, but IMHO as the hue button is already assigned to color change up and down mapped to click and hold, having a hold color up for the ON button seems useless.

@xaviml
Copy link
Owner

xaviml commented Dec 31, 2022

Hi @ScratMan ,

You are right, the power button when held either can do nothing or turn off all the lights at home according to this review: https://youtu.be/2N8TD81KSAY?t=252. Therefore, I will implement your suggested mapping.

Thanks!

@xaviml xaviml force-pushed the Philips929002398602LightController-ZHA branch from c33c570 to 321455a Compare December 31, 2022 10:54
@xaviml xaviml merged commit 4e90dca into xaviml:main Dec 31, 2022
@xaviml xaviml changed the title WIP: Added ZHA support for Philips929002398602LightController Added ZHA support for Philips929002398602LightController Jan 1, 2023
@xaviml
Copy link
Owner

xaviml commented Jan 1, 2023

Hi @ScratMan ,

This device can be now tested on ControllerX v4.25.0b0.

Regards,
Xavi M.

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.

None yet

3 participants