I can’t wrap my head around how to achieve this new automation in Node Red.
I wan’t to run a script when my phone disconnects from a paired Bluetooth speaker. I have the native HA Android app installed. I have the Bluetooth sensor and Bluetooth connection sensor exposed. The Connection Sensor exposes an attribute that show’s the currently paired device.
What I’m trying to achieve
- trigger: when Bluetooth speaker disconnects and stays disconnected for 10s
- conditions: speaker was connected to my phone for 5 mins or more (this is the bit I can’t work out how to achieve)
- action: run a script.
This is where I’m currently at:
[{"id":"e8cab719.8638b8","type":"trigger","z":"f506f890.db8b98","name":"","op1":"","op2":"","op1type":"nul","op2type":"payl","duration":"10","extend":true,"units":"s","reset":"","bytopic":"all","topic":"topic","outputs":1,"x":430,"y":1200,"wires":[["1a932c6a.59f024"]]},{"id":"19247665.85807a","type":"server-state-changed","z":"f506f890.db8b98","name":"Bluetooth Connected","server":"79d7078a.622af8","version":1,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"sensor.sm_g960f_ha_androidnative_bluetooth_connection","entityidfiltertype":"exact","outputinitially":false,"state_type":"str","haltifstate":"0","halt_if_type":"num","halt_if_compare":"is","outputs":2,"output_only_on_state_change":true,"x":140,"y":1200,"wires":[["e8cab719.8638b8"],[]]},{"id":"1a932c6a.59f024","type":"api-call-service","z":"f506f890.db8b98","name":"","server":"79d7078a.622af8","version":1,"debugenabled":false,"service_domain":"script","service":"turn_on","entityId":"script.morning_bedroom_getting_dressed","data":"","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":620,"y":1200,"wires":[[]]},{"id":"79d7078a.622af8","type":"server","z":"","name":"Home Assistant","legacy":false,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":true,"cacheJson":true}]