Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

定时任务配置格式 #182

Open
hanxi opened this issue Sep 20, 2024 · 1 comment
Open

定时任务配置格式 #182

hanxi opened this issue Sep 20, 2024 · 1 comment
Labels
文档 帮助文档

Comments

@hanxi
Copy link
Owner

hanxi commented Sep 20, 2024

支持采用 crontab 的格式配置定时任务,已经支持下面的任务类型:

  • stop 关机
  • play 播放歌曲
  • play_music_list 播放列表
  • tts 文字转语音
  • refresh_music_list 刷新播放列表
  • set_volume 设置音量
  • set_play_type 设置播放类型,单曲循环 0 , 全部循环 1 , 随机播放 2 , 单曲播放 3 , 顺序播放 4

示例

[
    {
        "expression": "0 8 * * 0-4",
        "name": "play",
        "did": "123456789",
        "arg1": "周杰伦晴天"
    },
    {
        "expression": "10 8 * * 0-4",
        "name": "stop",
        "did": "123456789"
    },
    {
        "expression": "0 9 * * *",
        "name": "play",
        "did": "123456789",
        "arg1": "周杰伦晴天"
    },
    {
        "expression": "0 10 * * *",
        "name": "play_music_list",
        "did": "123456789",
        "arg1": "周杰伦"
    },
    {
        "expression": "30 10 * * *",
        "name": "play_music_list",
        "did": "123456789",
        "arg1": "周杰伦|晴天"
    },
    {
        "expression": "0 7 * * *",
        "name": "tts",
        "did": "123456789",
        "arg1": "早上好!该起床了!"
    },
    {
        "expression": "0 3 * * *",
        "name": "refresh_music_list"
    },
    {
        "expression": "* * * * *",
        "name": "set_volume",
        "did": "123456789",
        "arg1": "25"
    },
    {
        "expression": "* * * * *",
        "name": "set_play_type",
        "did": "123456789",
        "arg1": "2"
    }
]

示例中的意思是:

  • 周一到周五每天 8 点播放歌曲 "周杰伦晴天"
  • 周一到周五每天 8 点 10 分执行关机指令
  • 每天 9 点播放歌曲 "周杰伦晴天"
  • 每天 10 点播放列表 "周杰伦"
  • 每天 10 点 30 分播放列表 "周杰伦" 里的 "晴天"
  • 每天 7 点发出语音 "早上好!该起床了!"
  • 每天 3 点刷新播放列表,用于自动更新目录下的歌曲到播放列表里。
  • 每分钟设置音量为 25
  • 每分钟设置为随机播放

注意星期一是0,星期二是1,星期日是6。
(0-6 or mon,tue,wed,thu,fri,sat,sun)
The first weekday is always monday.

参数意思

  • expression 的格式是标准的 crontab 的格式,用于配置任务的执行时机,如何配置可以直接用下面的 crontab ai 工具生成
  • name 是任务名,目前只支持上面那几种。
  • did 是小爱音箱的设备ID,就是设置页面的音箱型号后面的那串数字。
  • arg1 根据任务不同而不同。
    • play 的 arg1 表示要播放的歌曲名。
    • play_music_list 的 arg1 表示要播放的播放目录名,可以加 | 符合加上目录下面的歌曲名,也可不加。
    • tts 的 arg1 表示要说的语音文字。
@hanxi
Copy link
Owner Author

hanxi commented Sep 29, 2024

0.3.38版本功能。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
文档 帮助文档
Projects
None yet
Development

No branches or pull requests

1 participant