cozylife / hass_cozylife_local_pull

home asstiant plugin
81 stars 35 forks source link

This repo is buggy yet #1

Open yuqianma opened 2 years ago

yuqianma commented 2 years ago

I cannot find any device in HA.

Debugging udp_discover.py alone on my laptop in the same lan, the result of get_ip() is always []. I have a ESP32 switch, paired in the CozyLife app through wifi. It works well in the app. Any idea?

yuqianma commented 2 years ago

Not a python & socket stuff expert. Here are two finds FYI:

1

get_ip() may get timeout before real data. Adding retries before break solves the bug.

2

https://github.com/cozylife/hass_cozylife_local_pull/blob/87e4a99643cf726b17adda6a6df5d98205910a22/custom_components/hass_cozylife_local_pull/utils.py?_pjax=%23js-repo-pjax-container%2C%20div%5Bitemtype%3D%22http%3A%2F%2Fschema.org%2FSoftwareSourceCode%22%5D%20main%2C%20%5Bdata-pjax-container%5D#L43

After python 3.9 there's no encoding='utf-8'. Just remove it.

But I cannot figure out how to make the device show in my HA yet...

yuqianma commented 2 years ago

image

cozylife commented 2 years ago

Hi. Please try to run from the command line

cd hass_cozylife_local_pull/custom_components/hass_cozylife_local_pull
python test.py
yuqianma commented 2 years ago

@cozylife I did similar step and fix the first bug by adding retries as I wrote. So there are 3 bugs above. At least the last two are not related to specific network. Can you tell me how can you use this component to add a switch for example? Since it does not have a unique ID.

yuqianma commented 2 years ago

May open a PR this weekend. But I wonder if you have used it really.

cozylife commented 2 years ago

It can be used on my hass. You can submit a hass log or PR.

cozylife commented 2 years ago

Please refer to this video https://user-images.githubusercontent.com/81341241/144952264-c61a89e1-2ac9-4dc4-8f9b-ac69dd26152c.mp4

soubhik-khan commented 2 years ago

Please refer to this video https://user-images.githubusercontent.com/81341241/144952264-c61a89e1-2ac9-4dc4-8f9b-ac69dd26152c.mp4

I have my bulb on the network and when I run the test.py, I can see the ip address of the bulb! @cozylife Can you share how did you add the switch on the hass? I can't find the device entity.

Screen Shot 2021-12-07 at 9 58 14 AM
cozylife commented 2 years ago

Please refer to this video https://user-images.githubusercontent.com/81341241/144952264-c61a89e1-2ac9-4dc4-8f9b-ac69dd26152c.mp4

I have my bulb on the network and when I run the test.py, I can see the ip address of the bulb! @cozylife Can you share how did you add the switch on the hass? I can't find the device entity. Screen Shot 2021-12-07 at 9 58 14 AM

you only need to ensure that hass_cozylife_local_pull is running in hass, then it will automatically discover the device and display it on the screen.

soubhik-khan commented 2 years ago

Please refer to this video https://user-images.githubusercontent.com/81341241/144952264-c61a89e1-2ac9-4dc4-8f9b-ac69dd26152c.mp4

I have my bulb on the network and when I run the test.py, I can see the ip address of the bulb! @cozylife Can you share how did you add the switch on the hass? I can't find the device entity.

you only need to ensure that hass_cozylife_local_pull is running in hass, then it will automatically discover the device and display it on the screen.

So I can see the ip address of the bulb when I run the test.py - which means hass_cozylife_local_pull is running. But the device is not auto discovered. Can you share the screenshot when you click the settings icon for your lovelace card? Would love to see how the entity name appears on hass.

cozylife commented 2 years ago

Please refer to this video https://user-images.githubusercontent.com/81341241/144952264-c61a89e1-2ac9-4dc4-8f9b-ac69dd26152c.mp4

I have my bulb on the network and when I run the test.py, I can see the ip address of the bulb! @cozylife Can you share how did you add the switch on the hass? I can't find the device entity.

you only need to ensure that hass_cozylife_local_pull is running in hass, then it will automatically discover the device and display it on the screen.

So I can see the ip address of the bulb when I run the test.py - which means hass_cozylife_local_pull is running. But the device is not auto discovered. Can you share the screenshot when you click the settings icon for your lovelace card? Would love to see how the entity name appears on hass. hass_cozylife_local_pull.log Please check my log.

cozylife commented 2 years ago

image I fixed this problem, please git pull hass_light_entity

yuqianma commented 2 years ago

image I fixed this problem, please git pull hass_light_entity

Great! BTW what's your HA sys info?

cozylife commented 2 years ago

OS:Ubuntu 20.04.3 LTS HASS:Home Assistant 2021.10.7 hassconfig

yuqianma commented 2 years ago

I still deem it not a usable component. Only a demo.

After I unplug and plug the device again, they cannot be manipulate in HA. The only way is to restart core to let the compoent run again. More, the entity id is not related to MAC address or other stable info. It may cause chaos after wifi restart or device remove.

(Other problem is that UDP broadcast cannot receive response from the device after a day. But unicast to the ip directly runs well. I have to restart my wifi to get them back. Not sure if it's my network's issue.)

cozylife commented 2 years ago

I still deem it not a usable component. Only a demo.

After I unplug and plug the device again, they cannot be manipulate in HA. The only way is to restart core to let the compoent run again. More, the entity id is not related to MAC address or other stable info. It may cause chaos after wifi restart or device remove.

(Other problem is that UDP broadcast cannot receive response from the device after a day. But unicast to the ip directly runs well. I have to restart my wifi to get them back. Not sure if it's my network's issue.)

I will upgrade this version, currently only 0.1.0. I will continue to update.

soubhik-khan commented 2 years ago

Unfortunately I have no luck in discovering the device yet!

cozylife commented 2 years ago

Unfortunately I have no luck in discovering the device yet! configuration.yaml 图片 Please retry.

yangqian commented 2 years ago

ive response from the device after a day. But unicast to the ip directly runs well. I have to restart my wifi to get th

See below for a third-party custom component of the cozylife light. I believe it fixes many of the issues. https://github.com/yangqian/hass-cozylife

yuqianma commented 2 years ago

@yangqian Awesome!