home-assistant / core

:house_with_garden: Open source home automation that puts local control and privacy first.
https://www.home-assistant.io
Apache License 2.0
74.2k stars 31.16k forks source link

homekit_controller: Support custom characteristic for Koogeek Smart Plug EU "Watt" data #27220

Closed pilot1981 closed 3 years ago

pilot1981 commented 5 years ago

Home Assistant release with the issue: it isn't possible to integrate koogeek smart plug EU

Last working Home Assistant release (if known): 0.99.3

Operating environment (Hass.io/Docker/Windows/etc.): HASSIO

Integration: homekit controller

Description of problem: sometime, HA don't find plug, sometime after inserted PIN it answer not correct; I already tried with plug in AP mode or after removing it from apple home app...

Problem-relevant configuration.yaml entries and (fill out even if it seems unimportant): NA

Traceback (if applicable): NA I don't fine anything useful, if you need some log please say where find it...

Additional information: NA

probot-home-assistant[bot] commented 5 years ago

Hey there @Jc2k, mind taking a look at this issue as its been labeled with a integration (homekit_controller) you are listed as a codeowner for? Thanks!

Jc2k commented 5 years ago

Thanks for raising this ticket. I have Koogeek light strip working with Home Assistant so hopefully we can figure out what is wrong with your smart plug.

I'm not sure what AP mode is - I have assumed it is "Access Point" mode. If not please ignore those points.

You have made a few different points and some of them may or may not be related, for example if HA can't see the plug when in AP mode - that is expected. If it can't see it when you have it paired with Apple Home - that is also expected. If it can't see it after you have done a hard reset of the device itself - that is also expected. But there are other cases when its not. So we need to construct a timeline of what you try and in what order and what happens.

When pairing with Home Assistant the device should not be in access point mode (if thats what AP mode is). And it should not be paired with your apple devices.

The normal pairing flow for a Koogeek device seems to be:

When paired, future communication is over TCP and the protocol is less reliant on mDNS, so hopefully if you do have reliability issues they will be greatly reduced after pairing is complete.

If you are still having trouble after following these steps then can you give a timeline of what you tried as bullet points. Try to capture as much information as possible. We don't have access to your device, your HA instance or your network setup so we only have what you tell us to go on. Ideally try and monitor your Koogeek starting with mDNS as described ^ as this can rule out networking issues quickly.

mDNS (the mechanism used for discovery) may not be fully functional depending on your network setup. So please also include details of your network. Do you have vlans? Do you have one flat subnet for wifi and ethernet? Or are there 2 subnets? What brand of networking gear do you use?

I do not use HASSIO myself, i use Home Assistant directly. And i only ever run it in a custom Docker container or from the command line of my development machine. So all the logs I look at are on stdout. I can't help you find where they are for your particular environment, unfortunately.

Jc2k commented 5 years ago

Also, if you get HA errors in the UI please include the text or a screenshot. There are many errors, and knowing exactly which one you see is very helpful

pilot1981 commented 5 years ago

Hi, thanks for reply. I followed your suggestion, but it stop during paring procedure with HA, please see attachment that say HA don't accept PIN code because device seem to be locked form another controller:

Schermata 2019-10-06 alle 11 29 50

I'm able to ping device before and after remove it from apple home app, and with tcpdump I found it:

11:31:17.625492 IP 192.168.1.113.mdns > 224.0.0.251.mdns: 0*- [0q] 5/0/0 (Cache flush) A 192.168.1.113, (Cache flush) AAAA fe80::a29d:c1ff:feb5:bd2, (Cache flush) SRV hap-B50BD2.local.:80 0 0, PTR Koogeek-P1-B50BD2._hap._tcp.local., (Cache flush) TXT "c#=1" "ff=1" "id=00:9A:13:1E:92:C6" "md=P1EU" "pv=1.1" "sf=1" "ci=7" "s#=1" "sh=RxGD7Q==" (337)
11:31:17.727825 IP6 fe80::a29d:c1ff:feb5:bd2.mdns > ff02::fb.mdns: 0*- [0q] 5/0/0 (Cache flush) A 192.168.1.113, (Cache flush) AAAA fe80::a29d:c1ff:feb5:bd2, (Cache flush) SRV hap-B50BD2.local.:80 0 0, PTR Koogeek-P1-B50BD2._hap._tcp.local., (Cache flush) TXT "c#=1" "ff=1" "id=00:9A:13:1E:92:C6" "md=P1EU" "pv=1.1" "sf=1" "ci=7" "s#=1" "sh=RxGD7Q==" (337)
11:31:17.830329 IP 192.168.1.113.mdns > 224.0.0.251.mdns: 0*- [0q] 5/0/0 (Cache flush) A 192.168.1.113, (Cache flush) AAAA fe80::a29d:c1ff:feb5:bd2, (Cache flush) SRV hap-B50BD2.local.:80 0 0, PTR Koogeek-P1-B50BD2._hap._tcp.local., (Cache flush) TXT "c#=1" "ff=1" "id=00:9A:13:1E:92:C6" "md=P1EU" "pv=1.1" "sf=1" "ci=7" "s#=1" "sh=RxGD7Q==" (337)
11:31:17.830773 IP6 fe80::a29d:c1ff:feb5:bd2.mdns > ff02::fb.mdns: 0*- [0q] 5/0/0 (Cache flush) A 192.168.1.113, (Cache flush) AAAA fe80::a29d:c1ff:feb5:bd2, (Cache flush) SRV hap-B50BD2.local.:80 0 0, PTR Koogeek-P1-B50BD2._hap._tcp.local., (Cache flush) TXT "c#=1" "ff=1" "id=00:9A:13:1E:92:C6" "md=P1EU" "pv=1.1" "sf=1" "ci=7" "s#=1" "sh=RxGD7Q==" (337)

I found the issue...I don't use dashes inserting PIN: now all work fine!!!!

thanks very much for your help!

You know also if I can take consumption value from it? which parameter I have to use?

regards

pilot1981 commented 5 years ago

I tried to obtain Watt data in every way, but I'm not able to do this...it's possible? there is a way to modify this integration? it need custom integration for Koogeek?

Jc2k commented 5 years ago

Sorry I was out after my last message.

Right now we probably only support the "standard" HomeKit characteristics (the ones apple define).

It might be that Koogeek have defined some custom ones that we could read, but they are undocumented. We don't currently have a way to implement support for them, but I would like to.

In your config directory (where configuration.yaml lives) there should be a .storage folder and in there you should see a homekit_controller-entity-map file. That contains all the characteristics your device exposes. If you can attach that I can see if I can see the data you are expecting.

(You might want to review the file first, it can contain serial numbers etc)

pilot1981 commented 5 years ago

Hi, thanks for reply.

In attach you can find file required whitout real mac address and serial number; I found this lines:

  "characteristics": [
                                    {
                                        "description": "1 REALTIME_ENERGY",
                                        "ev": false,
                                        "format": "float",
                                        "iid": 22,
                                        "perms": [
                                            "pr",
                                            "ev"
                                        ],
                                        "type": "4AAAF931-0DEC-11E5-B939-0800200C9A66",
                                        "value": 0.0
                                    },

could be useful? I can use it to create my sensor template?

homekit_controller-entity-map.txt

Jc2k commented 5 years ago

I don't use sensor templates myself but I might be able to make it appear as a state attribute on the entity if that would be useful.

pilot1981 commented 5 years ago

yes, it will be great!!!!!

I wait for your update!

pilot1981 commented 5 years ago

Hi @Jc2k , any news? I could expect this new feature in 0.100.3?

Jc2k commented 5 years ago

Hi @pilot1981 - haven't had much time to work on homekit_controller this past month as really busy and no hobby time. So unfortunately no progress to report. I'll let you know if I find any time to pick this up, but right now it is behind the asyncio rework branch that i am working on (enables events from the devices to work without having to poll).

pilot1981 commented 4 years ago

Hi, any news about this develop?

Jc2k commented 4 years ago

No time to work on it still, sorry. Events still the priority when I do have time.

pilot1981 commented 4 years ago

Hi, any news about my request?

Jc2k commented 4 years ago

Haven't forgot but very little free time. Events still priority when I do have time.

Jc2k commented 4 years ago

@pilot1981 wanted to give you an update on this. The events code i've been talking about for the past X months finally landed upstream and should be in the next release. With that out of the way I've also been able to do a bunch of refactoring to get ready for vendor specific extensions. Not quite there yet but it's getting closer slowly.

pilot1981 commented 4 years ago

Great news!!!! Thanks very much. I wait for new release of HASSIO!

pilot1981 commented 4 years ago

I see HA released 0.107 whit this change:

HomeKit Controller - Support for HomeKit controller’s legacy pairing data folder .homekit has been deprecated and in Home Assistant Core release 0.109.0 we plan to remove this code. Pairings have not been saved this way since Home Assistant 0.94, so if you are running Home Assistant 0.94 or later this does not affect you - your pairings were already migrated to configuration entries. If you are running an older release and do not upgrade soon you will not be able to automatically migrate your existing pairings at upgrade time and will have to manually re-pair them. - (@Jc2k - #32158) (homekit_controller docs)

already this include koogeek plug EU support?

Jc2k commented 4 years ago

Ah sorry, i think i've said something confusing.

Support for custom characteristics in the koogeek plugin is not available yet.

What i meant by my last update was just that most of the work i needed to do to start working on this was done. There is still a bit more that needs to be done, but it's getting closer.

To be clear though, the plug itself should work (turn on/off etc) just can't report watt data?

pilot1981 commented 4 years ago

Yes

cwendigo commented 4 years ago

Hello all, I also would appreciate to be able to have this data, I have koogeek EU plugs and switches with power monitoring capabilities. Thank you in advance.

pilot1981 commented 4 years ago

hi @Jc2k , any news?

stale[bot] commented 4 years ago

There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates. Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment đź‘Ť This issue now has been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.

cwendigo commented 4 years ago

Hi @Jc2k, some time to take a look at this?? Thx!!

Jc2k commented 4 years ago

One day I hope!

pilot1981 commented 4 years ago

please @Jc2k let's try it!

Jc2k commented 4 years ago

So the plan is to create secondary entities for stuff like that. That's clean because it doesn't complicate the core switch entity with unrelated vendor specific crap. It's also in line with the preferred HA style for decomposing complex accessories into multiple entities that are linked via the device registry.

I spent time than I had, 200 lines in and its a bit more work than expected. More work is needed in aiohomekit to deal with vendor characteristic types (makes assumptions it shouldnt). And think I need to totally change how it handles creating entities too.

pilot1981 commented 4 years ago

Understood. In any case, Thanks a lot for your job @Jc2k!

Balok-Fesarius commented 3 years ago

Did the PR for this hit a snag?

Jc2k commented 3 years ago

It's waiting for a review. That can take a while.

cwendigo commented 3 years ago

great news here!! thx!!!

cwendigo commented 3 years ago

I know this issue is closed as we have now koogeek-O1EU real time entities but i can´t see those entities in my koogeek-SW2 or koogeek-DM switches.

Will be possible to add?

Jc2k commented 3 years ago

Please don't comment on closed tickets. This is a new new feature request. I do not have any of the devices mentioned so I will need you to provide an entity map (as discussed above). It's best not to raise gh tickets for new feature requests, ha policy is to post on the forums. But you can message me the map directly on the forums or via discord. I'm quite busy at the moment and until I've seen the map I can't till you if it's possible to do what you want, much less how easy it will be.