Check and see if one byte differs from another of your 433Mhz sensors/switches. I find that occasionally I will get what seems like interference on my RF bridge. I will get spurious packets that differ in only one byte of my configured sensors, when I should have received the correct value. This lasts a while then stops, I am yet to work out the interference source.
Interestingā¦
I have just started logging all my 433 signals so that I can try and work out when my sensors send a low battery signal and I have been noticing a lot of signals that look the same as I am expecting but varying by one byte. And not always the same byte so I am none the wiser as to if any are actual low battery signals.
But you are saying they might just be interference?
This is exactly what I see.
I doubt itās interference from a 433 Mhz device though. I live remotely so itās definitely not coming from another property and Iām aware (hopefully) of all of my devices.
Hmmmā¦ Iāve seen also āinterference-corrupted codesā on my RF bridge. Usually, just single byte (but not always last one) was ācorruptedā. Are you seeing completely random codes or they can be partially-matched with some known codes?
Also, some RF sensors (like door/window sensors, or wireless thermostats) emit additional RF codes, when ābattery is nearly drainedā. I guess in such case the prefix of RF signal should match the other (known) codesā¦ just last byte would differā¦ Maybe this is an issue?
Correct. It could be that as the codes are so similar though the battery codes from my devices end in F and thatās not what Iām seeing.
Whatās also odd is how itās not consistent. For the last 4 days Iāve had no issues. I had assumed that it may be a faulty device so took it out of service, only to find another one exhibiting this behaviour.
Inconclusively, Iāve noticed it to be worse in the sun and less problematic when itās cold.
Hmmm, The battery capacity changes with temperature. So, maybe the RF signal strength varies depending on conditions.
https://www.thoughtco.com/why-batteries-discharge-quickly-cold-weather-607889
Thatās certainly a possibility.
I have assumed that the devices just send out a ālow batteryā code once it drops to a pre determined level. Is it possible that it also sends out intermediate battery level codes too maybe, and that is what I am seeing?
The Chinese documents are a little scant on detail.
I seem to be getting random byte changes. It always appears to be just one byte but so far I have not seen a pattern with which byte is different.
I am now saving all āunknownā RF codes to a file so I can have a good look when I have a lot of them.
Understatement!
Are you doing that automatically? Care to share?
When I receive an unknown code I publish it to a separate MQTT topic. Then I have an automation that writes them to a file.
#===========
#=== Notify
#===========
notify:
- platform: file
name: log_unknown_rf_codes
filename: my-log_unknown_rf_codes.log
#================
#=== Automations
#================
automation:
#===============================
#=== Deal with unknown RF Codes
#===============================
- alias: Access Monitoring Unknown RF Codes
trigger:
- platform: mqtt
topic: 433/Unknown_RF_Code
condition:
- condition: template
value_template: >
{% set known_codes = 'DC970A, DC970E, BLAH-BLAH' %}
{{ trigger.payload[0:6] not in known_codes }}
- service: notify.log_unknown_rf_codes
data_template:
message: >
{{ as_timestamp(now()) | timestamp_custom('%d %b, %X') }} - {{ trigger.payload }}
You can modify rfbridge_demux.py
and have it take care of logging unknown codes to a file.
Replace the last few line of the python_script with the following:
if p is not None:
if p in d.keys():
service_data = {'topic':'433/{}'.format(d[p][0]), 'payload':'{}'.format(d[p][1]), 'qos':0, 'retain':'{}'.format(d[p][2])}
hass.services.call('mqtt', 'publish', service_data, False)
else:
logger.warning('<rfbridge_demux> Received unknown RF command: {}'.format(p))
service_data = {'message':'{} - {}'.format(datetime.datetime.now().strftime("%d %b, %X"), p)}
hass.services.call('notify', 'log_unknown_rf_codes', service_data, False)
It publishes known codes to your preferred MQTT topic (433/<code>
) and unknown codes are logged to the notify component you created (notify.log_unknown_rf_codes
).
Yes, but I still havenāt changed to use the python script. Itās on my todo list!
As a favour can you show me the python to add so that I can write to the log only if an input_boolean is on?
This is the big drawback to using python scripts written by others. They are a lot harder to modify if you donāt have a good knowledge of python!
Whenever you get around to using the python_script, then Iāll help you to modify it.
Could I have some help with this please? I am working with Strategy 2.
My rfbridge_demux.py is this;
d = { '1A1092':['Mum needs help','ON','false'],
'989301':['doorbell','ON','false'],
'2D8B11':['Water leak','ON','false'],
'125B0A':['Front door','ON','true']
'125B0E':['Front door','OFF','true']
'B91D0A':['Back door','ON','true']
'B91D0E':['Back door','OFF','true']
'1DE00A':['Study single door','ON','true']
'1DE00E':['Study single door','OFF','true']
'E801FE':['kitchen motion','ON','false']
'3834B9':['My room door','ON','false']
'EA1E99':['Brewery door','ON','false']
'CC8DA2':['My Study light toggle','ON','true']
}
p = data.get('payload')
if p is not None:
if p in d.keys():
service_data = {'topic':'home/{}'.format(d[p][0]), 'payload':'{}'.format(d[p][1]), 'qos':0, 'retain':'{}'.format(d[p][2])}
else:
service_data = {'topic':'home/unknown', 'payload':'{}'.format(p), 'qos':0, 'retain':'false'}
logger.warning('<rfbridge_demux> Received unknown RF command: {}'.format(p))
hass.services.call('mqtt', 'publish', service_data, False)
My automation is this:
- alias: 'rfbridge_demultiplexer'
trigger:
- platform: mqtt
topic: bridge1/tele/RESULT
action:
- service: python_script.rfbridge_demux
data_template:
payload: '{{trigger.payload_json.RfReceived.Data}}'
and my adjusted binary sensor is this:
- platform: mqtt
name: "Door bell"
state_topic: 'home/doorbell'
off_delay: 00:00:05
device_class: motion
The old binary sensor config is this:
- platform: mqtt
name: "Door bell"
state_topic: "bridge1/tele/RESULT"
value_template: '{{value_json.RfReceived.Data}}'
payload_on: "989301"
payload_off: "989301off"
device_class: Motion
qos: 1
Iām starting with the door bell but if I subscribe to the topic home/doorbell there is no data received to the topic. I can see the payload arrive in the original topic as;
{
"Time": "2019-12-29T20:06:51",
"RfReceived": {
"Sync": 9020,
"Low": 290,
"High": 880,
"Data": "989301",
"RfKey": "None"
}
}
I have no log entries but none the lest - I expect it to be something simple as it so often is!
But for the life of me I cannot see it.
Oh and āA Happy New Year to Allā.
edit1: As a side note I am focusing on the doorbell as a tester. Do it simple and the rest will follow approach.
Hereās what I currently have in my rfbridge_demux.py:
if p is not None:
if p in d.keys():
service_data = {'topic':'home/{}'.format(d[p][0]), 'payload':'{}'.format(d[p][1]), 'qos':0, 'retain':'{}'.format(d[p][2])}
else:
service_data = {'topic':'home/unknown', 'payload':'{}'.format(p), 'qos':0, 'retain':'false'}
logger.warning('<rfbridge_demux> Received unknown RF command: {}'.format(p))
hass.services.call('mqtt', 'publish', service_data, False)
Do I just need to change it to this, or are any other changes needed?
if p is not None:
if p in d.keys():
service_data = {'topic':'home/{}'.format(d[p][0]), 'payload':'{}'.format(d[p][1]), 'qos':0, 'retain':'{}'.format(d[p][2])}
hass.services.call('mqtt', 'publish', service_data, False)
else:
logger.warning('<rfbridge_demux> Received unknown RF command: {}'.format(p))
service_data = {'message':'{} - {}'.format(datetime.datetime.now().strftime("%d %b, %X"), p)}
hass.services.call('notify', 'log_unknown_rf_codes', service_data, False)
Will it create the log file or do I need to create an empty one first?
Adding an input_boolean to activate/deactivate would be a welcome addition.
Based on a quick review, the python_script, automation, and binary_sensor all appear to be correct.
If payloads are published to bridge1/tele/RESULT
but none are published to home/doorbell
then it may be due to:
- The python script is not being executed because you may have overlooked to include
python_script:
in your configuration file (and then restarted Home Assistant). - The automation is not turned on (check its state in Developer Tools > States).
Check the system logās details for any messages related to the execution of the automation and python_script.
According to the File Sensorās documentation, it will create the file if it doesnāt exist.
If you work with Klogg then Iām sure the two of you will develop a means to do that. Hereās something to get you both going:
x = hass.states.get('input_boolean.whatever')
if x is not None and x.state == "on":
<do something>
Definitely set `python_script:ā in the configuration file.
And;
The automation.rfbridge_demultiplexer is set to on.
not sure how to set the debug for this but any advice is appreciated.
Developer Tools > Logs
then click Load Full Home Assistant Log
.
Each time a payload is published to bridge1/tele/RESULT
it should trigger automation.rfbridge_demultiplexer
(and this will appear in the log) which then calls python_script.rfbridge_demux
which, I believe, should also appear in the log.
If the log doesnāt report any of this activity ā¦ something isnāt what it seems to be here.
I think then
I will investigate in the UK morning as its late here now. Thank you for your support.