platypush.plugins.alarm

class platypush.plugins.alarm.AlarmPlugin(**kwargs)[source]

Alarm/timer plugin.

Requires:

add(when: str, actions: Optional[list] = None, name: Optional[str] = None, audio_file: Optional[str] = None, audio_volume: Union[float, int, None] = None, enabled: bool = True) → str[source]

Add a new alarm. NOTE: alarms that aren’t configured in the platypush.backend.alarm.AlarmBackend will only run in the current session. If you want an alarm to be permanently stored, you should configure it in the alarm backend configuration. You may want to add an alarm dynamically if it’s a one-time alarm instead

Parameters:
  • when – When the alarm should be executed. It can be either a cron expression (for recurrent alarms), or a datetime string in ISO format (for one-shot alarms/timers), or an integer representing the number of seconds before the alarm goes on (e.g. 300 for 5 minutes).
  • actions – List of actions to be executed.
  • name – Alarm name.
  • audio_file – Path of the audio file to be played.
  • audio_volume – Volume of the audio.
  • enabled – Whether the new alarm should be enabled (default: True).
Returns:

The alarm name.

disable(name: str)[source]

Disable an alarm. This will prevent the alarm from executing until re-enabled or until the application is restarted.

Parameters:name – Alarm name.
dismiss()[source]

Dismiss the alarm that is currently running.

enable(name: str)[source]

Enable an alarm.

Parameters:name – Alarm name.
get_alarms() → List[Dict[str, Any]][source]

Get the list of configured alarms.

Returns:List of the alarms, sorted by next scheduled run.
snooze(interval: Optional[float] = 300.0)[source]

Snooze the alarm that is currently running for the specified number of seconds. The alarm will stop and resume again later.

Parameters:interval – Snooze seconds before playing the alarm again (default: 300).