peterbuga / HASS-sonoff-ewelink

Home Assistant component to control Sonoff/eWeLink devices with original firmware
MIT License
791 stars 296 forks source link

Sonoff BASIC component hangs HA start #215

Closed ttecles closed 4 years ago

ttecles commented 4 years ago

Hi,

I downloaded the code and added to the folder but when I start the HA, it hangs on the following line:

de febr. 26 21:14:55 raspberrypi hass[3845]: 2020-02-26 21:14:55 INFO (MainThread) [homeassistant.setup] Setting up cloud
de febr. 26 21:14:55 raspberrypi hass[3845]: 2020-02-26 21:14:55 INFO (MainThread) [homeassistant.setup] Setup of domain recorder took 3.8 seconds.
de febr. 26 21:14:55 raspberrypi hass[3845]: 2020-02-26 21:14:55 INFO (MainThread) [homeassistant.setup] Setup of domain cloud took 0.1 seconds.
labachev commented 4 years ago

Same here, After update to HA Core 0.106 it says it can't find sonoff component.

peterbuga commented 4 years ago

@labachev did it worked before? simply update => not working anymore? trying to pinpoint if it's an install problem or braking change problem

labachev commented 4 years ago

@peterbuga : After update to 0.106.1 it cannot load the component. Error in log is: [homeassistant.components.homeassistant] Component error: sonoff - Integration 'sonoff' not found.

Dergonic commented 4 years ago

Same for me. Was ok when running 0.105.x bit not more while running 0.106.4.

Logs says :

Log Details (ERROR) Logger: homeassistant.setup First occured: 11:00:13 AM (1 occurences) Last logged: 11:00:13 AM

Setup failed for sonoff: Integration not found.

Files are still in custom_component folder and I check the whole config and it looks ok. I'm available if anyone need more info ;)

browetd commented 4 years ago

Probably the same issue on my side... I tried to transfer HA from one Raspberry PI4 to another one... I backup all the HA files from the old and restored everything on the new (I am running in a venv python 3.7.4 on the old one and 3.8.2 on the new one)... HA 0.106 on both ... Sonoff is running on the old one but not in the new environment... No error message, just HA stuck during startup (0% cpu used)... Maybe a Python issue due to a different version in the new environment or ... ? I checked the websocket clients, same version...
UPDATE: I re-installed python 3.7.4 instead of 3.8.2 on my test environment.... Same issue: home assistant seems to be stuck, it is active but nothing happens (If I remove sonoff from the configuration file, it runs correctly...) I don't know what is the difference between the two environment (prod and test)... Both are Raspberry pi 4B + 2GB in venv and Python 3.7.4

***** configuration.yaml `

default_config:

logger: default: debug

recorder: db_url: mysql://user:password@localhost/hass?charset=utf8 purge_keep_days: 10

http: server_port: 8124 base_url: https://myurl ssl_certificate: mycertificate ssl_key: mykey

group: !include groups.yaml automation: !include automations.yaml script: !include scripts.yaml scene: !include scenes.yaml

sonoff: username: myuser password: mypassword ` Pretty simple config file for test.... *** Now the content of home-assistant.log

2020-03-09 09:37:47 WARNING (MainThread) [homeassistant.loader] You are using a custom integration for hacs which has not been tested by Home Assistant. This component might cause stability problems, be sure to disable it if you do exper$ 2020-03-09 09:37:47 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event service_registered[L]: domain=logger, service=set_default_level> 2020-03-09 09:37:47 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event service_registered[L]: domain=logger, service=set_level> 2020-03-09 09:37:47 INFO (MainThread) [homeassistant.setup] Setup of domain logger took 0.0 seconds. 2020-03-09 09:37:47 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event component_loaded[L]: component=logger> 2020-03-09 09:37:47 INFO (MainThread) [homeassistant.setup] Setting up http 2020-03-09 09:37:47 INFO (MainThread) [homeassistant.setup] Setup of domain http took 0.0 seconds. 2020-03-09 09:37:47 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event component_loaded[L]: component=http> 2020-03-09 09:37:47 INFO (MainThread) [homeassistant.setup] Setting up system_log 2020-03-09 09:37:47 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event service_registered[L]: domain=system_log, service=clear> 2020-03-09 09:37:47 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event service_registered[L]: domain=system_log, service=write> 2020-03-09 09:37:47 INFO (MainThread) [homeassistant.setup] Setup of domain system_log took 0.0 seconds. 2020-03-09 09:37:47 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event component_loaded[L]: component=system_log> 2020-03-09 09:37:47 INFO (MainThread) [homeassistant.setup] Setting up recorder 2020-03-09 09:37:47 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event service_registered[L]: domain=recorder, service=purge> 2020-03-09 09:37:47 INFO (MainThread) [homeassistant.setup] Setting up webhook 2020-03-09 09:37:47 INFO (MainThread) [homeassistant.setup] Setup of domain webhook took 0.0 seconds. 2020-03-09 09:37:47 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event component_loaded[L]: component=webhook> 2020-03-09 09:37:47 INFO (SyncWorker_15) [homeassistant.loader] Loaded alexa from homeassistant.components.alexa 2020-03-09 09:37:47 INFO (SyncWorker_19) [homeassistant.loader] Loaded google_assistant from homeassistant.components.google_assistant 2020-03-09 09:37:47 INFO (SyncWorker_18) [homeassistant.loader] Loaded camera from homeassistant.components.camera 2020-03-09 09:37:47 INFO (SyncWorker_6) [homeassistant.loader] Loaded media_player from homeassistant.components.media_player 2020-03-09 09:37:47 WARNING (Recorder) [homeassistant.components.recorder] Ended unfinished session (id=11 from 2020-03-09 08:06:52) 2020-03-09 09:37:47 DEBUG (Recorder) [homeassistant.components.recorder] Connected to recorder database 2020-03-09 09:37:51 INFO (MainThread) [homeassistant.setup] Setting up cloud 2020-03-09 09:37:51 INFO (MainThread) [homeassistant.setup] Setup of domain recorder took 3.8 seconds. 2020-03-09 09:37:51 DEBUG (SyncWorker_13) [homeassistant.util.json] JSON file not found: /home/homeassistant/.homeassistant/.storage/cloud 2020-03-09 09:37:51 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event component_loaded[L]: component=recorder> 2020-03-09 09:37:51 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event service_registered[L]: domain=cloud, service=remote_connect> 2020-03-09 09:37:51 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event service_registered[L]: domain=cloud, service=remote_disconnect> 2020-03-09 09:37:51 INFO (MainThread) [homeassistant.setup] Setup of domain cloud took 0.0 seconds. 2020-03-09 09:37:51 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event component_loaded[L]: component=cloud>

****Status of the homeassistant service

`● homeassistant@homeassistant.service - Home Assistant Loaded: loaded (/etc/systemd/system/homeassistant@homeassistant.service; disabled; vendor preset: enabled) Active: active (running) since Mon 2020-03-09 11:45:44 CET; 1min 21s ago Process: 8743 ExecStartPre=/bin/sleep 15 (code=exited, status=0/SUCCESS) Main PID: 8775 (hass) Tasks: 23 (limit: 4035) Memory: 42.7M CGroup: /system.slice/system-homeassistant.slice/homeassistant@homeassistant.service └─8775 /srv/homeassistant/bin/python3 /srv/homeassistant/bin/hass -c /home/homeassistant/.homeassistant

Mar 09 11:45:46 browetpierre hass[8775]: 2020-03-09 11:45:46 WARNING (Recorder) [homeassistant.components.recorder] Ended unfinished session (id=13 from 2020-03-09 10:43:20) Mar 09 11:45:46 browetpierre hass[8775]: 2020-03-09 11:45:46 DEBUG (Recorder) [homeassistant.components.recorder] Connected to recorder database Mar 09 11:45:50 browetpierre hass[8775]: 2020-03-09 11:45:50 INFO (MainThread) [homeassistant.setup] Setting up cloud Mar 09 11:45:50 browetpierre hass[8775]: 2020-03-09 11:45:50 DEBUG (SyncWorker_3) [homeassistant.util.json] JSON file not found: /home/homeassistant/.homeassistant/.storage/cloud Mar 09 11:45:50 browetpierre hass[8775]: 2020-03-09 11:45:50 INFO (MainThread) [homeassistant.setup] Setup of domain recorder took 3.9 seconds. Mar 09 11:45:50 browetpierre hass[8775]: 2020-03-09 11:45:50 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event component_loaded[L]: component=recorder> Mar 09 11:45:50 browetpierre hass[8775]: 2020-03-09 11:45:50 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event service_registered[L]: domain=cloud, service=remote_connect> Mar 09 11:45:50 browetpierre hass[8775]: 2020-03-09 11:45:50 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event service_registered[L]: domain=cloud, service=remote_disconnect> Mar 09 11:45:50 browetpierre hass[8775]: 2020-03-09 11:45:50 INFO (MainThread) [homeassistant.setup] Setup of domain cloud took 0.0 seconds. Mar 09 11:45:50 browetpierre hass[8775]: 2020-03-09 11:45:50 DEBUG (MainThread) [homeassistant.core] Bus:Handling <Event component_loaded[L]: component=cloud>

*****Python

pi@raspberry:/home/homeassistant/.homeassistant $ python3 --version Python 3.7.4 pi@browetpierre:/home/homeassistant/.homeassistant $ python --version Python 2.7.16

`

browetd commented 4 years ago

SOLVED !!!?

I made some additional tests... I restored my initial test environment: HA 0.106.5 running in a venv with python 3.8.2 on a raspberry pi4B (2GB).

I added the file manifest.json in custom_components/sonoff with the following content:

{ "domain": "sonoff", "name": "Sonoff", "documentation": "https://github.com/peterbuga/HASS-sonoff-ewelink", "requirements": ["websocket-client==0.54.0"], "dependencies": [], "codeowners": ["@peterbuga"] }

IT IS WORKING FOR ME !!! SONOFF is finally loading... Check if this is not fixing your issue as well

Dergonic commented 4 years ago

Looks like I solved mine, but not sure how. Here is what I did (as far as I remember):

1- I applied @browetd solution and restated through Webinterface (I assume it only restarted the docker container) 2- As soon as it was still not working, I went deaper and read @browetd was speaking of Python3 while python was only 2.7.17 on my Hassio host. I Installed Python 3.7.5. 3- (I updated my SSL certificate which was expired - I don't know if it can be any important) 4- I restarted the whole HOST (sudo reboot on the docker host)

Then it is ok ! I have no idea which point solved the issue or if a combination of several. If any dev/pro need any other information, I'll be pleased to help.

KixMan28 commented 4 years ago

@browetd Thank you for the tip. it worked for me too. I just added the manifest.json file with the content you mentioned in the location you mentioned and restarted my HA. All my Sonoff appeared immediately.

browetd commented 4 years ago

I still don't understand why the same configuration (one created and upgraded for about a year) and the other one created this week-end from scratch have different behaviour with the same files (I did a full backup of the "upgraded" home assistant directory (/home/homeassistant) and restored it in the new environment before starting Home Assistant with the json file as explained)... Nevertheless, happy that this fix is helping... I am now in full prod with the new environment !

peterbuga commented 4 years ago

@browetd i assumed the manifest file might have something to do with it, although last time i check HA listed in their blog that custom components don't require this file ¯\_(ツ)_/¯

browetd commented 4 years ago

@peterbuga You are 100% correct, I checked this morning the documentation and it is still mentioned " It is required to add such a file, except for custom components."... Soooo.... ??? but for me it fixed the issue... Maybe if confirmed, the documentation should be updated if the statement about manifest.json file requirement is not true anymore...

ttecles commented 4 years ago

solved for me too! Great job @browetd

KixMan28 commented 4 years ago

Now this is strange. Yesterday I added the manifest.json file to my sonoff folder, because my Sonoff devices were not showing up in HA. Today my devices disappeared again. This time I removed the manifest.json file from the sonoff directory and the devices appeared again in HA.

x-Felix commented 4 years ago

I disabled sonoff component in configuration.yaml today before upgrading Hassio 3.12 to 3.13. After successfully upgraded to Hassio 3.13, I tried to enable sonoff components but failed with HA hangs. The last line of the 'ha core log' output is 2020-04-17 12:24:26 INFO (MainThread) [homeassistant.setup] Setting up sonoff Cannot run ha core restart at this stage, just with error. Have to do a power cycle after disabled sonoff component in configuration.yaml. Then it returns normal. Tried to delete the pycache file under sonoff custom_component folder, also tried put manifest.json file there, no use. All attempts with sonoff enabled in configuration.yaml hang HA start.

--Update: Seems like it get itself resolved. The only difference is my main NBN link is back online now. While I was on 4G backup mobile network, hassio 3.13 with sonoff component cannot start. No idea this component may have dependency on Internet connectivity?

peterbuga commented 4 years ago

@x-Felix

No idea this component may have dependency on Internet connectivity?

this component is STRICTLY using the internet connection, as it's simulates an ewelink app! i recommend to increase the scan_interval to a higher value (600-1800) if you're stuck to a limited 4G connection, this value is more like a fallback-status-update. most of the updates are done via websockets