Sonoff DW1 433Mhz door/window sensor - Low battery warning capable?

Hi all,
I testing out a Sonoff DW1 433Mhz door sensor (AKA CD100S sensor) to HA via a reflashed Sonoff 433Mhz RF Bridge (ESPurna FW, works great). All works well, and very good range and I get reliable reporting from the door it’s fixed too. I used the RF Bridge’s WebGUI learning mode to trap and save the DW1’s code, all worked fine as stated above into HA via MQTT.
However, the small folded paper instructions that the DW1 comes with says in a round about way, that the unit sends a status message to the hub (RF Bridge in my case) every hour, and will also send a low battery warning when the battery is low (I’m guessing via a bit in the status message).
The switch has a common EV1527 code chip in it. The data sheets I’ve found all seem to be the same one page sheet from China, and contain nothing about that functionality…

Does anybody know if the EV1527 is actually capable of low battery warning ?
Martin

i guess we have wait to the battery is low and look at console on bridge Ip.
Any one knows if "Low High’ cam bu used to monitor the battery?
“RfReceived”:{“Sync”:12490,“Low”:420,“High”:1230,“Data”:“D44E4A”,“RfKey”:2}}

I believe that “Low” and “High” are measurements of the pulse widths of the signal, or similar.

I did some testing with some other 433MHz door/window sensors from Banggood to see what codes they transmitted. I don’t know if these would be applicable to others… These are “GS-WDS07” sensors from here: Gs-wds07 wireless door magnetic strip 433mhz for security alarm home system Sale - Banggood.com sold out-arrival notice at about $5.15 each. The sensors that I have are powered by a single AAA battery.

On the PCB, there’s provision for a “tamper” switch, but nothing is populated. If you short the pins, you can activate the “tamper” function and get a code transmitted.

Interesting that these things seem to have a programmer header, perhaps with pins labeled

G(round?) 
T(ransmit?)
R(eceive?)
V(cc?)

I wonder what to make of that :slight_smile:

So, for one of my sensors, I get these codes:

12F70A - open
12F70E - closed
12F707 - tamper
12F706 - low battery

The low battery code is emitted when the battery voltage is below a volt. I removed the battery, and connected my variable bench power supply, and slowly reduced the voltage. Going by the display on my power supply, I think about 0.8 V, but I’m not sure how accurate it is, and I didn’t bother to measure the actual voltage that it tripped at, mostly just looking to see if it did anything with a low power supply voltage.

Also of interest, this particular sensor seemed to have about a 28 microamp standby current. This I measured with 4.5 digit Fluke 8050A bench multimeter and should be pretty close. Of course, the current spikes up quite a bit when it decides to transmit… I didn’t bother to try to measure that.

I only got around to doing the low battery test on one of the sensors. The other 3 had these codes:

13D20A - open
13D20E - closed
13D20F - tamper (no switch actually installed) (the tamper code on this is different from the rest - maybe have to re-test?)

and

13DA0A - open
13DA0E - closed
13DA07 - tamper (no switch actually installed)

and

13FD0A - open
13FD0E - closed
13FD07 - tamper (no switch actually installed)

Sorry that I didn’t have an answer to your specific question. Maybe this could be helpful if these devices share some common transmitter chip?

7 Likes

I also have these which are similar but with tamper switch soldered and they also send 4 codes as mentioned.

As it seems 06 is common for low battery

19:28:28 MQT: tele/sonoffbr/RESULT = {“RfReceived”:{“Sync”:14080,“Low”:460,“High”:1370,“Data”:“BD3206”,“RfKey”:“None”}}

19:30:19 MQT: tele/sonoffbr/RESULT = {“RfReceived”:{“Sync”:14060,“Low”:480,“High”:1340,“Data”:“0B6006”,“RfKey”:“None”}}

20:22:11 MQT: tele/sonoffbr/RESULT = {“RfReceived”:{“Sync”:14100,“Low”:460,“High”:1370,“Data”:“B7EF06”,“RfKey”:“None”}}

20:26:04 MQT: tele/sonoffbr/RESULT = {“RfReceived”:{“Sync”:14060,“Low”:470,“High”:1350,“Data”:“0A2B06”,“RfKey”:“None”}}

20:31:05 MQT: tele/sonoffbr/RESULT = {“RfReceived”:{“Sync”:14110,“Low”:470,“High”:1360,“Data”:“BDA406”,“RfKey”:“None”}}

2 Likes

@mr.sneezy
Hi, i did’nt test low battery message, but i’m sure that my DW1 sends message ONLY at door opening and not also on door closing… How can you see if the door is fixed??

@gt4020 I have the same question. Has anyone faced this?

a can confirm, that 06 code is low battery signal (about 1V).

also have leak water detector, SKU855819. They declare in manual, that have low battery signal. But i examine it with power supply, and dont see any specific code (tasmota rf bridge). Onle about 2.29V send standard signal code for detection leak.
but, if is low battery Sync data is upper 10200-10500. If battery is ok, sync data is about 9000. So question is, can i extract syncc data and compare, if it is high as 10100? If yes, battery is low…

edit: PIR digoo (1xAAA 1,5V) - low battery have code D at last digit in code

I wouldn’t blindly rely upon low battery signals. Some sensors do send them (like Digoo R8H), some don’t (I believe that Sonoff DW is a very simple device and might not have it at all), but they all work differently - some send it regularly, some send it only ONCE at some voltage level.
For PIRs I store last time it triggered and have an automation that reports PIRs that did not send signals for the last N hours (so it’s probably dead/RF signal too weak). With door sensors it can be similar.

Speaking about DW1 - it only reports open state, useless as a sensor (but you can make a RF button out of it :wink:
In a way KERUI026/GS-IWDS07 are much better (but have their own issues, nobody’s perfect). And it depends what RF gateway you’re using.

so im not good in yaml (total beginer). But try to set this automation:

alias: change battery because sync is high for device code 9CEA29
description: ‘’
trigger:

  • platform: mqtt
    topic: rfbridge_A12345/tele/RESULT
    condition:
  • condition: template
    value_template: ‘"{{ trigger.payload_json.RfReceived.Sync > 10200 }}"’
  • condition: and
    conditions:
    • condition: template
      value_template: ‘"{{ trigger.payload_json.RfReceived.Data == ‘‘9CEA29’’ }}"’
      action:
  • data:
    message: change battery because sync is high for device code 9CEA29
    service: notify.notify

But get this in log: “2020-02-08 20:07:41 ERROR (MainThread) [homeassistant.helpers.condition] Error during template condition: UndefinedError: ‘dict object’ has no attribute ‘payload_json’
2020-02-08 20:07:41 ERROR (MainThread) [homeassistant.helpers.service] Error rendering data template: UndefinedError: ‘dict object’ has no attribute ‘payload_json’
2020-02-08 20:07:56 ERROR (MainThread) [homeassistant.helpers.condition] Error during template condition: UndefinedError: ‘dict object’ has no attribute ‘payload_json’
2020-02-08 20:07:56 ERROR (MainThread) [homeassistant.helpers.service] Error rendering data template: UndefinedError: ‘dict object’ has no attribute ‘payload_json’”

Where i have mistake, can you pleas hel me?

please always enclose your config in back quotes when posting here to prevent formatting.

your value_templates should be enclosed in single/double quotes - I can see more than required there. Weird quotes around Data value as well. Try double quotes around templates and single quotes inside (see below).
also, just make one template condition like

condition:
  condition: template
  value_template: >
    {{
      trigger.payload_json.RfReceived.Sync | int > 10200 and
      trigger.payload_json.RfReceived.Data == '9CEA29'
    }}

so the whole automation is

- alias: low_battery
  trigger:
    platform: mqtt
    topic: rfbridge_A12345/tele/RESULT
  condition:
    condition: template
    value_template: >
      {{
        trigger.payload_json.RfReceived.Sync | int > 10200 and
        trigger.payload_json.RfReceived.Data == '9CEA29'
      }}
  action:
    service: notify.notify
    data:
      message: 'change battery because sync is high for device code 9CEA29'

Hi, thx for help. i trayed your code. It seems, that it work ok.

Now i work on some python script for more devices (inspiration taken from forum). Can you pleas revise?

 #configuration 
binary_sensor:
 - platform: mqtt
     name: 'device1 lowbatt'
     #topic returned from python script
     state_topic: 'home/device1_lowbatt_py'
     off_delay: 3600
     device_class: power
#automation
#some id
- id: '123456789'
  alias: rfbridge1_sync_lowbatt_py
  description: rfbridge1 sync lowbatt python script
  trigger:
  - platform: mqtt
    topic: rfbridge1_A12345/tele/RESULT
  condition: []
  action:
  - data_template:
      #dont know, if this section is ok, if i can send two values to script
      #return device RF code
      loaddata: '{{trigger.payload_json.RfReceived.Data}}'
      #return sync value as number - int
      loadsync: '{{trigger.payload_json.RfReceived.Sync | int}}'
    #call python script
    service: python_script.rfbridge_demux_sync_lowbatt
#python script rfbridge_demux_sync_lowbatt.py
d = { 
      '9CAE29':['device1_lowbatt_py','ON','false','10200'],
      '9CEA29':['device2_lowbatt_py','ON','false','10300']
      }
#dont know, if this section is ok
#device code from automation
p = data.get('loaddata')
#sync value as int from automation
s = data.get('loadsync')

#if p exist
if p is not None:
  #if p is from d
  if p in d.keys():
    #return sync value for low battery per device code, because not all devices have same sync value for low batt state
    syncdata = '{}'.format(d[p][3])
    #if s exist
    if s is not None:
        #if mqtt device sync value is more than sync data for low batt for this device
        if int(s) > int(syncdata):
           #set service data 
           service_data = {'topic':'home/{}'.format(d[p][0]), 'payload':'{}'.format(d[p][1]), 'qos':0, 'retain':'{}'.format(d[p][2])}
           #publish service data to "configuration"
           hass.services.call('mqtt', 'publish', service_data, False)
           #writo to log
           logger.warning('<rfbridge_demux_lowbatt> Received lowbatt syncdata: {}'.format(s))

could you tell me what kind of revision is required?
does it work at all?
I’m not good at python, just learning it and sometimes write my own scripts for HA

so, if there is something wrong (syntx, or other error for HA). Also i revised, corrected and tested.

Now when i publish mqtt packet for topic “rfbridge1_A12345/tele/RESULT”:

{
    "Time": "2020-02-08T19:55:59",
    "RfReceived": {
        "Sync": 10500,
        "Low": 440,
        "High": 1380,
        "Data": "9CAE29",
        "RfKey": "None"
    }
}

I get right value from script:

2020-02-09 13:44:00 WARNING (SyncWorker_5) [homeassistant.components.python_script.rfbridge_demux_sync_lowbatt.py] <rfbridge_demux_lowbatt> Received lowbatt syncdata: 10500

so it works - congratulations!

what can I say looking at your code… I don’t know what the logic is being your setup.
configuration:

  1. Hope you know what you’re doing using off_delay

automation

  1. you can drop id, just - alias: rfbridge1_sync_lowbatt_py
  2. you can drop empty condition section (condition: []) (ie. when there is no condition - don’t include it)
  3. #dont know, if this section is ok, if i can send two values to script
    you can pass as many variables as you need. just keep in mind they’l all be strings, not objects

rfbridge_demux_sync_lowbatt.py

  1. I think this s = data.get('load sync') brings you a string so maybe it’s better to convert ti to int here rather that in the automation
  2. I think you can substitute if p is not None: with just if p:
  3. Line 21, you’re converting your s to int - see p.1
  4. Line 21 - not a big deal but define your d like this
d = { 
      '9CAE29':['device1_lowbatt_py', 'ON', 'false', 10200],
      '9CEA29':['device2_lowbatt_py', 'ON', 'false', 10300]
      }

and then you can write if int(s) > syncdata: because your syncdata is a number.
5. add something like info = d[p] after line 15 and the use info[3] etc instead of d[p][3]
6 Line 25 should be just hass.services.call('mqtt', 'publish', service_data)

and that’s about it :wink:

thx sir for all your time, im learned something new.

1 Like

Do any of you know what the low voltage code is for the PIR2?

Regarding DW1 - they’re a very simple circuit taken from open hardware designs - EV1527 DW1 - EasyEDA open source hardware lab - a on-to-off reed switch transition causes a FET to turn on power to the entire 1527+led for 2 seconds (The basic Sonoff PIR is almost identical, just swapping a PIR for the reed switch)

Modification is possible, but you’re talking adding adding a $2 embedded controller to a $3 sensor. It’s not worth it (or the time needed)

They’re useful for things like catflaps, movement sensing or low rate (more than once per 5 seconds will not be retected reliably) meter rotational pulse generators but anything more than a simple low duty cycle pulse requirement isn’t worth the time taken to hack on them

It’s cheaper, faster and less messy to just cut your losses and buy better sensors