import echo_controller.switch as Switch import echo_controller.sensor as Sensor import echo_controller.blinds as Blinds import echo_controller.air_conditioner as AirConditioner import echo_controller.led_strip as LedStrip class Controller: # These are all the device types with actions device_action_controls = { 'switch' : Switch.Switch.handle_action, 'sensor' : Sensor.Sensor.handle_action, 'blinds' : Blinds.Blinds.handle_action, 'airconditioner' : AirConditioner.AirConditioner.handle_action, 'led_strip': LedStrip.LEDStrip.handle_action } # These are all the output devices device_output_controls = { 'sensor' : Sensor.Sensor.handle_data } @staticmethod def handle_action(device, action, data = {}): device_type = device['type'] return Controller.device_action_controls[device_type](device, action, data) @staticmethod def handle_output_device(device, action, data): device_type = device['type'] return Controller.device_output_controls[device_type](device, action, data)