Sonoff /eWeLink component for original firmware

Amazing work going on! :slight_smile:

Hello,

i have problem with HASSIO 0.84.3 and component. I try it, but still error.

2018-12-22 16:02:40 WARNING (MainThread) [homeassistant.loader] You are using a custom component for 
sonoff which has not been tested by Home Assistant. This component might cause stability problems, be sure 
to disable it if you do experience issues with Home Assistant.
2018-12-22 16:02:40 ERROR (MainThread) [homeassistant.setup] Error during setup of component sonoff
Traceback (most recent call last):
File "/usr/local/lib/python3.6/site-packages/homeassistant/setup.py", line 148, in _async_setup_component
component.setup, hass, processed_config)  # type: ignore
AttributeError: module 'custom_components.sonoff' has no attribute 'setup'

Any idea?

@Bojkas this is a pretty uncommon error, after a quick google-ing some people reported that it might be due to python3.6 version. a shot in the dark, but if you have python3.5+ installed can you try to start HA using this version as a test ?

Im not sure, how do that. :frowning: I have only this version and one SD card.

Hello there,
Thanks for this, its exactly what i was looking for;
but i am getting an error: “Couldn’t authenticate using the provided credentials!”, what type of quote does the username and password have to be in?, or is this a known issue ?

Thanks

nevermind, i figured it out, it seems that you have to add another zero after the country code

1 Like

Is the HT-TH31 sonoff switch supported?

As a switch it should works. not sensor.

I followed the instructions for copying sonoff.py file (size 16kb) into the custom_components folder and created the switch folder and copied the sonoff.py file to 2kb size. In confg create code
sonoff:
username: ‘+8493252556’
password: ‘123456’
scan_interval: 60
grace_period: 600
api_region: ‘vn’
But hass.io invalid config message
The following components and platforms could not be set up:
sonoff
Please check your config


the instruction of how to, folder and files structure.
## Setup

To setup add to your configuration.yaml:

sonoff: username: [email or phone number] password: [password] scan_interval: 60 (optional) grace_period: 600 (optional) api_region: 'eu' (optional)

And copy the *.py files in  `custom_components`  folder using the same structure like defined here:

```
 custom_components
    ├── sonoff.py
    └── switch
        └── sonoff.py
```

for your setting. username: I’m not sure if you need a + in front of phone number (I use email) and the api_region: If you are in Asia like mine. I use ‘as’

thank you very much! I edited api_region: ‘vn’ into api_region:‘ as ’and works well

Hello,

i have no errors anymore, but nothnig show. What should happen? Should a sonoff button be added automatically, or do I have to do something other than copy files and configuration.yaml?

@Bojkas they should show up automatically in dashboard, or alternatively you can search them by switch. in the developer entities list section.
let me know what sonoff devices you have exactly, they might be incompatible. (also, what did you used to get over the error reported above?)

I had a similar set up to you, using input boolean with IFTTT.

Thanks Peter, this way works perfect and ties in better.

I do not know how, but Somfy.py was empty in custom_component. I has copy again and have no error.
In dashboard nothing new.
In DEV have only switch.turn_on/off/toggle.

I have Sonoff T1 2-gang EU, FW 2.7.0, eWelik 3.5.5. Hassio 0.84.6.

@Bojkas it should work I’m not sure what is happening on your side :frowning: please enable the debug for sonoff component as mentioned here and watch for any output regarding this.

you could also use sonoff-debug to help me with some more info

Hi,

I have this error:

2018-12-27 12:15:07 ERROR (MainThread) [homeassistant.components.switch] Error while setting up platform sonoff
Traceback (most recent call last):
File “/usr/src/app/homeassistant/helpers/entity_platform.py”, line 124, in _async_setup_platform
task = async_create_setup_task()
File “/usr/src/app/homeassistant/helpers/entity_platform.py”, line 89, in async_create_setup_task
None, platform.setup_platform, hass, platform_config,
AttributeError: module ‘custom_components.switch.sonoff’ has no attribute ‘setup_platform’

Ubuntu 18.04 + docker + total noob.
i checked using sonoff-debug and it returned all of my devices along with their schedules that I have setup.

Help, please

@chunqrinq the same error has been reported a few posts above as a result of a faulty copy-paste of some sorts. please double check if both sonoff.py files contents inside your HA install match the ones from the github

Hi,

I have tried downloading the raw file and copy-pasted the content of sonoff.py and checked the content of the file, and I am sure both have identical content.
I have sonoff.py in custom_components and custom_components/switch directories.

However, all give me the same error.

In comparing the log error, Bojkas had ‘custom_components.sonoff’ while I had ‘custom_components.switch.sonoff’.
Does this lead somewhere? Thx.

@chunqrinq I might not understand properly but I think you didn’t copied properly the files: there are 2 different sonoff.py and switch\sonoff.py files (i know the naming is a bit tricky, but try to follow the structure presented in github project) so please make sure both files from the project are exactly the same on your side. the error could imply that you copied the root-sonoff.py file in switch\sonoff.py folder also which is wrong!