Homeassistant手机通知功能

设置要求

  • (APP下载链接)需要在手机上下载homeassistant客户端,然后使用客户端登录到homeassistant中
  • 登录后,给app权限让app能够创建手机的实体出来
  • 在手机的设置-通知-找到homeassistant软件,允许该软件通知等一些权限(一定要开放,不然不会通知)

调用服务测试

《Homeassistant手机通知功能》
点击开发者工具,然后选择服务,在服务栏输入noti然后选择带app后缀的就是你手机的实体
《Homeassistant手机通知功能》
然后在数据处输入下面的数据,然后点击调用

    title: "Motion Detected in Backyard"
    message: "Someone might be in the backyard."

手机上面应该就会出现通知了
《Homeassistant手机通知功能》

通知的设置

通知的完整文档

链接
这里简要说一下
分组通知(可以让通知不在一个下拉列表中,方便消息分类)
数据处数据:

    message: Motion detected
    data:
      group: Motion # name of the group you wish to use

替换通知(当同一个tag下的数据再次被收到的时候,替换当前为tag标签的通知)

    title: "Motion Detected in Backyard"
    message: "Someone might be in the backyard."
    data:
      tag: tag

清除通知(通过message值为clear_notification,来删除当前为tag标签的通知)

    message: clear_notification
    data:
      tag: tag

向多个设备发送通知

为了向多个设备发送通知,必须设置一个通知的类,让通知的类包含需要发送的设备

notify:
  - name: ALL_DEVICES
    platform: group
    services:
      - service: mobile_app_iphone_one
      - service: mobile_app_iphone_two
      - service: mobile_app_ipad_one
      - service: mobile_app_pixel_4_xl
    service: notify.ALL_DEVICES
    data:
      message: "Something happened at home!"

然后在设备中选择notify.ALL_DEVICES,在数据中输入message: “Something happened at home!”,这样就能够将message这条消息发送给所有设备。

改变通知的时候上面图标的颜色

    title: "Motion Detected in Backyard"
    message: "Someone might be in the backyard."
    data:
      color: '#2DF56D' # or 'red'

通知单击操作(当消息弹出,又用户点击时触发操作)

    title: "Motion Detected in Backyard"
    message: "Someone might be in the backyard."
    data:
      clickAction: 'http://www.baidu.com' # action when clicking main notification

通知频道的设置
为了创建通知,您需要指定要使用的频道。默认情况下,如果未定义通道,则所有通知都使用常规。
如果未提供频道的默认值,则如下所示:
重要性:默认,这意味着默认通知的重要性

振动模式:振动禁用

LED颜色:LED禁用
如果要创建频道:

    title: "Motion Detected in Backyard"
    message: "Someone might be in the backyard."
    data:
      channel: Motion # name of the channel you wish to create or utilize

则会创建一个为Montion的频道

删除频道

    message: remove_channel
    data:
      channel: Motion # name of the channel you wish to remove

确定频道的属性

  • 频道的重要性
    设置通知的通道时,还可以选择为每个通知设置通道的重要性。此属性的可能值为“high”、“low”、“max”、“min”和“default”。

      message: Motion Detected
      data:
        channel: Motion # For devices on Android 8.0+ only
        importance: high
    
  • 通知振动模式
    可以通过设置vibrationPattern属性来设置通道的振动模式。可能的值是一个数字列表。例如“100,1000,100,1000,100”等。对应为“off time,on time,off time,on time,off time”等。

      message: Motion Detected
      data:
        vibrationPattern: "100, 1000, 100, 1000, 100" # The pattern you wish to set for vibrations
        channel: Motion # For devices on Android 8.0+ only
    
  • 通知LED颜色
    一些Android设备有一个多色的通知LED。通过设置ledColor属性,可以控制LED闪烁的颜色。可能的值与属性颜色相同,例如“2DF56D”或“red”。

      message: Motion detected
      data:
        ledColor: "red" # Set the LED to red
        channel: Motion # For devices on Android 8.0+ only          
    

通知主体
如果您的通知将有大量文本(超过6行),您可以通过设置主题选择显示较小的文本

    message: "Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet."
    title: "Long text"
    data:
      subject: "Subject for long text"

通知自动删除时间
您可以设置通知在自动删除/取消之前在用户设备上显示的时间。您可以使用timeout属性和以秒为单位的值来实现这一点。

    message: Motion Detected
    data:
      timeout: 600 # How many seconds the notification should be received by the device

通知消息HTML的形式
您可以向通知的消息中添加一些自定义HTML标记。

    message: 'This is a <b><span style="color: red">HTML</span></b> <i>text</i><br><br>This is a text after a new line'
    title: "Cool HTML formatting"

通知图标
您可以通过提供图标url来设置通知的图标。提供的URL必须是可公开访问的,也可以是相对路径(即/local/icon)/图标.png),有关详细信息,请参阅附件。需要注意的是,如果您设置了图像,那么Android将不会显示通知的图标,图像将显示在其位置。因此消息将与图像一起显示,并以图像作为图标。

    message: Motion Detected
    data:
      icon_url: "https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fa4.att.hudong.com%2F27%2F67%2F01300000921826141299672233506.jpg&refer=http%3A%2F%2Fa4.att.hudong.com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=jpeg?sec=1615725993&t=e7e76936feed6e4a49da171637ba98fa"

文本到语音通知
您可以让您的设备说出通知,而不是在设备上发布通知。此通知的工作方式与其他通知不同。您将设置消息:TTS和实际的文字发言将在标题。当前支持仅限于设备上设置的当前文本到语音区域设置。如果处理消息时出错,您将看到设备上出现toast消息。检查以确保Google文本到语音引擎是最新的,并设置为默认值,以防您遇到任何问题。

    message: TTS
    title: Motion has been detected

注意: 默认情况下,文本到语音通知使用音乐流,因此只要设备的音量未设置为0,它们将绕过设备上的振铃器模式。您可以选择使用channel:alarm_stream ,让您的通知无论音乐音量大小都能发出。

    message: TTS
    title: Motion has been detected
    data:
      channel: alarm_stream

如果您发现您的报警流音量太低,可以使用频道:channel:alarm_stream_max ,它将临时将报警流音量设置为最大音量,播放通知,然后恢复到原始音量。

    message: TTS
    title: Alarm has been triggered
    data:
      channel: alarm_stream_max

带条件的语音设置

  - alias: Notify of Motion
    trigger:
      ...
    condition:
      - condition: state
        entity_id: sensor.<your_device_id_here>_ringer_mode # Only speak if the Ringer is normal (not vibrate or silent)
        state: normal
      - condition: state
        entity_id: sensor.<your_device_id_here>_do_not_disturb_sensor # Only speak if DND is not enabled
        state: 'off'
      - condition: state
        entity_id: sensor.<your_device_id_here>_audio_mode # Only speak if the phone is idle (not ringing or in a call)
        state: normal
      - condition: state
        entity_id: sensor.<your_device_id_here>_is_music_active # Only speak if the phone is not playing music
        state: 'off'
    action:
      - service: notify.mobile_app_<your_device_id_here>
        data:
          message: TTS
          title: Motion has been detected
    原文作者:_WILLPOWER_
    原文地址: https://blog.csdn.net/qq_37429313/article/details/113795979
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞