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

[BUG] Smooth Power On causing issues #24

Closed
jrbenito opened this issue Feb 7, 2020 · 24 comments
Closed

[BUG] Smooth Power On causing issues #24

jrbenito opened this issue Feb 7, 2020 · 24 comments
Assignees
Labels
bug Something isn't working

Comments

@jrbenito
Copy link

jrbenito commented Feb 7, 2020

Tried to activate smooth_power_on feature but it seems not working (after press and hold dim up button I expect the lights to turn on). Lights do nothing and logs below appear.

Other functions are working.

AppDaemon: 4
hass-core: 0.105.2
Device: Ikea Control E1810 and E1743
Integration: zha
Logs (if applicable):

2020-02-07 22:34:54.185691 WARNING hall_controller: ------------------------------------------------------------
2020-02-07 22:34:54.187746 WARNING hall_controller: Unexpected error in worker for App hall_controller:
2020-02-07 22:34:54.189194 WARNING hall_controller: Worker Ags: {'id': '70a0b38623c543cc979ebc08af76b188', 'name': 'hall_controller', 'objectid': 'b503df8f82424d5aaddb12c918204000', 'type': 'event', 'event': 'zha_event', 'function': <bound method ZHAIntegration.callback of <core.integration.zha.ZHAIntegration object at 0x74f673a0>>, 'data': {'unique_id': '14:b4:57:ff:fe:7b:8b:f2:1:0x0008', 'device_ieee': '14:b4:57:ff:fe:7b:8b:f2', 'endpoint_id': 1, 'cluster_id': 8, 'command': 'move_with_on_off', 'args': [0, 83]}, 'pin_app': True, 'pin_thread': 3, 'kwargs': {'device_ieee': '14:b4:57:ff:fe:7b:8b:f2', '__thread_id': 'MainThread'}}
2020-02-07 22:34:54.190399 WARNING hall_controller: ------------------------------------------------------------
2020-02-07 22:34:54.193131 WARNING hall_controller: Traceback (most recent call last):
  File "/usr/lib/python3.8/site-packages/appdaemon/threading.py", line 725, in async_worker
    await funcref(args["event"], data, args["kwargs"])
  File "/config/appdaemon/apps/controllerx/apps/controllerx/core/integration/zha.py", line 22, in callback
    await self.controller.handle_action(action)
  File "/config/appdaemon/apps/controllerx/apps/controllerx/core/controller.py", line 108, in handle_action
    await action(*args)
  File "/config/appdaemon/apps/controllerx/apps/controllerx/core/controller.py", line 28, in _action_impl
    await method(self, *args, **kwargs)
  File "/config/appdaemon/apps/controllerx/apps/controllerx/core/type/light_controller.py", line 318, in hold
    await super().hold(attribute, direction)
  File "/config/appdaemon/apps/controllerx/apps/controllerx/core/controller.py", line 28, in _action_impl
    await method(self, *args, **kwargs)
  File "/config/appdaemon/apps/controllerx/apps/controllerx/core/controller.py", line 179, in hold
    stop = await self.hold_loop(*args)
  File "/config/appdaemon/apps/controllerx/apps/controllerx/core/type/light_controller.py", line 321, in hold_loop
    return await self.change_light_state(
  File "/config/appdaemon/apps/controllerx/apps/controllerx/core/type/light_controller.py", line 348, in change_light_state
    new_state_attribute, exceeded = stepper.step(old, direction)
  File "/config/appdaemon/apps/controllerx/apps/controllerx/core/stepper/minmax_stepper.py", line 21, in step
    new_value = value + sign * step
TypeError: unsupported operand type(s) for +: 'NoneType' and 'int'

2020-02-07 22:34:54.194219 WARNING hall_controller: ------------------------------------------------------------
@jrbenito jrbenito added the bug Something isn't working label Feb 7, 2020
@xaviml
Copy link
Owner

xaviml commented Feb 7, 2020

Have you restart AppDaemon server after the update?

Could you share the instance app configuration for hall_controller?

@xaviml
Copy link
Owner

xaviml commented Feb 8, 2020

I just tried the following configuration:

test:
  module: controllerx
  class: E1810Controller
  controller: <id>
  integration: zha
  light: group.test_lights
  smooth_power_on: true

and I haven't had any issues with the smooth_power_on. Could you maybe also indicate which light or lights you are binding? I have tried with two TRADFRI LED bulb E27 1000 lumen, dimmable, white spectrum, opal white (LED1732G11) by IKEA

@jrbenito
Copy link
Author

jrbenito commented Feb 9, 2020

Sorry for delay.

Have you restart AppDaemon server after the update?

Yes, actually I've restarted my RPi too.

Could you share the instance app configuration for hall_controller?

kitchen1_controller:
  module: controllerx
  class: E1810Controller
  controller: <id>
  integration: zha
  smooth_power_on: true
  light: light.kitchen_master

kitchen2_controller:
  module: controllerx
  class: E1743Controller
  controller: <id>
  integration: zha
  smooth_power_on: true
  light: light.kitchen_master

hall_controller:
  module: controllerx
  class: E1743Controller
  controller:
    - <id1>
    - <id2>
  integration: zha
  smooth_power_on: true
  light: light.hallway_master

So, both kitchen and hallway controllers works but none do smoth_power_on. One thing I noticed is that, when dimm_up button is hold, sometimes I get a message from ZHA in the logs:

2020-02-09 00:39:42 WARNING (MainThread) [zigpy.zcl] Data remains after deserializing ZCL frame

I will turn debug on from ZHA and see if more things come. Not all the time I get errors from AppDaemon logs, so even do smooth_power_on doesn't work, it was not directly tied to that error message I first posted. (but the message keeps showing from time to time).

My lights:

Kitchen -> 6 x Ikea GU10 brigthness/color temperature version
Hallway -> 3x Ikea GU10 brightness/ no color temperature version

Groups:

light:
  - platform: group
    name: Kitchen Master
    entities:
      - light.ikea_of_sweden_tradfri_bulb_gu10_ws_400lm_xxxxx_level_light_color_on_off
      - light.ikea_of_sweden_tradfri_bulb_gu10_ws_400lm_xxxxx_level_light_color_on_off
      - light.ikea_of_sweden_tradfri_bulb_gu10_ws_400lm_xxxxx_level_light_color_on_off
      - light.ikea_of_sweden_tradfri_bulb_gu10_ws_400lm_xxxxx_level_light_color_on_off
      - light.ikea_of_sweden_tradfri_bulb_gu10_ws_400lm_xxxxx_level_light_color_on_off
      - light.ikea_of_sweden_tradfri_bulb_gu10_ws_400lm_xxxxx_level_light_color_on_off
  - platform: group
    name: Hallway Master
    entities:
      - light.hall_entrance_spot1
      - light.hall_middle_spot1
      - light.hall_laundry_spot1

One other behavior, with this configuration above, I can bright/dim the lights by pressing button but not by holding button (both E1810 and E1743). However, I can tune color temp (E1810) by pressing or hold buttons (left/right).

Thanks for any clue.

@xaviml
Copy link
Owner

xaviml commented Feb 9, 2020

Hi @jrbenito,

I am guessing the problem is related to the way you created the group of lights. The way the groups are supported is by the group integration and not light group. For the moment, if you want to group lights, you will need to do it this way: https://www.home-assistant.io/integrations/group/

Let me know if you try and it solves the problem. I will need to give support to group of light grouped with the way you did it.

@jrbenito
Copy link
Author

jrbenito commented Feb 9, 2020

Hi @xaviml,

Well, I might be doing something wrong because below configurations has exactly the same behavior:

bath_controller:
  module: controllerx
  class: E1810Controller
  controller: <id>
  integration: zha
  smooth_power_on: true
  light: group.bathroom

groups.yaml:

bathroom:
  name: Bathroom
  entities:
    - light.ikea_of_sweden_tradfri_bulb_gu10_ws_400lm_xxxxxxxx_level_light_color_on_off
    - light.ikea_of_sweden_tradfri_bulb_gu10_ws_400lm_xxxxxxxx_level_light_color_on_off
    - light.ikea_of_sweden_tradfri_bulb_gu10_ws_400lm_xxxxxxxx_level_light_color_on_off
    - light.ikea_of_sweden_tradfri_bulb_gu10_ws_400lm_xxxxxxxx_level_light_color_on_off

The only thing is, I have this config for Bathroom and the light group for kitchen and hall in the same apps.yaml. Does one config affects another?

@xaviml
Copy link
Owner

xaviml commented Feb 9, 2020

Interesting.. so this configuration gives the same error as the other one? Could you put the logs of this configuration in here? Also, does is work as expected (and without errors) without the smooth_power_on?

@htvekov
Copy link
Contributor

htvekov commented Feb 13, 2020

Hi' Xavi.

I get the exact same errors as jrbenito applying smooth power on to a single Ikea color bulb using a E1743 remote. Can't get it to work.

My setup:
AppDeamon 4
Home Assistant Core 0.105.2
ControllerX: v2.2.0
Integration: z2m

2020-02-13 19:41:23.021071 INFO AppDaemon: Initializing app office1_controller using class E1743Controller from module controllerx
2020-02-13 19:41:51.898039 WARNING office1_controller: ------------------------------------------------------------
2020-02-13 19:41:51.901136 WARNING office1_controller: Unexpected error in worker for App office1_controller:
2020-02-13 19:41:51.903114 WARNING office1_controller: Worker Ags: {'id': '6ac2e6689329424189ebd39011097b68', 'name': 'office1_controller', 'objectid': '231cf3c0b34345a6be7917806a3450c7', 'type': 'state', 'function': <bound method Z2MIntegration.callback of <core.integration.z2m.Z2MIntegration object at 0x74bd43a0>>, 'attribute': 'state', 'entity': 'sensor.0x000d6ffffeb9f099_click', 'new_state': 'brightness_up', 'old_state': '', 'pin_app': True, 'pin_thread': 2, 'kwargs': {'__thread_id': 'MainThread'}}
2020-02-13 19:41:51.904810 WARNING office1_controller: ------------------------------------------------------------
2020-02-13 19:41:51.908496 WARNING office1_controller: Traceback (most recent call last):
File "/usr/lib/python3.8/site-packages/appdaemon/threading.py", line 709, in async_worker
await funcref(entity, attr, old_state, new_state, self.AD.state.sanitize_state_kwargs(app, args["kwargs"]))
File "/config/appdaemon/apps/controllerx/core/integration/z2m.py", line 15, in callback
await self.controller.handle_action(new)
File "/config/appdaemon/apps/controllerx/core/controller.py", line 108, in handle_action
await action(*args)
File "/config/appdaemon/apps/controllerx/core/controller.py", line 28, in _action_impl
await method(self, *args, **kwargs)
File "/config/appdaemon/apps/controllerx/core/type/light_controller.py", line 318, in hold
await super().hold(attribute, direction)
File "/config/appdaemon/apps/controllerx/core/controller.py", line 28, in _action_impl
await method(self, *args, **kwargs)
File "/config/appdaemon/apps/controllerx/core/controller.py", line 179, in hold
stop = await self.hold_loop(*args)
File "/config/appdaemon/apps/controllerx/core/type/light_controller.py", line 321, in hold_loop
return await self.change_light_state(
File "/config/appdaemon/apps/controllerx/core/type/light_controller.py", line 348, in change_light_state
new_state_attribute, exceeded = stepper.step(old, direction)
File "/config/appdaemon/apps/controllerx/core/stepper/minmax_stepper.py", line 21, in step
new_value = value + sign * step
TypeError: unsupported operand type(s) for +: 'NoneType' and 'int'
2020-02-13 19:41:51.910698 WARNING office1_controller: ------------------------------------------------------------

@xaviml
Copy link
Owner

xaviml commented Feb 13, 2020

Hi @htvekov, it is very interesting. I don't happen to reproduce this on my set up (same controller and same integration). Does the light turns on at least?

I will add some debug logs to see where the error might come from.

@xaviml
Copy link
Owner

xaviml commented Feb 13, 2020

Do you guys see "brightness" attribute when the light is off? like in this picture.
Screenshot from 2020-02-13 20-26-08

@htvekov
Copy link
Contributor

htvekov commented Feb 13, 2020

All 'normal' functions work. But press and hold 'on' button doesn't turn on light.

No, brightness attribute disappears and is NOT present when light is off.
It might be in order to mention that all my lights are connected to HA via Hue bridge and not on my HA z2m network (don't know if attributes presented to HA from Hue Bridge differ from what z2m presents ?)

image

image

@xaviml
Copy link
Owner

xaviml commented Feb 13, 2020

I think I have spotted the error then. I got all my lights with z2m and they report the brightness as well when they are off and this is why I do not see any errors. However, I have seen that a line of code should be placed in an "else" condition. I will publish a release soon with this change and I will let you know to check if that fixed the error. Thank you for your answer.

@htvekov
Copy link
Contributor

htvekov commented Feb 13, 2020

Your very welcome, Xavi 😊

Just had a quick check. All my lights both Ikea- and Hue bulbs (and Hue light groups as well) have no brigtness attribute set when turned off. So it's the bridge that doesn't send all attributes when light are off. Quite a pity, as I'm not able to set brightness on my Ikea bulbs when they're turned off...
I'll probably have to reconsider my setup with all lights on the Hue bridge and all other zigbee sensors etc. on z2m. But then again, one major obstacle is the WAF (Wife Acceptance Factor) 👩👩😁😁😁

Looking forward to test, when you have new code ready, Xavi 👍

xaviml added a commit that referenced this issue Feb 13, 2020
@xaviml
Copy link
Owner

xaviml commented Feb 13, 2020

Hi guys

I released v2.2.1b1 with a fix for this bug. These are the instructions to try the code:

Through HACS

If you go to ControllerX in HACS, you can select in the menu Show Beta and install v2.2.1b1. Then you will need to restart your AppDaemon server.

Through files

You can download the dev branch and copy the controllerx folder inside apps into /config/appdaemon/apps/. Then you will need to restart your AppDaemon server.

If you guys try it out, let me know about it. Thanks :)

@htvekov
Copy link
Contributor

htvekov commented Feb 13, 2020

Hi' Xavi

Just tested the smoot power on.
Still a 'no go' I'm afraid 🤔

image

2020-02-13 23:19:34.318064 WARNING office1_controller: ------------------------------------------------------------
2020-02-13 23:19:34.320608 WARNING office1_controller: Unexpected error in worker for App office1_controller:
2020-02-13 23:19:34.323345 WARNING office1_controller: Worker Ags: {'id': '82f64d0124f043e28ba283692ef0c3b5', 'name': 'office1_controller', 'objectid': 'c8fa394820054d29a36a0f541055a391', 'type': 'state', 'function': <bound method Z2MIntegration.callback of <core.integration.z2m.Z2MIntegration object at 0x74f24f58>>, 'attribute': 'state', 'entity': 'sensor.0x000d6ffffeb9f099_click', 'new_state': 'brightness_up', 'old_state': '', 'pin_app': True, 'pin_thread': 2, 'kwargs': {'__thread_id': 'MainThread'}}
2020-02-13 23:19:34.325123 WARNING office1_controller: ------------------------------------------------------------
2020-02-13 23:19:34.328119 WARNING office1_controller: Traceback (most recent call last):
File "/usr/lib/python3.8/site-packages/appdaemon/threading.py", line 709, in async_worker
await funcref(entity, attr, old_state, new_state, self.AD.state.sanitize_state_kwargs(app, args["kwargs"]))
File "/config/appdaemon/apps/controllerx/core/integration/z2m.py", line 15, in callback
await self.controller.handle_action(new)
File "/config/appdaemon/apps/controllerx/core/controller.py", line 108, in handle_action
await action(*args)
File "/config/appdaemon/apps/controllerx/core/controller.py", line 28, in _action_impl
await method(self, *args, **kwargs)
File "/config/appdaemon/apps/controllerx/core/type/light_controller.py", line 318, in hold
await super().hold(attribute, direction)
File "/config/appdaemon/apps/controllerx/core/controller.py", line 28, in _action_impl
await method(self, *args, **kwargs)
File "/config/appdaemon/apps/controllerx/core/controller.py", line 179, in hold
stop = await self.hold_loop(*args)
File "/config/appdaemon/apps/controllerx/core/type/light_controller.py", line 321, in hold_loop
return await self.change_light_state(
File "/config/appdaemon/apps/controllerx/core/type/light_controller.py", line 348, in change_light_state
new_state_attribute, exceeded = stepper.step(old, direction)
File "/config/appdaemon/apps/controllerx/core/stepper/minmax_stepper.py", line 21, in step
new_value = value + sign * step
TypeError: unsupported operand type(s) for +: 'NoneType' and 'int'
2020-02-13 23:19:34.330779 WARNING office1_controller: ------------------------------------------------------------

@xaviml
Copy link
Owner

xaviml commented Feb 13, 2020

Hi, it seems you are still running v2.2.0 since the line that crashes is not there in v2.2.1b1. Try to click on "reinstall" or uninstall ControllerX and install again v2.1.1b1

@xaviml
Copy link
Owner

xaviml commented Feb 13, 2020

Also, do not forget to restart AppDaemon addon.

@jrbenito
Copy link
Author

I will post my results as soon I get back home.

My lights and controllers are all paired to HA via ZHA integration.

@jrbenito
Copy link
Author

Hi there,

So here is my setup:

zha-xavi

First one is an Ikea GU10 with color temp capability, it is off at the moment of the screenshot.
Second is light group (not a group of lights) that includes the first one, also off at the moment
Third one is a Hue group of lights (provided by philips hue bridge), also off at the moment.

Now, here are the same lights but all turned on:

zha-nowOn

Hence, both hue groups and Light groups (not groups of lights) report same capabilities and none report brightness when off. That might explain things.

Just to clarify: light.accent is a device connected via ZHA, light.bathroom_master is a light group (light from platform group created on HA) and light.closet is a group provided by philips hue bridge.

BRs,

@xaviml
Copy link
Owner

xaviml commented Feb 14, 2020

Thanks @jrbenito, as I suspected the problem was that the light did not show brightness when it was off. This caused an error in a line that was missplaced.

I got it fixed in v2.2.1b1, if you follows the instructions I gave before, you can try and let me know if that fixed the problem.

Also, if you want to try the group of light, you will need to do it through normal groups ("group.xxxxx").

Thanks for the detailed answer!

@htvekov
Copy link
Contributor

htvekov commented Feb 14, 2020

Hi' Xavi.

You've been busy coding 😁😎

I had to do a couple of restarts before the beta actually was loaded and used (even though HACS indicated that the beta was installed ?)

Anyway, it works - but not perfectly. I'll try to explain the behaviour I experience 😊

On my setup (with Ikea color bulb on Hue Bridge) 'smooth power on' turns on the bulb at a little bit brighter state, than lowest possible and dims to minimum (within 0.1/0.2 seconds or so).
Immediately after bulb is turned on, the brightness start to increase. So it's hard to make a 'smooth power on' and NOT to increase brightness by mistake, as you have to release button immediately after bulb turns on.

Perhaps you should implement that brightness won't change on initial long press. Meaning that button has to be released and pressed again before brightness adjusting begins ?

I'm not sure whether or not the startup brightness behaviour I experience can be dealt with ?
Perhaps it's just the nature of the Ikea bulbs on Hue bridges (Don't know if Hue bridge applies some form of 'standard' transition period to Ikea bulbs as well as Hue bulbs. That would require Zigbee logs from Hue bridge to tell exactly whats happening). I'll test behavior on other Ikea bulbs (warm white- and white spectrum bulbs)

In 'real life' it's really not a problem as the brightness on startup is only slightly higher than lowest possible and drops to lowest level within some 0.1 second)

Thank you once again, Xavi 👍

@xaviml
Copy link
Owner

xaviml commented Feb 14, 2020

Hi @htvekov,

Thanks again for your extensive feedback on this issue. You turned out to be the tester star for this release 😄. I experience the same with z2m. This is because I had a problem with the brightness state and I had to turn on first the light and then change its brightness, this is why you see that behavior within 0.1s. However, I will double-check if that can be avoided, but I cannot assure anything.

Respect the smooth power on when holding, it is expected. However, as you say it does not make sense to keep brightening if what you wanted is the minimum brightness. So, I will change this behavior. It will turn the light to minimum brightness and it won't change the brightness. However, you will be able to brighten up a little bit if you hold up again.

I will keep you updated.

@xaviml
Copy link
Owner

xaviml commented Feb 14, 2020

Well, it was quicker than I thought to fix. You can download now from HACS v2.2.1b2. I fixed the following:

  • When the button is held, it does not keep brightening the light up, it just keeps to minimum brightness.
  • The light is not turn on twice to set the brightness, so if set to maximum brightness, then turned off and then hold for smooth power on, it should not bright up for 0.1, it should just bright to minimum brightness directly.

Let me know if this is the behavior now. Thank you for your testing @htvekov and @jrbenito.

@htvekov
Copy link
Contributor

htvekov commented Feb 14, 2020

Holy crap, you're quick Xavi 🚀🚀😁

Tested new beta fw and 'smooth power on' works perfect in my setup now.

  • Hold button turns on light and brightnes does not increase until button is released and pressed again
  • Initial brightness 'glitch' appears to have to have disappeared altogether. I can't see any initial higher brigtness now on any of my Ikea bulbs now (color, warm white and white spectrum E27 bulbs)

All in all perfect behaviour in my setup - Nice job, Xavi 😎👍

@xaviml
Copy link
Owner

xaviml commented Feb 14, 2020

This issue has been fixed in v2.2.1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants