@Tyfoon @Soul think I have some serious progress
Using appdaemon I can now keep the keypad synced with HA. The procedure is as follows:
1) Define the wake up interval of the keypad (using ozwcp for example):
This time (in seconds) will be the maximum amount of time that the alarm status in HA could be changed with the device not knowing (being out of sync).
For now I have set up mine to 5 min (360 sec).
2) Download and install appdaemon
From here install appdaemon.
I used the pip method on my Pi3 explained in the README.
3) Set up appdaemon as in the README
Set up the AppDaemon config with your ha_url
etc… and test the hello_world app is working.
4) Create the appdaemon app
I wrote a small app based something similar from magnushacker here. Thnx @magnushacker!
In the conf/apps/
directory of appdaemon, create a new file called alarmsync.py
.
Copy the following text to the file:
import appdaemon.appapi as appapi
#
# Sync alarm level and HA manual alarm so they are synced to have the correct
# status (on/off) when triggered by the remote from outside HA.
#
# Args:
# HA_alarm: entity ID HA manual alarm (state is either disarmed, armed or pending)
# Zipato_alarm_level: entity ID of the Zipato alarm level (state is either 0 or 255)
# Zipato_alarm_access_cntrl : entity ID of the Zipato alarm access_control
# app name: entity ID of manual alarm state to sync with
class AlarmSync(appapi.AppDaemon):
def initialize(self):
self.listen_state(self.state_change, self.name)
self.log("AlarmSync to %s" % self.args["Zipato_alarm_level"])
def state_change(self, entity, attribute, old, new, kwargs):
if new == 'armed_away':
self.set_state(self.args["Zipato_alarm_level"], state='255')
self.log("Changed Zipato_alarm_level to 255")
self.set_state(self.args["Zipato_alarm_access_cntrl"], state='5')
self.log("Changed Zipato_alarm_access_cntrl to 5")
elif new == 'armed_home':
self.set_state(self.args["Zipato_alarm_level"], state='255')
self.log("Changed Zipato_alarm_level to 255")
self.set_state(self.args["Zipato_alarm_access_cntrl"], state='5')
self.log("Changed Zipato_alarm_access_cntrl to 5")
elif new == 'disarmed':
self.set_state(self.args["Zipato_alarm_level"], state='0')
self.log("Changed Zipato_alarm_level to 0")
self.set_state(self.args["Zipato_alarm_access_cntrl"], state='6')
self.log("Changed Zipato_alarm_access_cntrl to 6")
5) Create the config for the app
Add the following to the end of appdaemon.cfg
(below # Apps
) located in the conf
directory.
[alarm_control_panel.ha_alarm]
module = alarmsync
class = AlarmSync
Zipato_alarm_level = sensor.schlage_link_mini_keypad_rfid_alarm_level_13_1
Zipato_alarm_access_cntrl = sensor.schlage_link_mini_keypad_rfid_access_control_13_9
Note that the following must correspond with your entity ids in HA:
alarm_control_panel.ha_alarm
= HA manual alarm panel
Zipato_alarm_level
= Zipato alarm level sensor
Zipato_alarm_access_cntrl
= Zipato alarm access control sensor
6) Start the daemon or set to start on startup.
As described in the README.
How does it work?
The keypad to HA state updates worked fine with my initial setup, however as discussed above HA to keypad could get out of sync.
With this however, whenever the HA manual alarm state changes (to arm_home
/ arm_away
or disarm
), the app changes the values of the keypad sensor values to match.
Now the cool thing is that the wake up time defines how often the keypad checks on the status of the (now updated) sensor values in HA.
Anytime the sensor values are different in the HA sensors compared to the physical keypad, and the keypad wakes up (in my set up every 5 min), the keypad will take on the values defined in the HA sensors.
Going forward with HA
From this we see that the HA “sensor” type is not ideal for this type of device. The reason being is that HA does not allow us to define sensor values in automation, hence the need for appdaemon.
I am new to HA but maybe it would be good to get the opinion of others as to how these types of situations can be handled more easily in the future. Simply allowing the ability to set the state/value of a sensor (as can be done via the web UI) in an automation would be a great help. And I think this case/device makes a good point for doing so.
I plan to keep making improvements such as including in the app for edge cases (what to do whilst the manual alarm is pending etc).
I will keep testing this and let you know if there are any problems. If you have any questions then fire away. HA seems to have a great community and I have really enjoyed troubleshooting this. Thanks everyone for the motivation