How are you confirming the script is triggered?
I have logger.info inside the script which show the service_data content and this is shown in the log. Is there anything special need to be done to publish through mqtt? The mqtt from RF bridge is triggered according to the log and calling the script.
Aug 24 07:56:45 hassbian hass[524]: 2019-08-24 07:56:45 INFO (MainThread) [homeassistant.components.automation] Executing RFbridge Demultiplexer
Aug 24 07:56:45 hassbian hass[524]: 2019-08-24 07:56:45 INFO (MainThread) [homeassistant.helpers.script] Script RFbridge Demultiplexer: Running script
Aug 24 07:56:45 hassbian hass[524]: 2019-08-24 07:56:45 INFO (MainThread) [homeassistant.helpers.script] Script RFbridge Demultiplexer: Executing step call service
Aug 24 07:56:45 hassbian hass[524]: 2019-08-24 07:56:45 INFO (SyncWorker_6) [homeassistant.components.python_script] Executing rfbridge_demux.py: {'payload': '0EF4E4'}
Aug 24 07:56:45 hassbian hass[524]: 2019-08-24 07:56:45 INFO (SyncWorker_6) [homeassistant.components.python_script.rfbridge_demux.py] Recv: {'topic': 'rfbridge/KeyFobB', 'payload': 'ON', 'qos': 0, 'retain': 'false'}
I’m trying to monitor using mosquito_sub with topic = rfbridge/*.
Like the Thinking
but I did mine Differancely
I have this sensor
- platform: mqtt
name: "Last RF"
state_topic: "tele/RF_Bridge/RESULT"
value_template: '{{value_json.RfReceived.Data}}'
expire_after: 1
qos: 1
I find out its rf code then write the 1 automation to turn on/off toggle something
- id: His side Lamp
alias: His side Lamp
initial_state: 'on'
trigger:
- entity_id: sensor.last_rf
platform: state
to: '137854'
condition: []
action:
- data:
entity_id: light.his_side
service: light.toggle
Silly me, thanks for pointing it out. Yes, indeed, it does get triggered. Now to finish up my automation Thanks again.
Hi @123 I’ve been using your rfbridge_demux for a while now and it works perfectly with the Sonoff PIR sensors I have around
But recently I got one of those Digoo RF 433 remotes and I’ve been trying to get it to trigger a binary sensor (not sure if the right call) but by some reason I see it on the log and on the mosquitto mqtt but it does nothing on the HA side… wondering if it could be my eyes misisng out something?
This is my rfbridge_demux:
d = { '123456':['remotesos','ON','false'] # remote SOS option
}
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])}
logger.warning('<rfbridge_demux> Received RF command: {}'.format(p))
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)
This is what I see on the mqtt side:
tele/sonoff-rf001/RESULT {"RfReceived":{"Sync":12430,"Low":420,"High":1210,"Data":"123456","RfKey":"None"}}
home/remotesos ON
This is my binary_sensor:
- platform: mqtt
name: 'SOS'
state_topic: '/home/remotesos'
off_delay: 15
device_class: safety
I’ve tried changing the device_classes but no joy at all
ps: the ‘123456’ is a fake code just for the sake of the post, the real one has the real 433 code.
Any ideas?
Thanks for the help.
The python_script will publish to this topic:
home/remotesos
However, your binary_sensor’s state_topic
is set to:
/home/remotesos
Remove the leading slash from the binary_sensor’s state_topic
.
#facepalm
OMG how did I not see that
Thank you very much
Thank you! This is the solution I’ve been looking for to make my configuration a whole lot more manageable.
I’m very averse to the verbose nature of Yaml and find in general, HASS’s configuration to be it’s biggest downside - this kind of approach completely changes my feelings about the platform, thank you!
Hi All
Trying to go convert to strategy 2 but getting this error in my HA log:
Error while executing automation automation.rfbridge_demultiplexer. Service not found for call_service at pos 1: Unable to find service python_script/rfbridge_demux
My first time configuring python scripts on the system so started from step one.
Anything specific I should look for?
Did you put python_script: in your configuration.yaml?
Thought I’d show my independent implementation of the ‘de-multiplexer’ completely using HA’s templates. I am able to take advantage of the fact that my door sensors all have their open/close code differ by only the last character (‘A’ for open, ‘E’ for close):
I like this.
One question though; what made you decide to raise an rf_signal_received
event and then trigger a second automation based on it, rather than just have it all as one automation?
I have RF devices other than door sensors, and I like having the RF signals abstracted from the MQTT messages, when I write other RF-based automations. You could totally do it the way you’re suggesting. It’s just preference.
Is there anything I can improve in my original post to make it less likely that others make the same mistake?
This is what it currently states:
To make this work, you have to configure Home Assistant to use the python_script component.
- Add
python_script:
to your configuration file.- Create the following sub-directory:
config/python_scripts
- Restart Home Assistant.
Can I suggest:
Add python_script:
to your configuration.yaml
file
Your suggestion is already present in the existing text (third paragraph in the second section). It’s the first one of three steps.
Or are you suggesting only the first step should be shown and the other two removed??
I’m just suggesting that “Add python_script:
to your configuration file” might be a cause of some confusion and that explicitly mentioning the configuration.yaml
might be better.
It was just an observation based my original experience when learning about HA combined with the fact that the entire HA config can be contained in one file, and usually is for new people. I sometimes think it can be generally confusing and not always clear what is being meant when the word ‘configuration’ s being used.
What yo had originally was clear to me but as you asked, I thought I’d give another view on it.
… and done!
I also added a link to the python_script integration’s documentation. It now reads as follows:
To make this work, you have to configure Home Assistant to use the python_script component. Full instructions can be found in the documentation for the python_script integration. Here are the basic steps:
- Add
python_script:
to yourconfiguration.yaml
file.- Create the following sub-directory:
config/python_scripts
- Restart Home Assistant.