本文整理汇总了Python中models.event.Event.create_event方法的典型用法代码示例。如果您正苦于以下问题:Python Event.create_event方法的具体用法?Python Event.create_event怎么用?Python Event.create_event使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.event.Event
的用法示例。
在下文中一共展示了Event.create_event方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: send_power_off
# 需要导入模块: from models.event import Event [as 别名]
# 或者: from models.event.Event import create_event [as 别名]
def send_power_off():
if request.json:
description = request.json.get('description') or 'website off'
else:
description = 'website off'
resp = arduino.turn_off()
if resp.get('return_value', 0) == 1:
Event.create_event(EventType.off, description)
return 'OK', 200
return 'Error', 500
示例2: monitor_ac_usage
# 需要导入模块: from models.event import Event [as 别名]
# 或者: from models.event.Event import create_event [as 别名]
def monitor_ac_usage(minutes=30):
""" Checks how long AC has been running and shuts it off after max is reached.
:param minutes: How many minutes to let the AC run continuously.
:return:
"""
with app.app_context():
event = Event.last_event()
if event and event.event != EventType.off:
off_time = event.timestamp.replace(minutes=+minutes)
now = arrow.utcnow()
if off_time < now:
if arduino.turn_off():
Event.create_event(EventType.off, "AutoOff Timer")