Sonoff /eWeLink switch component for original firmware

sonoff
Tags: #<Tag:0x00007f4811acf458>

#61

Great @peterbuga. They were in the states section. I works fine!!! Can I change the name of it for a friendly one in customize? Another question, I have a 2ch geekcreit device linked. It should work too?


#62

Awesome, glad that it works ;)!

You can easily customize your entities either from built-in customize menu or from customize.yaml (which is pretty much the same thing).
Or, if by “customize”, you mean the name of the entity itself to be “switch.kitchen” for example, I’m still debating for this case. It has come to my attention that the names that don’t contain valid ascii characters (ex: chinese characters) don’t play nice with entities and i have to default back to device id instead, leaving everything a small mess.

Keep an eye on the project (I don’t have an ETA yet) I’m re-writing the component to rely completely on the websocket for all the to&from updates, it’ll be much faster, probably less cpu intensive and the changes will reflect almost instantly in HA.


#63

I’m unfamiliar with this device but if you can control it eWeLink app it should definitely work. If it’s not working please follow the guidelines for adding a new device mentioned in the 1st post.


#64

Hyped for this. :slight_smile:
Working pretty amazing with what the websocket branch has so far.

Also I think your decision to stick with deviceid makes sense.
That way the automations and homekit integration is not affected.


#65

It has two switches but I see only one switch in HA. I will connect it and check what happens
If you can integrate your project directly in home assistant core in future releases it would be great!


#66

@peterbuga I have tried to use sonoff-debug.py in a raspberry getting this message:
Traceback (most recent call last):
File “sonoff-debug.py”, line 87, in
devices_json = get_devices()
File “sonoff-debug.py”, line 69, in get_devices
headers.update({‘Authorization’ : 'Bearer ’ + user_details[‘at’]})
KeyError: ‘at’
Do you know what it means?


#67

@jgyoldi most likely you provided wrong user and/or password :laughing: double check!
this is just a debug script, i didn’t spent too much time on it catching all the errors :confused:


#68

@peterbuga Finally I got it working and I have a device.json file with the information of the following device:


It appears at HA with your project as one single switch but it doesn´t work. How can I send you the devices.json containing it?

Regards.


#69

You can post contents of the file here or on GitHub as an issue.
He made sure all sensitive data is already removed.
Still feel free to go through the contents once
Thanks


#70

@peterbuga you’re about to receive a pleasant surprise. :slight_smile:


#71

Have been using the websocket branch with the changes in the pull request for about a day now.
Must I say it’s insanely fast!!
Like blows my mind every time it updates and changes state. :stuck_out_tongue:


#72

Running Hassio,
Assuming I did this properly maybe?

local/custom_components/sonoff

sonoff.py & .getmore files

and : local/custom_components/sonoff

sonoff.py

the added to the main config.yaml

sonoff:
  username: !secret sonoff_username
  password: !secret sonoff_password
  scan_interval: 60 
  grace_period: 600 
  api_region: 'eu'

getting a error : Component not found: sonoff

I must be missing something, any suggestions anyody?


#73

You would want to place the files in custom_components (already present within your /config folder, the folder that contains configuration.yaml) not local/custom_components

So your file structure should look like:

config/custom_components/sonoff.py
config/custom_components/switch/sonoff.py

Edit: Oh I misread your question. The files don’t need another folder called sonoff. Just add sonoff.py directly to custom_components and create a folder called switch (and place the other sonoff.py from github here)


#74

Yes that’s where I placed them, I was just showing the path I placed them in


#75

On Hassio for other custom components I had to place them in that folder ( ie ; Alexa.nedia_player, google_calendar etc.)


#76

Oh I misread your question. The files don’t need another folder called sonoff. Just add sonoff.py directly to custom_components and create a folder called switch (and place the other sonoff.py from github here)


#77

ok, ty I’ll give it a try


#78

@Corey_Maxim just as @forums2012 mentioned earlier you really do not need to create any folder called sonoff
if it makes things a bit clear, the only 2 files you need to have are like this:

custom_components/sonoff.py
custom_components/switch/sonoff.py

#79

ok, I was able to restart. do you know what might be causing this error?

Error during setup of component sonoff
Traceback (most recent call last):
File “/usr/local/lib/python3.6/site-packages/homeassistant/setup.py”, line 145, in _async_setup_component
hass, processed_config)
File “/config/custom_components/sonoff.py”, line 52, in async_setup
hass.data[DOMAIN] = Sonoff(config)
File “/config/custom_components/sonoff.py”, line 96, in init
self.do_login()
File “/config/custom_components/sonoff.py”, line 162, in do_login
self._bearer_token = resp[‘at’]
KeyError: ‘at’


#80

its hard to figure out the correct password on the app. I think maybe its that…