Control Sonoff Devices with eWeLink (original) firmware over LAN and/or Cloud

Ohh… could it be because I have the device in a IOT vlan and hass in another vlan? Interesting if thats it, cause all my other devices are also on that vlan and HA can see them… will do some more digging. Thanks for the help.

Its fixed :slight_smile:
image

Basically after trying several things, I’ve realized that I didn’t have the mdns enabled on my router :slight_smile:

It’s fixed now. Thanks

Hello… I have just installed Sonoff Lan via HACS in Home Assistant. I have updated th configuration.yaml file with my ewelink account info, but after restarting HA, I get the following errors in the logs? Have I missed something?

Can’t connect to eWeLink Cloud

1:34:54 PM – (WARNING) Sonoff (custom integration)

Login error: {‘error’: 404, ‘msg’: ‘user is not exit’}

1:34:54 PM – (ERROR) Sonoff (custom integration)

Hi. Is there also a link to install this via a custom repository in the Addon store?

Does anyone use this add-on?
If so, what are the advantages or disadvantages of the add-on
AlexxIT / SonoffLAN.

I don’t use the official Sonoff (=Ewelink) add-on, but the differences I know/read about:

  • Always uses “mixed” mode. Mostly uses local according to them, but uses cloud “if it needs to” (and you don’t control “when” or “how much” it needs to).
  • At the moment doesn’t support the dimmer (D1), fans (iFan03 and iFan 04-L) and camera (GK-200MP2-B). At least the camera is just a rebranded third-party camera and I wouldn’t be surprised if the other ones are too. That means they may never make it into the add-on (too much work for them)
  • Sonoff is a company, they need to make money. They are not making the add-on because they love their customers, they expect to make more money. If at any time they decide to only make certain features only available to users with a subscription, they can do so.

Personally I like to only buy Sonoff devices that are flashable with ESPHome/Tasmota (and most are), which in my opinion gives you the most control and can extend the devices with extra options in some cases.

I’ve been scratching my head for a couple of nights now. My automations stopped working. I realized that the problem was in the template (value_template) and that it didn’t get the temperature from my Sonoffs (TH16/10). Whereas i earlier accessed like so:
{{ state_attr('sensor.sonoff_xxxxxxxxxx_temperature', 'temperature') }}
it now needs to be:
{{ (state_attr('sensor.xxxxxxxxxx_t', 'state') | float) }}

Just posting in case somebody else also is scratching their head! :slight_smile:

This is a very helpful thread, thank you to all the contributors (especiallcy AlexxIT)! :slight_smile:

There is some problem with latest firmware TH16. Check issued on GitHub

I lost my TH:s again. I can se one in the developer tolls/states section, but it is unavailable.
I tried uninstalling and re-installing this (and other) components and all kinds og configurations, but to no avail…
Any ideas?

image

I am using it. So far only for Sonoff WiFI Bulb B02-B.
Installation and discovery went very smooth. I can switch on/off and control brightness and colour temperature.
Not all services for light are working (example: increase brightness: brightness_step) and I also cannot read attribute from the light with template (this: {{ states.light.10010aaa88 }} gives error - already made issue on github). If this issue will not be resolved quickly I consider to move to AlexxIT Add-on.

@ffkokkola - It seems that your sensor does not communicate with HA. Do you see it responding in eWLink app (or other Sonoff app which was dedicated to it) ?
I have issue with my Soboff WiFi Bulb but at leas HA can see it in the Developer panel and I can turn it on/off from HA. I cannot read attributes though… :frowning:
Still looking for solutiona.

@azel_inc, if possible you can talk as you made the call to the “sonoff.update_consumption” service.
I can’t get the consumption of my POW R2.

Happy New Year All, Sorry for the deleted post above, I hit enter too soon!

I am new to Sonoff/ewelink but have a lot of other smart home stuff and have been running HA for a couple of years. I have set up this integration with my new Sonoff Micro and it works well. I also have the new NSPanel on order and this should arrive next week and I am trying to work out how I can add widgets to it to control non ewelink device via HA without flashing. I am sure this integration will pick up the the 2 physical buttons fine and using this integration I am able to trigger HA automation based on the Sonoff micro switching on and off but doing it this way effectively renders the Micro unusable as a physical switch and will mean having to get physical “dummy” switches for each HA automation i want to do. So I have my thinking cap on and am looking for ideas please… :slightly_smiling_face:

One thing I thought was creating some sort of virtual device in ewelink but the only way I can see to do that is to create a one button remote. The integration sees this remote in HA as a binary sensor but it does not seem to pick up any state change, I even tried changing the device to a switch in HA config, it saw it as a switch then but still did not detect state change and it just went offline when the HA switch was operated.

Second idea is scenes, the plan would be to create different push button scenes in ewelink that just toggle the same physical Sonoff switch, the advantage being that multiple scenes would only tie up 1 physical device, however the integration does not seem to detect ewelink scenes in my cloud account :-(.

So, to my questions :slight_smile:

@AlexxIT is there any way to be able to detect scenes in HA please and if not could this functionality maybe be added in the future please?

Or does anyone have any other ideas that I haven’t thought about yet as I really don’t want to have to try and flash the panel or buy a bunch of dummy devices if i can avoid it.

Thanks Pete

1 Like

AlexxIT. Eres un crack. Enhorabuena. Acabo de guardar mi soldador y empezar a hacerte reverencias por tu trabajo . Gracias.

Hi Alexey,

first of all, let me thank you for the great work you’ve done with this component.

I have ordered 20 Sonoff TX T3 to replace all the switches I have in the house. I want to control all of them locally, not via ewelink cloud, but I wanted to avoid flashing tasmota etc. on each one of them if possible, and I found your work.

I have some questions before I receive the switches and prepare the installation:

  1. I read about the DYI mode here and it seems to be a good way for local management, but if I do this I would lose the autodiscovery of the devices, right? Reading your instructions, the only way to autodiscover is to pull info from the ewelink cloud, correct?

  2. In the instructions you refer to 2nd and 3rd firmware, etc. can the devices be upgraded to latest firmware?

  3. if I set DYI mode on all of the switches, will the component discover all of them locally without cloud, correct?

Thanks for any help you might give me on this.

Alessandro

OK so I received the NS panel today and as expected this fab integration picks up and can control the 2 physical switches with no flashing needed. So far the only way I have been able to trigger a HA automation is by using a Sonoff switch or plug with nothing connected to it. The panel toggles that and then the HA automation runs based on the switch/plug state change. Works great but not ideal as you need a spare physical switch for each widget/automation, but it does work!

Hi, since two days I permanently receive this notification:

Cloud mode cannot work simultaneously with two copies of component

My config did not change:

sonoff:
  username: !secret so_user # mail
  password: !secret so_pw

I definately run only one instance of HA.
I should have installed only one component :wink:
The switches work as normal.
What could be the issue?

I have this error in log:

Dieser Fehler wurde von einer benutzerdefinierten Integration verursacht

Logger: custom_components.sonoff.sonoff_cloud
Source: custom_components/sonoff/sonoff_cloud.py:149
Integration: Sonoff (documentation, issues)
First occurred: 09:01:48 (1 occurrences)
Last logged: 09:01:48

Coolkit API error: 0, message='Attempt to decode JSON with unexpected mimetype: text/html; charset=utf-8', url=URL('https://eu-api.coolkit.cc:8080/dispatch/app')
Traceback (most recent call last):
  File "/config/custom_components/sonoff/sonoff_cloud.py", line 149, in _api
    return await r.json()
  File "/usr/local/lib/python3.9/site-packages/aiohttp/client_reqrep.py", line 1097, in json
    raise ContentTypeError(
aiohttp.client_exceptions.ContentTypeError: 0, message='Attempt to decode JSON with unexpected mimetype: text/html; charset=utf-8', url=URL('https://eu-api.coolkit.cc:8080/dispatch/app')

Sonoff has been downtime of cloud servers for two days now

Ah, I already opened a GitHub issue.
Does that cause the following errors as well?

Dieser Fehler wurde von einer benutzerdefinierten Integration verursacht

Logger: custom_components.sonoff.sonoff_cloud
Source: custom_components/sonoff/sonoff_cloud.py:149
Integration: Sonoff (documentation, issues)
First occurred: 09:01:48 (1 occurrences)
Last logged: 09:01:48

Coolkit API error: 0, message='Attempt to decode JSON with unexpected mimetype: text/html; charset=utf-8', url=URL('https://eu-api.coolkit.cc:8080/dispatch/app')
Traceback (most recent call last):
  File "/config/custom_components/sonoff/sonoff_cloud.py", line 149, in _api
    return await r.json()
  File "/usr/local/lib/python3.9/site-packages/aiohttp/client_reqrep.py", line 1097, in json
    raise ContentTypeError(
aiohttp.client_exceptions.ContentTypeError: 0, message='Attempt to decode JSON with unexpected mimetype: text/html; charset=utf-8', url=URL('https://eu-api.coolkit.cc:8080/dispatch/app')

and

Dieser Fehler wurde von einer benutzerdefinierten Integration verursacht

Logger: custom_components.sonoff.sonoff_cloud
Source: custom_components/sonoff/sonoff_cloud.py:228
Integration: Sonoff (documentation, issues)
First occurred: 09:35:15 (2 occurrences)
Last logged: 09:40:27

Cloud WS exception: the JSON object must be str, bytes or bytearray, not NoneType
Traceback (most recent call last):
  File "/config/custom_components/sonoff/sonoff_cloud.py", line 228, in _connect
    resp = json.loads(msg.data)
  File "/usr/local/lib/python3.9/json/__init__.py", line 339, in loads
    raise TypeError(f'the JSON object must be str, bytes or bytearray, '
TypeError: the JSON object must be str, bytes or bytearray, not NoneType

The Sonoff/eWeLink app has been struggling to see my various devices. Availability is patchy at best.

Local control still works ok via HA and AlexxIT’s custom integration, but I have a Sonoff L1 that isn’t capable of local control, and that’s been unavailable for the last 24 hours or so in HA.

Does anyone know of an availability/status page etc. for Sonoff/eWeLink?

Luke