Bwalarm (akasma74 edition)

Here’s my automation for open sensor notifications. I know there’s a way to pull the sensors directly from BWalarm, but I prefer this more visual representation.

Basically, I can specify whether the sensor notifies me when arming “away” or “home” separately.
It then checks the status of a particular sensor.
The function node formats the message, pulling the sensor name from the previous state node.
Finally, there’s a notify and TTS node.

[{"id":"9529988e.843498","type":"server-events","z":"5da73b18.815574","name":"Call Service Events","server":"b4442cdf.ce6f4","event_type":"call_service","exposeToHomeAssistant":false,"haConfig":[{"property":"name","value":""},{"property":"icon","value":""}],"x":170,"y":2180,"wires":[["f0c7c379.994d3"]]},{"id":"f0c7c379.994d3","type":"switch","z":"5da73b18.815574","name":"Alarm State","property":"payload.event.service","propertyType":"msg","rules":[{"t":"eq","v":"alarm_arm_away","vt":"str"},{"t":"eq","v":"alarm_arm_home","vt":"str"}],"checkall":"true","repair":false,"outputs":2,"x":370,"y":2180,"wires":[["c99c2d79.3ab26","fe51b0e.a95475","c1c15248.8912f","ddd18552.49b758","268a1463.02673c","d1bfa8bd.355428","4eb554dc.df9adc","3fe69935.aeeeb6","cb381ae.2de41e8","a86490ff.1478a","fef95f5f.e8a5","42cb55a.18100ac"],["c99c2d79.3ab26","fe51b0e.a95475","c1c15248.8912f","ddd18552.49b758","d1bfa8bd.355428","4eb554dc.df9adc","3fe69935.aeeeb6","cb381ae.2de41e8","a86490ff.1478a","fef95f5f.e8a5","42cb55a.18100ac"]]},{"id":"c99c2d79.3ab26","type":"api-current-state","z":"5da73b18.815574","name":"Alfresco Door","server":"b4442cdf.ce6f4","version":1,"outputs":2,"halt_if":"on","halt_if_type":"str","halt_if_compare":"is","override_topic":false,"entity_id":"binary_sensor.alfresco_door","state_type":"str","state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","blockInputOverrides":false,"x":840,"y":1920,"wires":[["99ed4481.b9fa08"],[]]},{"id":"fe51b0e.a95475","type":"api-current-state","z":"5da73b18.815574","name":"Front Door","server":"b4442cdf.ce6f4","version":1,"outputs":2,"halt_if":"on","halt_if_type":"str","halt_if_compare":"is","override_topic":false,"entity_id":"binary_sensor.front_door","state_type":"str","state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","blockInputOverrides":false,"x":830,"y":1860,"wires":[["99ed4481.b9fa08"],[]]},{"id":"7ff291fe.415db","type":"comment","z":"5da73b18.815574","name":"Sensor Open Notifications","info":"","x":170,"y":1780,"wires":[]},{"id":"c1c15248.8912f","type":"api-current-state","z":"5da73b18.815574","name":"Garage External","server":"b4442cdf.ce6f4","version":1,"outputs":2,"halt_if":"on","halt_if_type":"str","halt_if_compare":"is","override_topic":false,"entity_id":"binary_sensor.garage_external_door","state_type":"str","state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","blockInputOverrides":false,"x":840,"y":1980,"wires":[["99ed4481.b9fa08"],[]]},{"id":"ddd18552.49b758","type":"api-current-state","z":"5da73b18.815574","name":"Laundry Door","server":"b4442cdf.ce6f4","version":1,"outputs":2,"halt_if":"on","halt_if_type":"str","halt_if_compare":"is","override_topic":false,"entity_id":"binary_sensor.laundry_door","state_type":"str","state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","blockInputOverrides":false,"x":840,"y":2100,"wires":[["99ed4481.b9fa08"],[]]},{"id":"268a1463.02673c","type":"api-current-state","z":"5da73b18.815574","name":"Garage Internal","server":"b4442cdf.ce6f4","version":1,"outputs":2,"halt_if":"on","halt_if_type":"str","halt_if_compare":"is","override_topic":false,"entity_id":"binary_sensor.garage_internal_door","state_type":"str","state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","blockInputOverrides":false,"x":840,"y":2040,"wires":[["99ed4481.b9fa08"],[]]},{"id":"d1bfa8bd.355428","type":"api-current-state","z":"5da73b18.815574","name":"Study Window","server":"b4442cdf.ce6f4","version":1,"outputs":2,"halt_if":"on","halt_if_type":"str","halt_if_compare":"is","override_topic":false,"entity_id":"binary_sensor.study_window","state_type":"str","state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","blockInputOverrides":false,"x":840,"y":2240,"wires":[["99ed4481.b9fa08"],[]]},{"id":"ee03f0eb.12ac4","type":"comment","z":"5da73b18.815574","name":"Doors","info":"","x":810,"y":1800,"wires":[]},{"id":"f96d35b7.d87058","type":"comment","z":"5da73b18.815574","name":"Windows","info":"","x":820,"y":2180,"wires":[]},{"id":"4eb554dc.df9adc","type":"api-current-state","z":"5da73b18.815574","name":"Living Room Window","server":"b4442cdf.ce6f4","version":1,"outputs":2,"halt_if":"on","halt_if_type":"str","halt_if_compare":"is","override_topic":false,"entity_id":"binary_sensor.living_room_window","state_type":"str","state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","blockInputOverrides":false,"x":860,"y":2300,"wires":[["99ed4481.b9fa08"],[]]},{"id":"3fe69935.aeeeb6","type":"api-current-state","z":"5da73b18.815574","name":"Dining Room Window","server":"b4442cdf.ce6f4","version":1,"outputs":2,"halt_if":"on","halt_if_type":"str","halt_if_compare":"is","override_topic":false,"entity_id":"binary_sensor.dining_room_window","state_type":"str","state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","blockInputOverrides":false,"x":860,"y":2360,"wires":[["99ed4481.b9fa08"],[]]},{"id":"cb381ae.2de41e8","type":"api-current-state","z":"5da73b18.815574","name":"Retreat Window","server":"b4442cdf.ce6f4","version":1,"outputs":2,"halt_if":"on","halt_if_type":"str","halt_if_compare":"is","override_topic":false,"entity_id":"binary_sensor.retreat_window","state_type":"str","state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","blockInputOverrides":false,"x":840,"y":2420,"wires":[["99ed4481.b9fa08"],[]]},{"id":"a86490ff.1478a","type":"api-current-state","z":"5da73b18.815574","name":"Bedroom 2 Window","server":"b4442cdf.ce6f4","version":1,"outputs":2,"halt_if":"on","halt_if_type":"str","halt_if_compare":"is","override_topic":false,"entity_id":"binary_sensor.bedroom_2_window","state_type":"str","state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","blockInputOverrides":false,"x":850,"y":2480,"wires":[["99ed4481.b9fa08"],[]]},{"id":"fef95f5f.e8a5","type":"api-current-state","z":"5da73b18.815574","name":"Bedroom 3 Window","server":"b4442cdf.ce6f4","version":1,"outputs":2,"halt_if":"on","halt_if_type":"str","halt_if_compare":"is","override_topic":false,"entity_id":"binary_sensor.bedroom_3_window","state_type":"str","state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","blockInputOverrides":false,"x":850,"y":2540,"wires":[["99ed4481.b9fa08"],[]]},{"id":"42cb55a.18100ac","type":"api-current-state","z":"5da73b18.815574","name":"Bathroom","server":"b4442cdf.ce6f4","version":1,"outputs":2,"halt_if":"on","halt_if_type":"str","halt_if_compare":"is","override_topic":false,"entity_id":"binary_sensor.bathroom_window","state_type":"str","state_location":"payload","override_payload":"msg","entity_location":"data","override_data":"msg","blockInputOverrides":false,"x":820,"y":2600,"wires":[["99ed4481.b9fa08"],[]]},{"id":"99ed4481.b9fa08","type":"function","z":"5da73b18.815574","name":"Message","func":"var sensorname = msg.data.attributes.friendly_name\nmsg.message =\n{\n    \"message\": \"Unable to Arm. \" + sensorname + \" Open.\" \n  }\nreturn msg;\n\n","outputs":1,"noerr":0,"x":1160,"y":2200,"wires":[["de529b2b.c691b8","406924bc.9b067c"]]},{"id":"406924bc.9b067c","type":"api-call-service","z":"5da73b18.815574","name":"TTS","server":"b4442cdf.ce6f4","version":1,"debugenabled":false,"service_domain":"tts","service":"google_translate_say","entityId":"media_player.entryway_speaker","data":"{\"message\":\"{{message.message}}\"}","dataType":"json","mergecontext":"","output_location":"","output_location_type":"none","mustacheAltTags":false,"x":1370,"y":2240,"wires":[[]]},{"id":"de529b2b.c691b8","type":"api-call-service","z":"5da73b18.815574","name":"Notify","server":"b4442cdf.ce6f4","version":1,"debugenabled":false,"service_domain":"notify","service":"notify","entityId":"","data":"{\"title\":\"ALARM\",\"message\":\"{{message.message}}\"}","dataType":"json","mergecontext":"","output_location":"payload","output_location_type":"msg","mustacheAltTags":false,"x":1370,"y":2160,"wires":[[]]},{"id":"b4442cdf.ce6f4","type":"server","z":"","name":"Home Assistant","legacy":false,"addon":true,"rejectUnauthorizedCerts":true,"ha_boolean":"y|yes|true|on|home|open","connectionDelay":true,"cacheJson":true}]

Wow I really like the visuality of NodeRed!
Could be nice if there was some sort of a export possibility to yaml automation. But yeah I know nodered is used for a looooot of things. I’m just trying to keep everything the same, so I don’t end up having a few automations in yaml, some in NodeRed and some directly created in the Automation front-end.

One thing though. The Alarm State, how do you get the information as AhmadK mentioned? The Alarm state does not change if any sensor is open, as the BWalarm does some backend stuff before it gets to the alarm state change?

One might have 3 different arm modes, each with its own set of sensors (and override sections) the alarm should track all sensors? Don’t think so.

The reality is sensors should be checked the moment we know what arm mode is being activated.
I’m thinking about generating a custom event if there are open sensors.

For what it’s worth, many commercial alarm systems operate the way I mentioned, even having a ‘ready’ LED on the keypad.
images

My alarm system has this functionality, although it’s shown as an icon on an LCD screen which you can tap to show open sensors

I appreciate that but imho one of many benefits of software alarms is it’s very flexible and configurable.
The way you mentioned makes sense but I personally prefer more precise diagnostics.

HTML will stop working in 0.115.0

Then don’t update to 0.115 yet.
They’re fast deprecating stuff without giving community devs time to change their code.
So far I’ve no idea how to migrate, mainly because didn’t have time to look into it.

We are still 7 weeks away from 0.115 I was just posting the commits made to remove it in case they offered any insight on how to move from HTML to .js

I get this multiple times per hour. If I disable bwalarm I don’t get it. I can’t figure out what its trying to do. It’s always with ‘id’:21.

I’m running 112.4 HassOS 4.11 Supervisor 228 on Raspberry PI - all current.
bwalarm is v 1.12.6

Has been a problem for many many prior versions but seems worse lately. Maybe worse with 112… but happened long before… Is something deprecated that isn’t alerting? Anyone see this and have tips?

2020-07-14 12:06:41 DEBUG (MainThread) [homeassistant.components.websocket_api.http.connection.2807739760] Received {'type': 'config/auth/list', 'id': 21}
2020-07-14 12:06:41 ERROR (MainThread) [homeassistant.components.websocket_api.http.connection.2807739760] Error handling message: Unauthorized
2020-07-14 12:06:41 DEBUG (MainThread) [homeassistant.components.websocket_api.http.connection.2807739760] Sending {'id': 21, 'type': 'result', 'success': False, 'error': {'code': 'unauthorized', 'message': 'Unauthorized'}}

Is your client logged in as admin or user?

Well there it is. Thanks. I set the tablet id to admin and the complaining goes away. I don’t recall seeing that as a tip in the documentation. Thanks for enlightening me.

Well, it took me some time to realise that the ugly message is related to a HA API call that works only if one uses admin’s account.
Since then I changed code so it checks if current user’s account and makes the call only if current user is an admin.
However, for some reason it does exist in my dev code but not in master one. Will fix it soon.
Thanks for pointing it out!

1 Like

I got a message tonight saying “This component is not working”.
This has been working for weeks.

I tried restarts, etc.
I backed everything up, and uninstalled Bwalarm, and reinstalled. No success.
I’ve cleared browser cache, etc and still nothing.

Any ideas please?

Did you check the home assistant log like it asks you to do?

Yeah I did. Could not find anything at all pertaining to Bwalarm.

EDIT: Replaced my Bwalarm.yaml, restarted and its working again. Don’t know what could have changed.

EDIT 2: So I had previously added name, under platform: bwalarm. This was never a problem until now, as its breaking the component.
Any ideas how I can rename the entity now? ie. alarm_control_panel.house_alarm

platform: bwalarm
name: House Alarm

If you can reproduce the issue and open a new one on Github, I’m happy to look into it

What exactly and how does break the component?

use house_alarm as name and it will be your object_id - part of entity_id in terms of HA.

If you want to change what’s displayed on panel (possibly you don’t) then it’s panel_title at panel level.

To reproduce the issue, as above, if I just add
name: House Alarm

into bwalarm.yaml, the entity id does indeed change to
alarm_control_panel.house_alarm.

I can even add this entity into the alarm card in lovelace and control the alarm.

However, it breaks the Bwalarm control panel, and I get the message as above.
“This componenent is not working. Check the Home Assistant log for more details.”

I’ve checked the log - there is nothing pertaining to this error at all.

I mean, its not a huge deal breaker, but I just don’t understand how I’ve had it working for so long without any issue. I’ve now had to go through and change the entity ID for all my automations.

I’m about to link two Home Assistant instances together with one as master and one as slave. I therefore think I need to rename my alarm_control_panel.house so that I can differentiate between the two. I tried to do this in /config/custom_components/bwalarm/alarm_control_panel.py
line 401 by renaming

  await hass.components.panel_custom.async_register_panel(
        webcomponent_name='alarm',
        frontend_url_path="alarm",
        html_url=url,
        sidebar_title='Alarm',
        sidebar_icon='mdi:shield-home',
        config={"alarmid": "alarm_control_panel.house"},
    )

but this did not work! :rofl: :rofl: any tips?!

EDIT: Figured it out. There was another line to edit (line 305) that seems to have done it.

Cheers

So what does your master-slave concept mean?

That I’d be able to view and interact the sensors from one HA directly natively in the other