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

Unable to power off by setting mode to 0 #25

Closed
IonBlade2K opened this issue Oct 24, 2019 · 17 comments
Closed

Unable to power off by setting mode to 0 #25

IonBlade2K opened this issue Oct 24, 2019 · 17 comments

Comments

@IonBlade2K
Copy link

IonBlade2K commented Oct 24, 2019

I currently have a series of HA Scripts setup to set different modes on my DreamScreen via scripts.yaml - off, video, music, and ambient. Previously, all 4 were working fine, but the SD card on my Pi died, and after rebuilding and updating HA and the HA DreamScreen Service to the latest, I'm no longer able to issue the mode: 0 to power the DreamScreen off. All other modes work fine, and the same script I use to power off works as expected to change the mode to video, music, or ambient by specifying anything but 0 for the mode.

When trying to execute the script to set the mode to 0, nothing changes on the DreamScreen, and I get this event in the HA logs:

Error executing script script.dreamscreen_off. Unknown error for call_service at pos 1:
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/components/script/init.py", line 209, in async_turn_on
await self.script.async_run(kwargs.get(ATTR_VARIABLES), context)
File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 181, in async_run
await self._handle_action(action, variables, context)
File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 265, in _handle_action
await self._actions[_determine_action(action)](action, variables, context)
File "/usr/src/homeassistant/homeassistant/helpers/script.py", line 348, in _async_call_service
context=context,
File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 97, in async_call_from_config
domain, service_name, service_data, blocking=blocking, context=context
File "/usr/src/homeassistant/homeassistant/core.py", line 1233, in async_call
await asyncio.shield(self._execute_service(handler, service_call))
File "/usr/src/homeassistant/homeassistant/core.py", line 1258, in _execute_service
await handler.func(service_call)
File "/config/custom_components/dreamscreen/init.py", line 173, in async_handle_dreamscreen_services
getattr(entity.device, attribute)()
TypeError: 'int' object is not callable

Attached is my scripts.yaml, which previously worked fine until updating HA and the script from a ~6 mo - 1 year old version.

scripts.yaml.txt

@J3n50m4t
Copy link
Owner

Without testing it on my system could you try my script (which worked yesterday at HA version 0.100.2)
Only difference I see is ' ' around the mode..

https://github.com/J3n50m4t/HomeAssistantConfiguration/blob/da9d2925ac687a3ca6c1c9ff5add4cfd59779122/automations.yaml#L143

@IonBlade2K
Copy link
Author

Thanks for the quick response! Unfortunately, seems like it does the same thing with either single or double quotes around the 0. I'm on 0.100.3, though the change notes don't make it seem like they'd have touched anything that should be related.

@J3n50m4t
Copy link
Owner

I want to update this weekend.. I will look into it then.

@IonBlade2K
Copy link
Author

IonBlade2K commented Oct 24, 2019

Thanks again! In doing some more digging, I found that this seems to be the case any time I use a value of 0 for the DreamScreen Service's available calls. For example, calling set_brightness with a value of 0 or set_ambient_scene with a scene of 0 also both throw the "'int' object is not callable" error.

Not sure if that helps at all, just something I found while coming up with a workaround of setting the brightness to 1 and color to 000001 to effectively turn the LEDs off for now.

@J3n50m4t
Copy link
Owner

J3n50m4t commented Oct 24, 2019

Tested it - works.
After upgrading - did you update your dreamscreen as well? There were few changes.
I used your turn of script, added it to my Config and only adjusted the naming. Dreamscreen instantly turned off over here.
(ofc updated to 0.100.3)

@IonBlade2K
Copy link
Author

Thanks for testing. I did validate that I'm on the latest for the DS4K - 1.6.5.6. At least this is the latest the app provides - not sure if there's some community unofficial firmware I'm not aware of.

Is your setup using the latest pull of the DS Service as well? If so, I can't imagine why this isn't working in my setup, since I nuked my whole DS Service folder out and re-pulled to make sure I had the latest files for it.

Not a huge deal, since I have a workaround in setting mode to ambient, brightness to 1, and color to 000001 as my new "off" script, which is such a low signal that the LEDs don't light up - just hoping that that isn't dangerous 24x7 for the DreamScreen.

@J3n50m4t
Copy link
Owner

Last Edit 2018 - so I don't think thats it.
I'm using latest pydreamscreen, lattest homeassistant component (this repo here).
also int object is not callable doesn't make much sense to me tbh.
could you checkout the repo again in you components with latest commits?

@msalhi
Copy link

msalhi commented Oct 27, 2019

Hello,
I'm facing the exact same issue. I've updated this component to the latest, also i tried with 3 version of HA (0.99, 0.100.2, 0.100.3), and my DS4K firmware is 1.6.5.7.
I tried in my script to put
mode: 0
mode: '0'
mode: "0"

I still have the error:
TypeError: 'int' object is not callable

@J3n50m4t
Copy link
Owner

Oh.. Turns out my version is pre hdr. The failing function got added in a commit later.
But that's good, we now know it did work before and it shouldn't be to hard to fix.

Sent with GitHawk

@msalhi
Copy link

msalhi commented Oct 27, 2019

I've checked on my side and it's working until commit 2549303.
The issue happen starting commit 1ced346.

@J3n50m4t
Copy link
Owner

Yes thanks. Will fix soon. Will inform you here then.

Sent with GitHawk

@J3n50m4t
Copy link
Owner

Could you test 6529aec please?

I've updated over here and it seems to work now. But I don't want to close until you can confirm.

@msalhi
Copy link

msalhi commented Oct 27, 2019

I tested it. I don't get the error anymore, but the service "set_mode" doesn't turn off the dreamscreen. looks like an empty service. no error message nothing

@msalhi
Copy link

msalhi commented Oct 27, 2019

I think i found the problem. Here is what I did.

173                 #getattr(entity.device, attribute)
174                 setattr(entity.device, attribute, attribute_value)

As you can see, I've replaced the getattr() and force to setattr() in order to get back to what it was before the HDR commit and it works fine.
Somehow, the getattr() doesn't work correctly.

@J3n50m4t
Copy link
Owner

Great Work!
So feel free to forge a PR

@IonBlade2K
Copy link
Author

That fixed it on my side as well. Thanks all!

@J3n50m4t
Copy link
Owner

Also fixed on my side. Great work @msalhi

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

No branches or pull requests

3 participants