Solved it!
When I added the state_attributes() method to my VisonicAlarm class (which inherit from homeassistant.components.alarm_control_panel:AlarmControlPanel) I overrode the state_attributes() method from the parent class:
@property
def state_attributes(self):
"""Return the state attributes."""
state_attr = {
ATTR_CODE_FORMAT: self.code_format,
ATTR_CHANGED_BY: self.changed_by
}
return state_attr
Which meant that my method (which is now missing the attribute ATTR_CODE_FORMAT) did not share the code_format() anymore:
@property
def state_attributes(self):
""" Return the state attributes of the alarm system. """
return {
STATE_ATTR_SYSTEM_SERIAL_NUMBER: hub.alarm.serial_number,
STATE_ATTR_SYSTEM_NAME: hub.alarm.name,
STATE_ATTR_SYSTEM_MODEL: hub.alarm.model,
STATE_ATTR_SYSTEM_READY: hub.alarm.ready,
STATE_ATTR_SYSTEM_ACTIVE: hub.alarm.active,
STATE_ATTR_SYSTEM_CONNECTED: hub.alarm.connected,
STATE_ATTR_SYSTEM_SESSION_TOKEN: hub.alarm.session_token,
STATE_ATTR_SYSTEM_LAST_UPDATE: hub.last_update,
}
So, all I had to do was to add this link to the attribute list and it worked!
ATTR_CODE_FORMAT: self.code_format,
Finally, this is what solved my problem:
@property
def state_attributes(self):
""" Return the state attributes of the alarm system. """
return {
STATE_ATTR_SYSTEM_SERIAL_NUMBER: hub.alarm.serial_number,
STATE_ATTR_SYSTEM_NAME: hub.alarm.name,
STATE_ATTR_SYSTEM_MODEL: hub.alarm.model,
STATE_ATTR_SYSTEM_READY: hub.alarm.ready,
STATE_ATTR_SYSTEM_ACTIVE: hub.alarm.active,
STATE_ATTR_SYSTEM_CONNECTED: hub.alarm.connected,
STATE_ATTR_SYSTEM_SESSION_TOKEN: hub.alarm.session_token,
STATE_ATTR_SYSTEM_LAST_UPDATE: hub.last_update,
ATTR_CODE_FORMAT: self.code_format,
ATTR_CHANGED_BY: self.changed_by,
ATTR_CHANGED_TIMESTAMP: self._changed_timestamp,
}