Bwalarm (akasma74 edition)

If there are open sensors, there will be no pending, right? No state change, nada :wink:

I’ll think about the good way of doing that.

@tom_l very likely so I’d advise to postpone updating (but it’s easy to roll back).
Will look into it soon. Actually, this component is based on AlarmControlPanelEntity and is a sibling of Manual Alarm Panel. Therefore in theory the above mentioned breaking changes should have no impact but I haven’t updated yet so cannot guarantee.

1 Like

Hi @onkytonk,

I use an Alexa Routine to Arm the alarm via a node red flow which checks if the sensors are open except for the override sensors. i.e Front Door, Hallway Motion. I do this using a Group that lists all the sensors apart from those I want to override. In node red i check the state of that Group. If it is on then at least one sensor is open and the alarm will not Arm and Alexa responds with which sensors are open. If the Group is off then I know all sensors apart from the override sensor are off and then the alarm will Arm. Here is the Node Red flow I use:

[{"id":"e611d8f0.cde5f8","type":"tab","label":"Flow 4","disabled":false,"info":""},{"id":"4d50ac10.aded9c","type":"template","z":"e611d8f0.cde5f8","name":"Format Friendly Name","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"{{payload.attributes.friendly_name}}","output":"str","x":880,"y":200,"wires":[["ef57d024.41c9c"]]},{"id":"ef57d024.41c9c","type":"join","z":"e611d8f0.cde5f8","name":"","mode":"custom","build":"string","property":"payload","propertyType":"msg","key":"topic","joiner":",","joinerType":"str","accumulate":false,"timeout":"","count":"","reduceRight":false,"reduceExp":"","reduceInit":"","reduceInitType":"","reduceFixup":"","x":1070,"y":200,"wires":[["6eb9023a.f31fdc"]]},{"id":"7986cb1c.fce2f4","type":"ha-get-entities","z":"e611d8f0.cde5f8","name":"","rules":[{"property":"entity_id","logic":"is","value":"binary_sensor\\.((?!kitchen_door|study_door)(.*door.*)|(.*window.*))","valueType":"re"},{"property":"state","logic":"is","value":"on","valueType":"str"}],"output_type":"split","output_empty_results":false,"output_location_type":"msg","output_location":"payload","output_results_count":1,"x":690,"y":200,"wires":[["4d50ac10.aded9c"]]},{"id":"57a90e4a.a29cd","type":"api-call-service","z":"e611d8f0.cde5f8","name":"Alexa Sensors Open TTS","version":1,"debugenabled":false,"service_domain":"notify","service":"alexa_media","entityId":"","data":"{\"message\":\"Please close {{payload}} , then say, Alexa Goodbye, to set the alarm to away\",\"data\":{\"type\":\"tts\"},\"target\":[\"{{lastalexa}}\"]}","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":1430,"y":200,"wires":[[]]},{"id":"6eb9023a.f31fdc","type":"change","z":"e611d8f0.cde5f8","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"payload.data.message","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":1220,"y":200,"wires":[["57a90e4a.a29cd"]]},{"id":"d0d0a226.7462a8","type":"api-current-state","z":"e611d8f0.cde5f8","name":"State of Alarm Sensors","version":1,"outputs":2,"halt_if":"on","halt_if_type":"str","halt_if_compare":"is","override_topic":false,"entity_id":"group.alarm_away_sensors","state_type":"str","state_location":"","override_payload":"none","entity_location":"","override_data":"none","blockInputOverrides":false,"x":490,"y":220,"wires":[["7986cb1c.fce2f4"],["32dec8d4.9935d"]]},{"id":"82ab5371.362fb","type":"api-call-service","z":"e611d8f0.cde5f8","name":"Arm Away","version":1,"debugenabled":false,"service_domain":"alarm_control_panel","service":"alarm_arm_away","entityId":"alarm_control_panel.house","data":"","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":1430,"y":260,"wires":[[]]},{"id":"9bde7dd0.f6221","type":"server-state-changed","z":"e611d8f0.cde5f8","name":"Alarm Goodbye","version":1,"exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"entityidfilter":"script.1564690605365","entityidfiltertype":"exact","outputinitially":false,"state_type":"str","haltifstate":"on","halt_if_type":"str","halt_if_compare":"is","outputs":2,"output_only_on_state_change":true,"x":120,"y":220,"wires":[["d043a31f.5b9cc8"],[]]},{"id":"32dec8d4.9935d","type":"api-call-service","z":"e611d8f0.cde5f8","name":"Alexa Goodbye","version":1,"debugenabled":false,"service_domain":"notify","service":"alexa_media","entityId":"","data":"{\"message\":\"All Windows and Doors are closed, Goodbye\",\"data\":{\"type\":\"tts\"},\"target\":[\"{{lastalexa}}\"]}","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":700,"y":240,"wires":[["14a603a2.6655b4"]]},{"id":"af34d1e5.804f1","type":"delay","z":"e611d8f0.cde5f8","name":"","pauseType":"delay","timeout":"3","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":1140,"y":260,"wires":[["82ab5371.362fb"]]},{"id":"14a603a2.6655b4","type":"api-current-state","z":"e611d8f0.cde5f8","name":"State of Vacum","version":1,"outputs":2,"halt_if":"docked","halt_if_type":"str","halt_if_compare":"is","override_topic":false,"entity_id":"vacuum.victor_2","state_type":"str","state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","blockInputOverrides":false,"x":900,"y":260,"wires":[["af34d1e5.804f1"],["36edc3a2.f1e194"]]},{"id":"36edc3a2.f1e194","type":"api-call-service","z":"e611d8f0.cde5f8","name":"Arm night","version":1,"debugenabled":false,"service_domain":"alarm_control_panel","service":"alarm_arm_night","entityId":"alarm_control_panel.house","data":"","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":1140,"y":320,"wires":[[]]},{"id":"d043a31f.5b9cc8","type":"api-render-template","z":"e611d8f0.cde5f8","name":"LAst Alexa","template":"{{ states.sensor.last_alexa.state }}","resultsLocation":"lastalexa","resultsLocationType":"msg","templateLocation":"template","templateLocationType":"msg","x":290,"y":220,"wires":[["d0d0a226.7462a8"]]},{"id":"ec85d738.90de18","type":"comment","z":"e611d8f0.cde5f8","name":"........................  Goodbye Script and Check Windows and Door Sensors  ........................","info":"","x":344,"y":151,"wires":[]}]
1 Like

Thanks for this. I never really found a use of the “group” feature. Now I do !!

GV

You are right. It is easier to react when receiving a message than not receiving it. I was am lazy :slight_smile:

GV

Should be a warning. The main issue is with icons (at the bottom, for example), they’ve gone.
Unfortunately, no mention in the release notes about what exactly we need to do to fix it… pita :frowning:

Could it be do to the custom-ui not being supported anymore?

I’m not home right now so can’t look into it myself right now.

if you check the link you posted yourself, you can see it has been solved :wink:

doh, thanks. my bad

just be be precise: the custom-ui issue on Ha 110 has been solved, not the issue of this topic or other mentioned issues (at least not that I know of …)

this component does not use custom-ui.
I presume it’s something to do with the optimisation of loading MDI icons - this code correctly displays all sensors’ icons, for example, but does not display any icon that is not used somewhere else in LL interface.
Looking into it now.

I’ve seen the solution in another custom component’s issue but am having trouble finding it. Will post it here if I do.

Edit: does this help:

https://github.com/kalkih/mini-media-player/issues/297

1 Like

Yeah, they replaced paper-icon-button with ha-icon-button (got it here).
A fix is ready but something is not quite right with icons’ sizes, need to get it back first.
UPDATE: forgot about .css :man_facepalming: will release the fix soon.

A fix for HA 0.110 is available.

5 Likes

Thank you for a quick update!

Speaking about changes to Manual Alarm Panel and considering this info, it looks kind of reasonable to think if this alarm should implement the same set of states.
Also, I haven’t checked yet but those previous_state/next_state may be useful to some.
Still need to wrap my head around their arming_time idea though…

@onkytonk, @greengolfer, @jamos and anyone using MQTT interface - I decided to create a new FR to discuss what’s required in terms of MQTT so please have a look and say what you think/share your ideas.

I’m also discussion an area/(zone?) idea here - it comes up from time to time and I thought it’s a good thing to try fighting out what’s required and how it could be implemented. I have no experience with this kind of alarms but happy to learn so the current functionality could be extended.
Not saying it will happen soon but it’s good to plan ahead anyway.

This is my sort of work around for open sensor notifications.
I use an events all node, when the service is called, it triggers to send a notification if a particular sensor is open.
Not sure if there is a simpler way to implement this.

Thanks for keeping this alarm component up to date!

Hi, If it’s of any use I’ve created a flow with functions to read in the immediate sensors from the bwalarm.yaml config file and output only those open sensors that correspond to what mqtt alarm_mode is sent. i.e. If Alarm_Away is set this flow will only output the open sensors that are configured from Away -Immediate section in BWalarm. It has the benefit of no additional nod red configuration if you add or remove sensors in the BWALARM config.

[{"id":"8d85fdee.d9d3","type":"tab","label":"Flow 1","disabled":false,"info":""},{"id":"b2b0d1a4.64ef08","type":"yaml","z":"8d85fdee.d9d3","property":"payload","name":"","x":730,"y":280,"wires":[["2f2f022c.de0166"]]},{"id":"eb980ac.188b7f8","type":"file in","z":"8d85fdee.d9d3","name":"BWALARM File","filename":"/config/resources/bwalarm/bwalarm.yaml","format":"utf8","sendError":true,"x":560,"y":280,"wires":[["b2b0d1a4.64ef08"]]},{"id":"2f2f022c.de0166","type":"function","z":"8d85fdee.d9d3","name":"Get Friendly Names ","func":"const globalHomeAssistant = global.get('homeassistant');\nvar armed_mode = flow.get('arm_mode');\nvar entity,friendlyName=\"\";\nvar count = 0;\nvar listState=[];\nvar listfriendlyNames=[];\nvar sensorOn=\"false\";\nvar topic=msg.topic;\nvar mAway,mHome,mNight,msg2={};\n\n// Get list of immediate sensors from BWALARM for different alarm modes\nmAway=msg.payload.states.armed_away.immediate;\nmHome=msg.payload.states.armed_home.immediate;\nmNight=msg.payload.states.armed_night.immediate;\n\n// Set sensor list based on Alarm Mode\nif (armed_mode==\"ARM_AWAY\") {\n        msg2=mAway;}\nif (armed_mode==\"ARM_HOME\") {\n        msg2=mHome;}\nif (armed_mode==\"ARM_NIGHT\") {\n        msg2=mNight;}\n\n// Loop through the Alarm sensors Array\nfor (var i = 0; i< msg2.length; i++) {\n    entity=msg2[i];\n    count +=1;\n    //Get State of sensors in array\n    listState[i] = globalHomeAssistant.homeAssistant.states[entity].state;\n    //Get Friendly Names of sensors\n    listfriendlyNames[i] = globalHomeAssistant.homeAssistant.states[entity].attributes.friendly_name;\n    // Check if any sensor states are on and if so set sensorOn to true\n    if (listState[i]== \"on\") {\n        sensorOn=\"true\";\n        // create a string of sensor Friendly Names that are on\n        friendlyName = friendlyName + listfriendlyNames[i] +\", \";\n    }\n}\n\n// set payload\nmsg.payload=friendlyName;\n//msg.data=sensorOn;\n\n// Return message if any Sensor states are on.\nif (sensorOn == \"true\") {\nreturn [msg];\n}else {\n   return [null];\n}\n","outputs":1,"noerr":0,"x":900,"y":280,"wires":[["36260eb0.e9f6a2","dfcc7d4.70cd1"]],"info":"Generates a list of Friendly Names of Open Sensors from the immediate sensors in the BWALARM.yaml file.\n\nRequires Flow.Arm_Mode variable from Store Arm Mode Function "},{"id":"36260eb0.e9f6a2","type":"api-render-template","z":"8d85fdee.d9d3","name":"Last Alexa","template":"{{ states.sensor.last_alexa.state }}","resultsLocation":"lastalexa","resultsLocationType":"msg","templateLocation":"template","templateLocationType":"msg","x":1110,"y":280,"wires":[["534c316c.34701"]]},{"id":"dbc0b540.f5b508","type":"function","z":"8d85fdee.d9d3","name":"Store Arm Mode","func":"var arm_mode = flow.get('arm_mode');\nvar msgt = msg.payload;\nflow.set('arm_mode',msgt);\nmsg.payload=arm_mode;\nreturn msg;","outputs":1,"noerr":0,"x":380,"y":280,"wires":[["eb980ac.188b7f8"]],"info":"Sets Flow.Alarm_Mode variable from MQTT Payload for use in Get Sensors/Friendly Names Function"},{"id":"7f78d91b.3b6638","type":"mqtt in","z":"8d85fdee.d9d3","name":"","topic":"home/alarm/set","qos":"2","datatype":"auto","broker":"3f5c82ac.348636","x":200,"y":280,"wires":[["dbc0b540.f5b508"]]},{"id":"534c316c.34701","type":"api-call-service","z":"8d85fdee.d9d3","name":"OPEN Sensors TTS","version":1,"debugenabled":false,"service_domain":"notify","service":"alexa_media","entityId":"","data":"{\"message\":\"ALARM Not Set, Please close {{payload}} , Then set the alarm \",\"data\":{\"type\":\"tts\"},\"target\":[\"media_player.hallway_echo_dot\"]}","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":1288,"y":280,"wires":[[]]},{"id":"dfcc7d4.70cd1","type":"api-call-service","z":"8d85fdee.d9d3","name":"Notify Phone","version":1,"debugenabled":false,"service_domain":"notify","service":"mobile_app_j_iphone","entityId":"","data":"{\"data\":{\"push\":{\"sound\":{\"critical\":1,\"name\":\"default\",\"volume\":1}}},\"message\":\"{{payload}}\",\"title\":\"Open Sensors\"}","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":1110,"y":340,"wires":[[]]},{"id":"3f5c82ac.348636","type":"mqtt-broker","z":"","name":"","broker":"localhost","port":"1883","clientid":"","usetls":false,"compatmode":true,"keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","closeTopic":"","closeQos":"0","closePayload":"","willTopic":"","willQos":"0","willPayload":""}]
1 Like

Is anyone using MQTT Alarm Panel? I can’t seem to get it to Disarm BWalarm.

If I disarm from within HA, the alarm panel is disarmed, but not the other way around.

Any idea or suggestions please?