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

Pros:

  • work with original Sonoff firmware
  • work over local network (LAN)
  • work with devices without DIY-mode
  • work with devices in DIY-mode
  • support single and multi-channel devices
  • support TH and POW device attributes
  • support Sonoff RF Bridge 433 for receive and send commands
  • instant device state update with Multicast
  • (optional) get devices list from eWeLink servers (with names and apikey/devicekey) and save it locally
  • (optional) change device type (switch, light or fan)
  • (optional) set multi-channel device as one light with brightness control

Link to component:

15 Likes

Works with pow r2 ?

Yes, works.

This looks really promising. I’m going to try it.
Thanks!

2 Likes

In your last update sonoff POW r2 stop working Unknown device_class 1000853db7

9:40 custom_components/sonoff/init.py (ER

@nelsonamen oh, sorry. I added fix to this situation.

Could you enable DEBUG log and see what type the device sends?

Properties: {'txtvers': '1', 'id': '1000123456', 'type': 'strip', 'apivers': '1'...

its working now thanks!!

i dont now if is this but i will paste it

2020-02-12 15:20:23 DEBUG (zeroconf-ServiceBrowser__ewelink._tcp.local.) [custom_components.sonoff] Add service eWeLink_1000853db7._ewelink._tcp.local.
2020-02-12 15:20:23 DEBUG (zeroconf-ServiceBrowser__ewelink._tcp.local.) [custom_components.sonoff] Properties: {‘txtvers’: ‘1’, ‘id’: ‘1000853db7’, ‘type’: ‘enhanced_plug’, ‘apivers’: ‘1’, ‘seq’: ‘9’, ‘encrypt’: True, ‘iv’: ‘Nzc5NDk4OTA3OTY4NDU3NQ==’, ‘data1’: ‘jRmv9EECOl+wAw91ULod/kZPTOIDPlLR0l0TCCMxjzsxYMvDOxlsL2UOoaxoPvWxapUwLNLFRSbjJhF3nVYRsYyjLuIgu+SeywM2jlNM1E2jTS1VoGSoZeFcKmDI2ougvJjjqIzWoIfwd3In0EYVMuOgDy0Jz8lwpbh0tDPJnJjgFYjGi1/cqQ5x8+4TMmyyHAnJoQwj8gmeczoIHrvoaYbsgrSTbS+YETUtMjbEgohu8dLi67NgiFAG3’, ‘data2’: ‘ikMbYz+’}
2020-02-12 15:20:23 DEBUG (zeroconf-ServiceBrowser__ewelink._tcp.local.) [custom_components.sonoff] State: {‘alarmVValue’: [-1, -1], ‘alarmCValue’: [-1, -1], ‘alarmPValue’: [-1, -1], ‘switch’: ‘on’, ‘startup’: ‘on’, ‘pulse’: ‘off’, ‘pulseWidth’: 500, ‘sledOnline’: ‘off’, ‘power’: 0, ‘voltage’: 231.61, ‘current’: 0}
2020-02-12 15:20:23 DEBUG (zeroconf-ServiceBrowser__ewelink._tcp.local.) [custom_components.sonoff] Add service eWeLink_100072b9cd._ewelink._tcp.local.
2020-02-12 15:20:23 DEBUG (zeroconf-ServiceBrowser__ewelink._tcp.local.) [custom_components.sonoff] Properties: {‘txtvers’: ‘1’, ‘id’: ‘100072b9cd’, ‘type’: ‘enhanced_plug’, ‘apivers’: ‘1’, ‘seq’: ‘18’, ‘encrypt’: True, ‘iv’: ‘Mjc4NjU3NjAyODA2NDk2Mw==’, ‘data1’: ‘Q73kan8eJeo4ZKalCIyruLunclKOMSlKQ4n3tfsg8P8cmsrP1nanvTVQjz1pNvAhXIaZsnzxUBDlDi/e5mEZkOscbDvDB85NlM2VdFk0zyL4FcpIUBg8fygxHlayaed+ybmSyXzwe5Bh883H18U6Mcxl4It7jpKLQGN0rU7D7vDKkE3Y9kmCWXF6nP6KqvFBi5p29jsqpOZqA1y46I3+3s7RI5QpX4hXmcFAn3kgpeDEB0Hx6bYXFc2Mk’, ‘data2’: ‘a+LRVRw’}
2020-02-12 15:20:23 DEBUG (zeroconf-ServiceBrowser__ewelink._tcp.local.) [custom_components.sonoff] State: {‘alarmVValue’: [-1, -1], ‘alarmCValue’: [-1, -1], ‘alarmPValue’: [-1, -1], ‘switch’: ‘on’, ‘startup’: ‘on’, ‘pulse’: ‘off’, ‘pulseWidth’: 500, ‘sledOnline’: ‘on’, ‘power’: 0, ‘voltage’: 230.86, ‘current’: 0}
2020-02-12 15:20:23 DEBUG (zeroconf-ServiceBrowser__ewelink._tcp.local.) [custom_components.sonoff] Add service eWeLink_1000686bc0._ewelink._tcp.local.
2020-02-12 15:20:23 DEBUG (zeroconf-ServiceBrowser__ewelink._tcp.local.) [custom_components.sonoff] Properties: {‘txtvers’: ‘1’, ‘id’: ‘1000686bc0’, ‘type’: ‘plug’, ‘apivers’: ‘1’, ‘seq’: ‘25’, ‘encrypt’: True, ‘iv’: ‘NTE2OTk4MDc3Mjc5NTIwNQ==’, ‘data1’: ‘O1QhwMsc0/d9g4PGZxkqKQ5gpQRd4Tk6F2OmqCxrLQnpfujTDofunH3pUtebG06bQ+RzSS2q4Yz6BwvKHh7SaC3bkHXRufPNwZfX2ztG1jM+D9NaevYRt6VQfIP1yMv9’}
2020-02-12 15:20:23 DEBUG (zeroconf-ServiceBrowser__ewelink._tcp.local.) [custom_components.sonoff] State: {‘switch’: ‘off’, ‘startup’: ‘off’, ‘pulse’: ‘off’, ‘sledOnline’: ‘off’, ‘pulseWidth’: 500, ‘rssi’: -59}
2020-02-12 15:20:23 INFO (MainThread) [homeassistant.setup] Setting up alexa_media

why the power never work

[switch.sonoff_100072b9cd state: on power: 0

Thanks. I was looking for enhanced_plug. I didn’t think that there are so many types of devices.

new update works!!
the (power: 0) state do not work.

I see that the device always sends power 0. I do not know why. I do not have this sonoff. Maybe other users will tell what is displayed on their device.

Hi!
Has anyone with a sonoff pow r2 (with the latest version) checked whether the data on power/voltage/amps are constantly updated? At the moment I am using the integration of peterburga and I was wondering if with this integration was possible to solve this problem!

No support of sonoff bridge binary sensors like smoke detector or movement detector? In this project there is support of binary sensors https://github.com/peterbuga/HASS-sonoff-ewelink

Thank you for getting this setup for us! I love when a component is improved! So far so good on my end.

Thanks again for the work you put into this!

1 Like

@evgenfed I don’t have smoke detector or movement detector. Only RF buttons / switches and RF bridge. I do not know how they should work.

@AlexxIT, I think you can take any RF button and set up it as alarm sensor in sonoff bridge for testing. May be implement code from peterburga project (file binary_sensor.py).

@evgenfed Found implementation in branch dev. I’ll see what can be done.

Great piece of work, local sonoff interaction!!
i was using the adding written by @peterbuga which off the bat seemed to handle the TH sesnors as seperate entities, and as such displayed then on the lovelace screen ( e.g a senor showing temp and one for humidity)
with this addin it seems to have gone, i can see in entity the switch.sonoff.XXXXxX and its releated attributes
humidity: 60
temperature: 19
friendly_name: Bathroom Extractor Fan
supported_features: 0

yet i am having trouble using the attributes in any automations.

as the below no longer works

alias: Switch Bathroom Fan Off
description: Humidity drops below 55%
trigger:

  • below: ‘55’
    entity_id: switch.sonoff_xxxxxxxx
    platform: numeric_state
    value_template: humidity
    condition: []
    action:
  • data:
    entity_id: switch.sonoff_xxxxxxxx
    entity_id: switch.sonoff_xxxxxxx
    service: switch.turn_off

any ideas?
many thanks
Mark

@Markymark you can read readme.

i have, and although i can get the sensor in lovelace i can’t use it as a trigger ( i assume it’s a formatting of syntax )
as far as i can tell i need it still to be a numeric_state
i’ve tried calling the actual switch and the humidity sensor as the entity_id
in value template and the FOR statement i have put “{{ state_attr(’‘switch.sonoff_10004b2680’’, ‘‘humidity’’) }}”

with varing combinations of removing the " and stripping out state_attr

i’m drawing a blank.

has anyone got any ideas?

Great project Alexx. Thanks for the great work. Does it work also with Sonoff T1 or T2 light switch?