完善中间件自动更新逻辑
This commit is contained in:
@@ -4,5 +4,5 @@ from pydantic import BaseModel
|
||||
class IotDeviceCommandRequest(BaseModel):
|
||||
id: str | None = None
|
||||
command: str | None = None
|
||||
project: str | None = None
|
||||
dept_id: str | None = None
|
||||
device_type: str | None = None
|
||||
|
||||
@@ -16,7 +16,7 @@ class MqttTopic:
|
||||
# 不足的层级用 None 补齐,避免属性缺失
|
||||
parts += [None] * (self.LEVELS - len(parts))
|
||||
|
||||
self.project: Optional[str] = parts[0]
|
||||
self.dept_id: Optional[str] = parts[0]
|
||||
self.domain: Optional[str] = parts[1]
|
||||
self.device_type: Optional[str] = parts[2]
|
||||
self.device_id: Optional[str] = parts[3]
|
||||
@@ -25,7 +25,7 @@ class MqttTopic:
|
||||
@classmethod
|
||||
def from_parts(
|
||||
cls,
|
||||
project: Optional[str] = None,
|
||||
dept_id: Optional[str] = None,
|
||||
domain: Optional[str] = None,
|
||||
device_type: Optional[str] = None,
|
||||
device_id: Optional[str] = None,
|
||||
@@ -43,7 +43,7 @@ class MqttTopic:
|
||||
map(
|
||||
_v,
|
||||
[
|
||||
project,
|
||||
dept_id,
|
||||
domain,
|
||||
device_type,
|
||||
device_id,
|
||||
@@ -65,7 +65,7 @@ class MqttTopic:
|
||||
map(
|
||||
_v,
|
||||
[
|
||||
self.project,
|
||||
self.dept_id,
|
||||
self.domain,
|
||||
self.device_type,
|
||||
self.device_id,
|
||||
@@ -80,7 +80,7 @@ class MqttTopic:
|
||||
用于 publish 场景
|
||||
"""
|
||||
parts = [
|
||||
self.project,
|
||||
self.dept_id,
|
||||
self.domain,
|
||||
self.device_type,
|
||||
self.device_id,
|
||||
@@ -101,7 +101,7 @@ class MqttTopic:
|
||||
return f"<MqttTopic {self.to_topic()}>"
|
||||
|
||||
def is_status(self) -> bool:
|
||||
return self.domain == "status"
|
||||
return self.domain == "status" and self.resource == "info"
|
||||
|
||||
def is_cmd(self) -> bool:
|
||||
return self.domain == "cmd"
|
||||
|
||||
Reference in New Issue
Block a user