コード例 #1
0
    def publish_properties(self):
        """publish device and node properties"""
        # node properties
        properties = (
            Property(b'$homie', b'2.0.1', True),
            Property(b'$online', b'true', True),
            Property(b'$name', self.settings.DEVICE_NAME, True),
            Property(b'$fw/name', self.settings.DEVICE_FW_NAME, True),
            Property(b'$fw/version', __version__, True),
            Property(b'$implementation', bytes(sys.platform, 'utf-8'), True),
            Property(b'$localip', utils.get_local_ip(), True),
            Property(b'$mac', utils.get_local_mac(), True),
            Property(b'$stats/interval', self.stats_interval, True),
            Property(b'$nodes', b','.join(self.node_ids), True)
        )

        # publish all properties
        for prop in properties:
            self.publish(*prop)

        # device properties
        for node in self.nodes:
            try:
                for prop in node.get_properties():
                    self.publish(*prop)
            except NotImplementedError:
                raise
            except Exception as error:
                self.node_error(node, error)
コード例 #2
0
ファイル: device.py プロジェクト: palmtreefrb/microhomie
    def publish_properties(self):
        """publish device and node properties"""
        publish = self.publish

        # device properties
        publish(b"$homie", b"3.0.1")
        publish(b"$name", self.settings.DEVICE_NAME)
        publish(b"$state", b"init")
        publish(b"$fw/name", b"Microhomie")
        publish(b"$fw/version", __version__)
        publish(b"$implementation", bytes(sys.platform, "utf-8"))
        publish(b"$localip", utils.get_local_ip())
        publish(b"$mac", utils.get_local_mac())
        publish(b"$stats", b"interval,uptime,freeheap")
        publish(b"$stats/interval", self.stats_interval)
        publish(b"$nodes", b",".join(self.node_ids))

        # node properties
        for node in self.nodes:
            try:
                for propertie in node.get_properties():
                    if propertie:
                        publish(*propertie)
            except NotImplementedError:
                raise
            except Exception as error:
                self.node_error(node, error)
コード例 #3
0
ファイル: device.py プロジェクト: arthurlutz/microhomie
    async def publish_properties(self):
        """publish device and node properties"""
        publish = self.publish

        # device properties
        await publish("$homie", "4.0.0")
        await publish("$name", self.device_name)
        await publish(DEVICE_STATE, STATE_INIT)
        await publish("$implementation", bytes(platform, UTF8))
        await publish(
            "$nodes", ",".join([n.id for n in self.nodes])
        )

        # node properties
        nodes = self.nodes
        for n in nodes:
            await n.publish_properties()

        if self._extensions:
            await publish("$extensions", ",".join(self._extensions))
            if "org.homie.legacy-firmware:0.1.1:[4.x]" in self._extensions:
                await publish("$localip", utils.get_local_ip())
                await publish("$mac", utils.get_local_mac())
                await publish("$fw/name", "Microhomie")
                await publish("$fw/version", __version__)
            if "org.homie.legacy-stats:0.1.1:[4.x]" in self._extensions:
                await self.publish("$stats/interval", str(self.stats_interval))
                # Start stats coro
                launch(self.publish_stats, ())
コード例 #4
0
ファイル: device.py プロジェクト: chris922/microhomie
    async def publish_properties(self):
        """publish device and node properties"""
        publish = self.publish

        # device properties
        await publish(b"$homie", b"3.0.1")
        await publish(b"$name", self.device_name)
        await publish(DEVICE_STATE, b"init")
        await publish(b"$fw/name", b"Microhomie")
        await publish(b"$fw/version", __version__)
        await publish(b"$implementation", bytes(platform, "utf-8"))
        await publish(b"$localip", utils.get_local_ip())
        await publish(b"$mac", utils.get_local_mac())
        await publish(b"$stats", b"interval,uptime,freeheap")
        await publish(
            b"$nodes", b",".join([n.id.encode() for n in self.nodes])
        )

        # node properties
        nodes = self.nodes
        for n in nodes:
            await n.publish_properties()