peterbuga / HASS-sonoff-ewelink

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

sonoff Dw2 support?! #251

Open DavidFFerreira opened 4 years ago

DavidFFerreira commented 4 years ago

sonoff Dw2 support?! Can you please add support for this?

alexwohlbruck commented 4 years ago

Looking for this too. Purchased the DW2 instead of the zigbee equivalent SNZB-04, and I don't want to mess with firmware flashing. May just start a return unless supporting these is trivial.

Home assistant will detect the state quickly whenever it changes, but then a few seconds later it changes to unavailable. Can anyone explain?

DavidFFerreira commented 4 years ago

@alexwohlbruck I found a way to have the Dw2 working fine in my HA Usigng Log as data support

sensor:

sonoff: username: !@Secret Username password: !@Secret Password scan_interval: 60 #(optional, lower values than 60 won't work anymore!) grace_period: 600 #(optional) api_region: 'eu' #(optional) entity_prefix: True #(optional) debug: False #(optional)

binary_sensor:

After that you can use your Binary sensor for

FairozJaf commented 3 years ago

@alexwohlbruck I found a way to have the Dw2 working fine in my HA Usigng Log as data support

sensor:

  • platform: sql db_url: !secret db_url queries:
  • name: Sonoff_GetLastState query: > SELECT state FROM "states" WHERE entity_id = 'switch.sonoff_1000e0ed27' AND state NOT IN ( 'unavailable', 'unknown') ORDER BY Last_Updated desc LIMIT 1; column: 'state'

sonoff: username: !@secret Username password: !@secret Password scan_interval: 60 #(optional, lower values than 60 won't work anymore!) grace_period: 600 #(optional) api_region: 'eu' #(optional) entity_prefix: True #(optional) debug: False #(optional)

binary_sensor:

  • platform: template sensors: front_door: device_class: opening value_template: > {{ ((is_state('sensor.Sonoff_GetLastState', 'off')) and is_state('switch.sonoff_1000e0ed27', 'on')) or ((is_state('sensor.Sonoff_GetLastState', 'on')) and is_state('switch.sonoff_1000e0ed27', 'unavaliable')) }}

After that you can use your Binary sensor for

FairozJaf commented 3 years ago

@DavidFFerreira Thank you for the code. Please note that I'm new to HA and YAML. The code won't work. I think the alignment spaces are out. Can you please assist by repost or post a text file for download.

DavidFFerreira commented 3 years ago

Hi There, dont bother with this code, right now you can do a total integration with sonoff adon in HA. With works great and there is no need for that code anymore

FairozJaf commented 3 years ago

@DavidFFerreira Thank you. My 6 other sonoff devices works using HACS in HA. The DW2 does not. It does not come up in Entities. I guess I'll have to do some more trouble shooting. Regards

FairozJaf commented 3 years ago

Is anyone have a the same problem as me with the Sonoff DW2 not showing in Entities in HA? Also let me know if it works for you and how you got it to work. I now have 8 x Sonoff devices working with problems. It's just the DW 2 that's not working.

FelisucoVFR commented 3 years ago

DW2 only supports “easy” SSID passwords. Only regular characters and numbers.

FairozJaf commented 3 years ago

@FelisucoVFR Thank you. I checked. I don't have special characters for SSID. I can see the DW2 on the network and also ping it. It just does not appear in HA. All other sonoff devices appear fine. I might look at flashing it with Tasmota or something when i get time. regards

FelisucoVFR commented 3 years ago

Ahh, ok. So it is paired already. Give me some time and I will tell you how I did and how I made it holding the state even after a HA reboot. If I remember correct I did the search in the Development tools by the third column using “dw2”. Not at entity name, at the last column.

Regards

El 9 feb 2021, a las 6:29, FairozJaf notifications@github.com escribió:  @FelisucoVFR Thank you. I checked. I don't have special characters for SSID. I can see the DW2 on the network and also ping it. It just does not appear in HA. All other sonoff devices appear fine. I might look at flashing it with Tasmota or something when i get time. regards

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or unsubscribe.

FelisucoVFR commented 3 years ago

@FairozJaf

image

Here it is how I could find it. Not hard but at the begining I was just doing the search at entity column. Once you have this solved, you will want to make it keep the last known status as it use to loose it after a HA restart and sometimes itself, indicating unavailable instead, so let us know when you can find it to go to the next step.

FelisucoVFR commented 3 years ago

at Configuration.yaml:

`# Garaje DW2 WIFI Door sensor data

To keep the last useful state from DW2 Wifi

And the binary_sensor to get the state according last state recorded instead of the actual. Very usefull to know the state after a restart until it receives the actual which may take a long while:

binary_sensor:

Hope it works for you too. Just need to replace the "xxxxx" with your sensor data. I have found this solution around a few forums. It took me a while adapting it but after restarting HA it worked nice.

FairozJaf commented 3 years ago

Thank you @FelisucoVFR The DW2 does not appear in HA. I search everything. It works in the eWelink App.
I search as you suggested and also device ID. Used the browser text search for the whole page. I also deleted ".sonoff.json". New one created. I find the deviceid & name in the ".sonoff.json" file. but not anywhere in HA. I've got 10 other Sonoff Devices that work great. I'm really out of ideas.