How to expand your HA MQTT discovery code for zones
## Alarm system
MG5050

## Environment
RPI3

### Git branch
Main

## Question
I would like to change (or add) to your homeassistant.py code, so that for each zone, a binary_sensor entity is added for the following zone states; alarm, was_in_alarm, trouble, and rf_low_battery_trouble. I would also like to add a switch entity for each that represents the bypass state, and can control is via a command. Something like the below. I don't know how to do this? Should I branch your code, or copy our repo and set up a new repo and add that as a Add-On Repository? Sorry, I've not even tested the code below, I don't know how.

    def _process_zone_statuses(self, zone_statuses, device, device_sn):
        for z_key, p_status in zone_statuses.items():
            if z_key not in self.zones:
                continue

            zone = self.zones[z_key]

            open_topic = '{}/{}/{}/{}/{}'.format(
                cfg.MQTT_BASE_TOPIC,
                cfg.MQTT_STATES_TOPIC,
                cfg.MQTT_ZONE_TOPIC,
                sanitize_key(zone['key']),
                'open'
            )

            alarm_topic = '{}/{}/{}/{}/{}'.format(
                cfg.MQTT_BASE_TOPIC,
                cfg.MQTT_STATES_TOPIC,
                cfg.MQTT_ZONE_TOPIC,
                sanitize_key(zone['key']),
                'alarm'
            )

            alarmed_topic = '{}/{}/{}/{}/{}'.format(
                cfg.MQTT_BASE_TOPIC,
                cfg.MQTT_STATES_TOPIC,
                cfg.MQTT_ZONE_TOPIC,
                sanitize_key(zone['key']),
                'was_in_alarm'
            )

            tamper_topic = '{}/{}/{}/{}/{}'.format(
                cfg.MQTT_BASE_TOPIC,
                cfg.MQTT_STATES_TOPIC,
                cfg.MQTT_ZONE_TOPIC,
                sanitize_key(zone['key']),
                'tamper'
            )

            battery_topic = '{}/{}/{}/{}/{}'.format(
                cfg.MQTT_BASE_TOPIC,
                cfg.MQTT_STATES_TOPIC,
                cfg.MQTT_ZONE_TOPIC,
                sanitize_key(zone['key']),
                'rf_low_battery_trouble'
            )

            bypass_topic = '{}/{}/{}/{}/{}'.format(
                cfg.MQTT_BASE_TOPIC,
                cfg.MQTT_STATES_TOPIC,
                cfg.MQTT_ZONE_TOPIC,
                sanitize_key(zone['key']),
                'bypassed'
            )

            bypass_command_topic = '{}/{}/{}/{}/{}'.format(
                cfg.MQTT_BASE_TOPIC,
                cfg.MQTT_CONTROL_TOPIC,
                cfg.MQTT_ZONE_TOPIC,
                sanitize_key(zone['key'])
            )

            open_config = dict(
                name=zone['label'],
                unique_id="{}_zone_{}_open".format(device_sn, zone['key']),
                state_topic=open_topic,
                device_class="motion",
                availability_topic=self.availability_topic,
                payload_on="True",
                payload_off="False",
                device=device
            )

            alarm_config = dict(
                name='{} (alarm)'.format(zone['label']),
                unique_id="{}_zone_{}_alarm".format(device_sn, zone['key']),
                state_topic=alarm_topic,
                device_class="problem",
                availability_topic=self.availability_topic,
                payload_on="True",
                payload_off="False",
                device=device
            )

            alarmed_config = dict(
                name='{} (alarmed)'.format(zone['label']),
                unique_id="{}_zone_{}_alarmed".format(device_sn, zone['key']),
                state_topic=alarmed_topic,
                device_class="problem",
                availability_topic=self.availability_topic,
                payload_on="True",
                payload_off="False",
                device=device
            )

            tamper_config = dict(
                name='{} (tamper)'.format(zone['label']),
                unique_id="{}_zone_{}_tamper".format(device_sn, zone['key']),
                state_topic=tamper_topic,
                device_class="problem",
                availability_topic=self.availability_topic,
                payload_on="True",
                payload_off="False",
                device=device
            )

            battery_config = dict(
                name='{} (battery)'.format(zone['label']),
                unique_id="{}_zone_{}_battery".format(device_sn, zone['key']),
                state_topic=battery_topic,
                device_class="problem",
                availability_topic=self.availability_topic,
                payload_on="True",
                payload_off="False",
                device=device
            )

            bypass_config = dict(
                name='{} (bypassed)'.format(zone['label']),
                unique_id="{}_zone_{}_bypassed".format(device_sn, zone['key']),
                state_topic=bypass_topic,
                command_topic=bypass_command_topic,
                availability_topic=self.availability_topic,
                payload_on="bypass",
                payload_off="clear_bypass",
                state_on="True",
                state_off="False",
                optimistic=False,
                qos=0,
                retain=True,
                icon="mdi:motion-sensor-off",
                device=device
            )

            open_configuration_topic = '{}/binary_sensor/{}/{}/config'.format(
                cfg.MQTT_HOMEASSISTANT_DISCOVERY_PREFIX,
                device_sn,
                sanitize_key(zone['key'])
            )

            alarm_configuration_topic = '{}/binary_sensor/{}/{}_alarm/config'.format(
                cfg.MQTT_HOMEASSISTANT_DISCOVERY_PREFIX,
                device_sn,
                sanitize_key(zone['key'])
            )

            alarmed_configuration_topic = '{}/binary_sensor/{}/{}_alarmed/config'.format(
                cfg.MQTT_HOMEASSISTANT_DISCOVERY_PREFIX,
                device_sn,
                sanitize_key(zone['key'])
            )

            tamper_configuration_topic = '{}/binary_sensor/{}/{}_tamper/config'.format(
                cfg.MQTT_HOMEASSISTANT_DISCOVERY_PREFIX,
                device_sn,
                sanitize_key(zone['key'])
            )

            battery_configuration_topic = '{}/binary_sensor/{}/{}_battery/config'.format(
                cfg.MQTT_HOMEASSISTANT_DISCOVERY_PREFIX,
                device_sn,
                sanitize_key(zone['key'])
            )

            bypass_configuration_topic = '{}/switch/{}/{}_bypass/config'.format(
                cfg.MQTT_HOMEASSISTANT_DISCOVERY_PREFIX,
                device_sn,
                sanitize_key(zone['key'])
            )

            self.publish(open_configuration_topic, json.dumps(open_config), 0, cfg.MQTT_RETAIN)
            self.publish(alarm_configuration_topic, json.dumps(alarm_config), 0, cfg.MQTT_RETAIN)
            self.publish(alarmed_configuration_topic, json.dumps(alarmed_config), 0, cfg.MQTT_RETAIN)
            self.publish(tamper_configuration_topic, json.dumps(tamper_config), 0, cfg.MQTT_RETAIN)
            self.publish(battery_configuration_topic, json.dumps(battery_config), 0, cfg.MQTT_RETAIN)
            self.publish(bypass_configuration_topic, json.dumps(bypass_config), 0, cfg.MQTT_RETAIN)
