Timer Service

The timer service allows a workflow to request a countdown timer.  When the timer reaches zero, the timer service will send a callback event which can be used to trigger a workflow (ie a response to the timer being trigger).

The time service accepts a countdown time, rule_name, a callback stream, callback tag, callback value, and callback user id.  

You can reset a specific timer service to restart the countdown timer.  You can have multiple timer services per device at any moment.

Note: The timer service is useful to trigger when a device goes offline and refreshed as long as the device is transmitting data.


Activate Timer Service

Before you can use the timer service, you'll need to request a timer service access token from Medium One at support@mediumone.com.



Import this line at the beginning of your Base Python code.

import HTTP
import json



Add Alarm

Endpoint: https://timer.mediumone.com/add_alarm

Method: POST

Credit cost: 1


 {"token": "1234567", "callback_stream": "m1_timer_test","callback_tag": "m1_test", "callback_msg": "This works!","callback_device_id": "test_device", "rule_name": "test_rule","time": 60}

  • Parameters:
    • token: str|unicode Medium One timer service access token (provided by Medium One)
    • callback_stream: str|unicode Stream for callback event.  Make sure the stream exists.
    • callback_tag: str|unicode Tag for callback event.
    • callback_msg: str|unicode Value associated with callback tag.
    • callback_device_id: str|unicode API basic user associated with callback event. Make sure the user exists.
    • rule_name: str|unicode Time rule name, needs to be unique per device, unless you are resetting the time.
    • time: int seconds to wait before sending event
  • Returns: expiration time in seconds since the epoch


Sample Code

import HTTP
import json callback_device_id = "test_device"
time = 60 # 60 seconds
url = "https://timer.mediumone.com/add_alarm"
header = {"Accept":"application/json","Content-Type":"application/json"}
body = {"token": "1234567", "callback_stream": "m1_timer_test","callback_tag": "m1_test", "callback_msg": "This works!" ,"callback_device_id": "test_device", "rule_name": "test_rule","time": time}
response = HTTP.post(url, json.dumps(body), None, None, 5000, header, 'utf-8', True)