Ejemplo n.º 1
0
    def activate(self):
        self.WLEDReceiver = False
        self._sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
        # check if ip/hostname resolves okay
        self.device_ip = resolve_destination(self._config["ip_address"])

        if not self.device_ip:
            _LOGGER.warning(
                f"Cannot resolve destination {self._config['ip_address']}, aborting device {self.name} activation. Make sure the IP/hostname is correct and device is online."
            )
            return
            # If the device is a WLED device, turn it on
        if wled_identifier(self.device_ip, self.name):
            self.WLEDReceiver = True
            self.wled_state = wled_power_state(self.device_ip, self.name)
            if self.wled_state is False:
                turn_wled_on(self.device_ip, self.name)
        super().activate()
Ejemplo n.º 2
0
    def activate(self):
        if self._config["ip_address"].lower() == "multicast":
            multicast = True
        else:
            multicast = False
        if self._sacn:
            raise Exception("sACN sender already started.")

        if multicast is False:
            self.device_ip = resolve_destination(self._config["ip_address"])
            if not self.device_ip:
                _LOGGER.warning(
                    f"Cannot resolve destination {self._config['ip_address']}, aborting device {self.name} activation. Make sure the IP/hostname is correct and device is online."
                )
                return

            if wled_identifier(self.device_ip, self.name):
                self.WLEDReceiver = True
                self.wled_state = wled_power_state(self.device_ip, self.name)
                if self.wled_state is False:
                    turn_wled_on(self.device_ip, self.name)

        # Configure sACN and start the dedicated thread to flush the buffer
        # Some variables are immutable and must be called here
        self._sacn = sacn.sACNsender(source_name=self.name)

        for universe in range(self._config["universe"],
                              self._config["universe_end"] + 1):
            _LOGGER.info(f"sACN activating universe {universe}")
            self._sacn.activate_output(universe)
            self._sacn[universe].priority = self._config[
                "e131_Packet_Priority"]
            if self._config["ip_address"] == "multicast":
                self._sacn[universe].multicast = True
            else:
                self._sacn[universe].destination = self.device_ip
                self._sacn[universe].multicast = False
        self._sacn._fps = self._config["refresh_rate"]
        self._sacn.start()
        self._sacn.manual_flush = True

        _LOGGER.info("sACN sender started.")
        super().activate()