Here is some code for selfhosted version…just to complete this discussion with some other solutions
// Ãœberwachungsstatus
if ( device.capabilitiesObj && device.capabilitiesObj.homealarm_state ){
if ( device.capabilitiesObj.homealarm_state.value == "disarmed" ){
$deviceElement.classList.toggle('on', false);
}
else{
$deviceElement.classList.toggle('on', true);
}
//Click-Event for Icon for changing mode on touch/click
$deviceElement.addEventListener('click', function() {
if ( nameChange ) { return } // No click when shown capability just changed
if ( longtouch ) {return} // No click when longtouch was performed
if ( device.capabilitiesObj.homealarm_state.value == "disarmed" ){
//$deviceElement.classList.toggle('on', true);
homey.devices.setCapabilityValue({
deviceId: device.id,
capabilityId: 'homealarm_state',
value: 'armed',
}).catch(console.error);
}
else{
//$deviceElement.classList.toggle('on', false);
homey.devices.setCapabilityValue({
deviceId: device.id,
capabilityId: 'homealarm_state',
value: 'disarmed',
}).catch(console.error);
}
});
//register eventhandler for mode change
device.makeCapabilityInstance('homealarm_state', function(value){
var $deviceElement = document.getElementById('device:' + device.id);
if( $deviceElement ) {
if ( device.capabilitiesObj.homealarm_state.value == "disarmed" ){
$deviceElement.classList.toggle('on', false);
}
else{
$deviceElement.classList.toggle('on', true);
}
}
});
}
I’m using the default Heimdall Surveillance Device in Homey (the one with the house+shield and the surveillance modes).
This Icos is showing the alarm in Homeydash (orange background) because it’s recogniced as sensor, but it’s not showing the mode.
For this I added some Code for:
- Showing the state (active/inactive icon)
- Make mode change possible with a click on the icon. It changes only between armed and disarmed.
Put this code into homeydash.app.js, function render_devices( ) somewhere after these lines:
devices.forEach(function(device) {
if (!device.ready) {return}
var $deviceElement = document.createElement(‘div’);