开门,关门功能

This commit is contained in:
sunjie
2026-01-11 20:18:28 +08:00
parent 24318d692c
commit b8c0d1ad87
2 changed files with 26 additions and 0 deletions
+24
View File
@@ -77,3 +77,27 @@ class AttendanceIot(models.Model):
'cmd': 'uploadFaceInfo'
}, ensure_ascii=False)
}])
# 发送开门信号
def action_send_open_door_sigle(self):
for record in self:
self.env['iot.message'].create([{
'name': '开门',
'topic': f'iot/device/{record.name}',
'device_sn': record.name,
'message_data': json.dumps({
'cmd': 'setDoor',
'value': 'on'
}, ensure_ascii=False)
}])
def action_send_close_door_sigle(self):
for record in self:
self.env['iot.message'].create([{
'name': '开门',
'topic': f'iot/device/{record.name}',
'device_sn': record.name,
'message_data': json.dumps({
'cmd': 'setDoor',
'value': 'off'
}, ensure_ascii=False)
}])
@@ -18,6 +18,8 @@
<field name="remake"/>
<button name="open_record" type="object" string="详情" class="btn-primary"/>
<button name="action_send_sync_sigle" type="object" string="同步数据" class="btn-primary"/>
<button name="action_send_open_door_sigle" type="object" string="开门" class="btn-primary"/>
<button name="action_send_close_door_sigle" type="object" string="关门" class="btn-primary"/>
</tree>
</field>
</record>