Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sonoff Dw2 Wifi - State update issue. After a few seconds close or open it shows unavaliable until it open or close again #232

Closed
DavidFFerreira opened this issue Sep 7, 2020 · 16 comments
Labels
enhancement New feature or request

Comments

@DavidFFerreira
Copy link

Sonoff Dw2 Wifi - State update issue. After a few seconds close or open it shows unavaliable until it open or close again, but after that it goes unavaliable again (because the device enters in sleep mode) It shoud shows lastOnlineState

@wishie
Copy link

wishie commented Sep 9, 2020

This is the nature of the beast. It's trying to save power. The DW2 is horrible. I replaced all mine with the new ZigBee ones

@kao16
Copy link

kao16 commented Sep 14, 2020

Is it possible to create an object that saves the last state (on or off) of the sensor, ignoring the "Unavaliable" state?

@wishie
Copy link

wishie commented Sep 14, 2020

Is it possible to create an object that saves the last state (on or off) of the sensor, ignoring the "Unavaliable" state?

Yes, this is possible in HA, but it still doesn't solve the slow response times of the switches. I've seen them take up to 1-2hrs to register a change sometimes. Hopeless things.

Seriously, cut your losses and get the SNZB-04 and the ZBBridge instead.

@DavidFFerreira
Copy link
Author

Mine is working fine with dw2, you can get last state from database ignoring the unavaiable and unknow

  • platform: sql
    db_url: !secret db_url
    queries:
    • name: Sonoff_GetLastState
      query: >
      SELECT state
      FROM states
      WHERE entity_id like '%sonoff_1000e0ed27%' -- Put here your sonoff entity
      AND state NOT IN ( 'unavailable', 'unknown')
      ORDER BY Last_Updated desc
      LIMIT 1;
      column: 'state'

@DavidFFerreira
Copy link
Author

then you can create a binary using the data that you collet

binary_sensor:

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

@kao16
Copy link

kao16 commented Sep 14, 2020

then you can create a binary using the data that you collet

binary_sensor:

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

Thanks! Will try it soon. I bought 10 of those and i thought i was stuck, since sonoff now requires a paid service for IFTTT (and IFTTT went pay-to-actually-use-it) and that was what make me search for alternatives, thats how i started Home assistant stuff

@AlexxIT
Copy link
Owner

AlexxIT commented Sep 14, 2020

Maybe your router can't handle 10 extra wifi devices

@kao16
Copy link

kao16 commented Sep 14, 2020

Maybe your router can't handle 10 extra wifi devices

2 of them are for my house and 8 for my bussiness, No problem so far

@kao16
Copy link

kao16 commented Sep 16, 2020

Mine is working fine with dw2, you can get last state from database ignoring the unavaiable and unknow

  • platform: sql
    db_url: !secret db_url
    queries:

    • name: Sonoff_GetLastState
      query: >
      SELECT state
      FROM states
      WHERE entity_id like '%sonoff_1000e0ed27%' -- Put here your sonoff entity
      AND state NOT IN ( 'unavailable', 'unknown')
      ORDER BY Last_Updated desc
      LIMIT 1;
      column: 'state'

Sorry if this is obvious, but how do i use the database? I've created the binary sensor and wited the SQL int configuration, but it appears always closed, it is not actualizing the state

@AlexxIT AlexxIT added the enhancement New feature or request label Jan 31, 2021
@TTLucian
Copy link

TTLucian commented Feb 6, 2021

Hi. My 4 DW2 WiFi sensors work fine. I think the power saving issue was solved in latest firmware upgrade. Only problem is that they show as unavailable after home assistant start or restart. They work fine after triggering them once (open or close) after HA has loaded.

@AlexxIT
Copy link
Owner

AlexxIT commented Feb 6, 2021

Can you send debug log? I'm interesting in init setup lines for this sensor

@TTLucian
Copy link

TTLucian commented Feb 6, 2021

Init, open and close (removed api key):

2021-02-06 18:20:36 DEBUG (MainThread) [custom_components.sonoff] 1000f168bc == Init   | {'uiid': 102, 'extra': {'manufacturer': 'SONOFF', 'model': 'DW2', 'sw_version': 'OPL-DMA-GL v1000.2.924'}, 'params': {'bindInfos': {'alexa': [''---------'], 'gaction': [''---------_ewelinkGoogleHome'], 'miot': [''---------_ewelink-miot-v1'], 'scene': 1}, 'switch': 'off', 'battery': 2.641, 'fwVersion': '1000.2.924', 'type': 4, 'chipID': 'd02701e2cec8', 'mac': 'd02701e2cec8', 'rssi': -61, 'lastUpdateTime': '2021-02-06T16:14:06.614Z', 'actionTime': '2021-02-06T16:12:32.821Z', 'cloud': 'offline'}}

2021-02-06 18:20:36 DEBUG (MainThread) [custom_components.sonoff] 1000f16272 == Init   | {'uiid': 102, 'extra': {'manufacturer': 'SONOFF', 'model': 'DW2', 'sw_version': 'OPL-DMA-GL v1000.2.924'}, 'params': {'bindInfos': {'alexa': ['''---------'], 'gaction': ['''---------_ewelinkGoogleHome'], 'miot': ['''---------_ewelink-miot-v1'], 'scene': 1}, 'switch': 'on', 'battery': 2.902, 'fwVersion': '1000.2.924', 'type': 2, 'chipID': 'd02701e2c234', 'mac': 'd02701e2c234', 'rssi': -76, 'lastUpdateTime': '2021-02-06T16:20:35.331Z', 'actionTime': '2021-02-06T16:20:35.331Z', 'cloud': 'offline'}}

2021-02-06 18:20:36 DEBUG (MainThread) [custom_components.sonoff] 1000f163f6 == Init   | {'uiid': 102, 'extra': {'manufacturer': 'SONOFF', 'model': 'DW2', 'sw_version': 'OPL-DMA-GL v1000.2.924'}, 'params': {'bindInfos': {'gaction': ['''---------_ewelinkGoogleHome'], 'miot': ['''---------_ewelink-miot-v1'], 'alexa': ['''---------']}, 'switch': 'off', 'battery': 2.742, 'fwVersion': '1000.2.924', 'type': 4, 'chipID': 'd02701e2c53c', 'mac': 'd02701e2c53c', 'rssi': -83, 'lastUpdateTime': '2021-02-06T16:01:29.341Z', 'actionTime': '2021-02-06T12:44:39.095Z', 'cloud': 'offline'}}

2021-02-06 18:20:36 DEBUG (MainThread) [custom_components.sonoff] 1000f1668a == Init   | {'uiid': 102, 'extra': {'manufacturer': 'SONOFF', 'model': 'DW2', 'sw_version': 'OPL-DMA-GL v1000.2.924'}, 'params': {'bindInfos': {'alexa': [''''---------'], 'gaction': [''''---------_ewelinkGoogleHome'], 'miot': [''''---------_ewelink-miot-v1'], 'scene': 1}, 'switch': 'off', 'battery': 2.747, 'fwVersion': '1000.2.924', 'type': 4, 'chipID': 'd02701e2ca64', 'mac': 'd02701e2ca64', 'rssi': -63, 'lastUpdateTime': '2021-02-06T15:55:45.930Z', 'actionTime': '2021-02-06T15:25:04.365Z', 'cloud': 'offline'}}


2021-02-06 18:23:38 DEBUG (MainThread) [custom_components.sonoff.sonoff_cloud] 1000f168bc <= Cloud3 | {'action': 'update', 'deviceid': '1000f168bc', 'apikey': ''---------', 'userAgent': 'device', 'd_seq': 1612628618233, 'params': {'switch': 'on', 'battery': 2.661, 'fwVersion': '1000.2.924', 'type': 2, 'chipID': 'd02701e2cec8', 'mac': 'd02701e2cec8', 'rssi': -61, 'lastUpdateTime': '2021-02-06T16:23:38.229Z', 'actionTime': '2021-02-06T16:23:38.229Z'}, 'from': 'device'}

2021-02-06 18:23:41 DEBUG (MainThread) [custom_components.sonoff.sonoff_cloud] 1000f168bc <= Cloud3 | {'action': 'update', 'deviceid': '1000f168bc', 'apikey': ''---------', 'userAgent': 'device', 'd_seq': 1612628621694, 'params': {'switch': 'off', 'battery': 2.644, 'fwVersion': '1000.2.924', 'type': 3, 'chipID': 'd02701e2cec8', 'mac': 'd02701e2cec8', 'rssi': -61, 'lastUpdateTime': '2021-02-06T16:23:41.690Z', 'actionTime': '2021-02-06T16:23:41.690Z'}, 'from': 'device'}

@AlexxIT
Copy link
Owner

AlexxIT commented Feb 8, 2021

The cloud tells the device is offline. eWeLink guys should fix it.

@emeyedeejay
Copy link

The "unavailable issues" are all Sonoff service-related (other than the "unavailable" after a restart.

The DW2 is not like the other Sonoff devices which can be controlled by your LAN (LAN control) ... the DW2 has no LAN control option at all - it needs to speak to the Sonoff backend to report open, closed etc. This also means that if your internet is down, these won't work.

So frustrating because they are great devices - in principle.

@AlexxIT
Copy link
Owner

AlexxIT commented Feb 18, 2021

Better to use battery devices on Zigbee or Bluetooth protocols.

@emeyedeejay
Copy link

Yeah - I'm beginning to see that. Mine are actually working very well right now. They need to enable LAN control/reporting on them then their serviceability will increase.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

6 participants