Mixing in common functionality

I have a lights.py module that contains several apps for various light-related automations. As time has gone on, these apps contain lots of replicated functionality; for example, several apps contain the exact same logic to turn lights on at sunset:

import appdaemon.appapi as appapi

class LivingRoomLights(appapi.AppDaemon):
    """Define a class to represent the app."""

    LIGHTS_SWITCH = 'group.living_room_lights'

    def initialize(self):
        """Initialize."""
        self.run_at_sunset(self.sunset_cb, offset=offset)

    def sunset_cb(self, kwargs):
        """Turn on the living room lights just before sunset."""
        self.turn_on(self.LIGHTS_SWITCH)

class MasterBedroomLights(appapi.AppDaemon):
    """Define a class to represent the app."""

    LIGHTS_SWITCH = 'group.master_bedroom_lights'

    def initialize(self):
        """Initialize."""
        self.run_at_sunset(self.sunset_cb, offset=offset)

    def sunset_cb(self, kwargs):
        """Turn on the living room lights just before sunset."""
        self.turn_on(self.LIGHTS_SWITCH)

I’d appreciate some suggestions on how to extrapolate these common functionalities while retaining the individual apps – as an example, ideally, I’d love to have multiple lighting apps based on location, group, etc. and properly mix in functionality (like turning the lights on at sunset) as needed.

Thoughts? Thank you!

at first you could start to use args.

in your apps.yaml you can set args and then use them in your app like:
self.args[“lightswitch”]

if you put that on the place from self.lights_switch you wouldnt need 2 apps, but just 1 and in the apps.yaml you give another arg for each lightswitch.

Ahh yes, great idea. Thank you!