def online_evt(device, message): result = DeviceEventModel.online(device=device, message=message) if result: ip = message['clientIp'] online_time = message['lastTime'] ding_alert(f'{device} 上线 IP: {ip} [{online_time}]') return
def error_evt(device, message): """ 协议解析错误 """ ding_alert(f'{device} 协议错误: {message}') # Todo 记录错误消息 return
def reboot_evt(device, message): ding_alert(f'{device} 重启: {message}') return
def script_query_evt(device, message): DeviceEventModel.update_attr(device=device, message=message) ding_alert(f'{device} 查询设备脚本: {message}') return
def attr_set_evt(device, message): DeviceEventModel.update_attr(device=device, message=message) ding_alert(f'{device} 设置设备属性: {message}') return
def state_query_evt(device, message): DeviceEventModel.update_state(device=device, message=message) ding_alert(f'{device} 查询设备状态: {message}') return
def state_report_evt(device, message): DeviceEventModel.update_state(device=device, message=message) ding_alert(f'{device} 上报设备状态: {message}') return
def upgrade_evt(device, message): ding_alert(f'{device} 升级: {message}') return
def offline_evt(device, message): result = DeviceEventModel.offline(device=device, message=message) if result: offline_time = message['lastTime'] ding_alert(f'{device} 离线 [{offline_time}]') return