J3n50m4t / Home-Assistant-DreamScreen-Service

Home Assistant Service for sending commands to a Wifi enabled DreamScreen
MIT License
31 stars 15 forks source link

Unable to power off by setting mode to 0 #25

Closed IonBlade2K closed 4 years ago

IonBlade2K commented 4 years ago

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 commented 4 years ago

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 commented 4 years ago

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 commented 4 years ago

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

IonBlade2K commented 4 years ago

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 commented 4 years ago

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 commented 4 years ago

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 commented 4 years ago

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 commented 4 years ago

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 commented 4 years ago

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 commented 4 years ago

I've checked on my side and it's working until commit 2549303279d98c1791ccfd08b1fb13899485c191. The issue happen starting commit 1ced346487f571441db8175939c4e044b1cab699.

J3n50m4t commented 4 years ago

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

Sent with GitHawk

J3n50m4t commented 4 years ago

Could you test https://github.com/GregoryDosh/Home-Assistant-DreamScreen-Service/commit/6529aec52244bfc9dbb8dd6db02f3f0ecbbc9945 please?

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

msalhi commented 4 years ago

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 commented 4 years ago

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 commented 4 years ago

Great Work! So feel free to forge a PR

IonBlade2K commented 4 years ago

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

J3n50m4t commented 4 years ago

Also fixed on my side. Great work @msalhi