NoUseFreak / niko-home-control

Python connector for niko home control
MIT License
4 stars 7 forks source link

missing release for niko-home-control==0.2.1 #10

Open onkelbeh opened 4 years ago

onkelbeh commented 4 years ago

Hi Dries,

hope you don't mind I am using your component in Home Assistant Gentoo Overlay, ebuilds: https://git.edevau.net/onkelbeh/HomeAssistantRepository/src/branch/master/dev-python/niko-home-control.

Home Assistant currently relies on niko-home-control==0.2.1

You do not publish SDIST on Pypi, and you did not add a tag for 0.2.1 here. To get a valid source, I forked it, and created the missing tag for https://github.com/NoUseFreak/niko-home-control/commit/4b9ff57c0f3fdadea7ac450d548292ca7b3033ad

Could you please snap a release or add a tag for 0.2.1, so I could get rid of the fork?

Thanks a lot. Greeting from sunny bavaria!

pergolafabio commented 4 years ago

Did it ever work on HA? Nikov1 ? When it was released , always had issues below...

https://github.com/home-assistant/core/issues/20005

NoUseFreak commented 4 years ago

Hi @onkelbeh , I've added the tag per your request, not sure why it was not present...

NoUseFreak commented 4 years ago

@pergolafabio I can confirm it does work with the v1 version on HA. If you are able to help me solve some issues others are having that would be great. It's still unclear if anyone that is having issues has this with the HA integration or with the lib itself.

Here is a snippet that should at least verify the working of the library.

https://github.com/NoUseFreak/niko-home-control.git
cd niko-home-control
pip3 install -r requirements.py
from nikohomecontrol import (
    NikoHomeControl
)

niko = NikoHomeControl({
    'ip': '<IP>',
    'port': 8000,
    'timeout': 20000,
    'events': True
})

print(niko.system_info())

for a in niko.list_actions():
    print(vars(a))
pergolafabio commented 4 years ago

It was not for me, but for someone I know, but he runs hassos, so not sure if I can do a pip install, do I need to change the requirements maybe? I can load a custom for him... Or should it work out of the box

NoUseFreak commented 4 years ago

The test script is not required to run on HA. From what I gather, it's a json parse error between the lib and the niko API. So feel free to run it on any device.

pergolafabio commented 4 years ago

ok, gonna let him test again, but i think we still receive this error as before :

https://github.com/home-assistant/core/issues/19283 , first post

onkelbeh commented 4 years ago

Thanks, reverted my SRC_URI to the new tag, and deleted the fork: https://git.edevau.net/onkelbeh/HomeAssistantRepository/issues/76#issuecomment-910

At least I can confirm it compiles fine, and runs all test. I can't do more tests because I do not have the hardware. Not sure if I sould close this here now because of the other issue, so I let it open.

pergolafabio commented 4 years ago

hi @NoUseFreak , we tried the platform again, but upon restart HA, still the error below

any idea?

2020-09-14 13:07:23 ERROR (MainThread) [homeassistant.components.light] Error while setting up niko_home_control platform for light
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 184, in _async_setup_platform
    await asyncio.shield(task)
  File "/usr/src/homeassistant/homeassistant/components/niko_home_control/light.py", line 37, in async_setup_platform
    [NikoHomeControlLight(light, niko_data) for light in nhc.list_actions()], True
  File "/usr/local/lib/python3.8/site-packages/nikohomecontrol/nikohomecontrol.py", line 36, in list_actions
    return [Action(action, self) for action in self.list_actions_raw()]
  File "/usr/local/lib/python3.8/site-packages/nikohomecontrol/nikohomecontrol.py", line 36, in <listcomp>
    return [Action(action, self) for action in self.list_actions_raw()]
  File "/usr/local/lib/python3.8/site-packages/nikohomecontrol/nikohomecontrol.py", line 77, in __init__
    self._id = action['id']
TypeError: string indices must be integers
NoUseFreak commented 4 years ago

@pergolafabio Do you have nc or telnet installed? Could you perhaps try the following command and share the output? I would like to understand why it fails to parse the json Niko is returning.

$ nc <IP> 8000
{"cmd":"listactions"}

I would be expecting something that is a valid json.

{"cmd":"listactions","data":[ {"id":1,"name":"Light Bathroom","type":1,"location":3,"value1":0},...]}
pergolafabio commented 4 years ago

hi @NoUseFreak , i asked him, here is output from @vincentvanneer

{"cmd":"listactions","data":[ {"id":16,"name":"Ledstrip keukeneiland","type":1,"location":4,"value1":0},{"id":22,"name":"Toilet gelijkvloers","type":1,"location":2,"value1":0},{"id":23,"name":"Technische ruimte","type":1,"location":3,"value1":0},{"id":25,"name":"Alles uit","type":0,"location":5,"value1":0},{"id":55,"name":"Thuiskomen","type":1,"location":5,"value1":0},{"id":33,"name":"Spots zithoek","type":2,"location":5,"value1":0},{"id":34,"name":"Automatische verlichting","type":1,"location":1,"value1":0},{"id":40,"name":"Stopcontact living","type":1,"location":5,"value1":0},{"id":42,"name":"Spots speelruimte","type":2,"location":5,"value1":0},{"id":43,"name":"Verlichting eetplaats","type":2,"location":5,"value1":0},{"id":44,"name":"Verlichting berging","type":1,"location":6,"value1":0},{"id":49,"name":"TV kijken","type":1,"location":5,"value1":0},{"id":50,"name":"Zwembadpomp","type":1,"location":8,"value1":0},{"id":51,"name":"Zwembadverlichting","type":1,"location":8,"value1":0},{"id":52,"name":"Buitenverlichting poolhouse","type":1,"location":8,"value1":0},{"id":54,"name":"Verlichting garage","type":1,"location":7,"value1":0},{"id":56,"name":"Verlichting keukeneiland","type":2,"location":4,"value1":0},{"id":61,"name":"Koken","type":1,"location":4,"value1":0},{"id":71,"name":"Automatisch verlichting","type":1,"location":7,"value1":0},{"id":72,"name":"Garagepoort","type":1,"location":7,"value1":0}]}

pergolafabio commented 4 years ago

hey @NoUseFreak

already got a chance to look at the issue?

NoUseFreak commented 3 years ago

Hi @pergolafabio I've not found the time to investigate the issue. If I would guess what the issue could be, it might be related to the size of the json being cut off at some point.

@legovaer Do you believe this might/can be the cause? I know you did some improvements on the tcp connection implementation.

pergolafabio commented 3 years ago

can i try shorter names for the lights to decrease the output of the json? is the culprit maybe the 255 max characters in HA?

NoUseFreak commented 3 years ago

You can give it a try, although I'm also noticing in my implementation, I only have actions of type 1 Do you know what type 0 and 2 could be?

pergolafabio commented 3 years ago

its not my house :-) , but could type 0 some kind of mood and type 2 a dimmer?

vincentvanneer commented 3 years ago

Hi Dries

It's my installation that Fabio is referring to.

I noticed that the types are following the actual type of action in NHC.

Type: 0 is an action with one option. On or Off. Not both. I used that to configure my ALL OFF Type: 1 is an action with on/off option. Those are used in 99% of my setup Type: 2 is a dimmer in NHC

I just removed the Type: 0 but the error remains.

I just downloaded the python project on your Github. I'll debug the code and see where the issue comes from.

Regards

Vincent.

NoUseFreak commented 3 years ago

Hi Vincent, It looks like my installation only has type 1 in the API. Although I have dimmers, I guess I've always assumed dimmers are not in the API, guess I will need to upgrade my installation at some point. Let me know your findings and if I can be of any assistance.

pergolafabio commented 3 years ago

so the culprit is maybe the dimmer?

NoUseFreak commented 3 years ago

I don't expect it to be, although I've never tested the dimmer functionality. The TypeError: string indices must be integers looks like something python is accessing in a bad way. I just don't quite see what it can be.

pergolafabio commented 3 years ago

Does it help to turn on debug?

vincentvanneer commented 3 years ago

I don't expect it to be, although I've never tested the dimmer functionality. The TypeError: string indices must be integers looks like something python is accessing in a bad way. I just don't quite see what it can be.

I’ll debug the code tonight. I assume it’s something in the parsing of the json reply.

Will keep you posted!

Regards

Vincent