嘿,伙计们,喜欢这个软件和论坛。我设置了几个区域,我的工作,我的家,我妻子的工作和孩子的学校。

我想出了如何在任何人离开或进入某个区域时在应用程序上获得通知。问题是我必须为第1个人进入区域1、第1个人离开区域1、第1个人进入区域2等编写一个自动化程序。如何设置它,使我得到通知时,任何人来或从一个区域所有在一个自动化?

任何帮助我都将非常感激。

将它们全部作为触发器添加到一个自动化中。

展示几个自动化,我们可以展示如何组合它们。

嘿,谢谢汤姆,这里有一些,抱歉我在打电话,所以格式可能有点奇怪。
编辑:固定的代码块。

女儿到学校- id: 1609734649963别名:Jord到达百年描述:"触发器:-平台:分区entity_id:人。jordyn区域:区域。百年事件:输入条件:[]action: - service: notify。joord Arrived at Centennial - service: notify。mobile_app_richelles_s10_mobile_app data: title: Notification message: Jord Arrived at Centennial mode: single daughter leaves school - id: '1609854795066' alias: Jord leaves Centennial description: " trigger: - platform: zone entity_id: person. "jordyn区域:区域。百年纪念活动:休假条件:[]行动:-服务:通知。mobile_app_craigs_s20_mobile_app数据:title:通知消息:Jord Left Centennial - service: notify。mobile_app_richelles_s10_mobile_app data: title: Notification message: Jord Left Centennial mode: single son leaves school - id: '1609865230284' alias: Brayden Left Centennial description: " trigger: - platform: zone entity_id: person. "brayden区域:区域。百年纪念活动:休假条件:[]行动:-服务:通知。mobile_app_craigs_s20_mobile_app数据:title:通知消息:Brayden Left Centennial - service: notify。mobile_app_richelles_s10_mobile_app data: title: Notification message: Brayden Left Centennial模式:single son arrived at school: - id: '1609813788530' alias: Brayden arrived Centennial description: " trigger: - platform: zone entity_id: person. "brayden区域:区域。centennial event: enter condition: [] action: - service: notify.mobile_app_craigs_s20_mobile_app data: title: Notification message: Brayden Arrived at Centennial - service: notify.mobile_app_richelles_s10_mobile_app data: title: Notification message: Brayden Arrived at Centennial mode: single

试试这个:

—alias: notify on zone enter/leave trigger:—platform: zone entity_id:—person。brayden——人。jordyn区域:区域。百年事件:enter - platform: zone entity_id: - person。brayden——人。jordyn区域:区域。百年事件:离开动作:-变量:事件:"{{'左'如果触发器。事件== 'leave' else 'arrived at'}}" person: "{{trigger.to_state.attributes.friendly_name}}" zone: "{{trigger.zone.attributes.friendly_name}}" - service: notify。Mobile_app_craigs_s20_mobile_app data: message: > {{person + ' ' + event ' ' + zone}} - service: notify。Mobile_app_richelles_s10_mobile_app数据:消息:> {{person + ' ' +事件' ' + zone}}

您只需要为每个区域添加一个输入和离开触发器。不幸的是,你不能为多个区域或离开和进入事件设置一个触发器。
编辑:
请正确格式化您的代码。阅读社区指引在这里, 11点。

3喜欢

嘿,伙计,非常感谢你的帮助,我现在有点忙不过来,等我回家再试。我是否只在automations.yaml中输入这些file or try to do in the UI? also, if i wanted to add more people, just put them under person.jordyn? what about adding a few more zones? thanks again Burningstone, appreciate you taking your time to help.

是的,没错。

将其添加到automation .yaml中。

我编辑了我的帖子,并添加了一个如何添加更多区域的说明。

非常感谢,等不及尝试摆脱大约20个自动化设备了,哈哈…

抱歉代码出了问题,我当时在打电话。我不能100%确定我理解为区域添加触发器,需要做一些阅读…

你好,@xman111-这里有一个巩固一些东西的可能性。

首先,创建一个通知组——然后你需要做的就是通知组,而不是单独通知每个人。把下面的东西放进你的configuration.yaml通知:(或在你的notifications.yaml文件如果你正在使用),不幸的是,没有重载通知,所以你必须重新开始(除非其他人知道一个更简单的方法):

—service: mobile_app_richelles_s10_mobile_app—service: mobile_app_craigs_s20_mobile_app

通知组的Ref:通知组-家居助理(Home A19463331伟德国际ssistant .io)

然后,在自动化中,像这样构造它:

—alias:分区通知触发器:—platform:分区entity_id:—device_tracker。person_one——device_tracker。person_two——device_tracker。person_three区域:区域。首页event: enter - platform: zone entity_id: - device_tracker.person_one - device_tracker.person_two - device_tracker.person_three zone: zone.home event: leave - platform: zone entity_id: - device_tracker.person_one - device_tracker.person_two - device_tracker.person_three zone: zone.school event: enter - platform: zone entity_id: - device_tracker.person_one - device_tracker.person_two - device_tracker.person_three zone: zone.school event: leave action: - service: notify.family_devices data: message: > {% if trigger.event == "leave" %} {{ trigger.from_state.attributes.friendly_name }} left {{ trigger.zone.attributes.friendly_name }} {% else %} {{ trigger.from_state.attributes.friendly_name }} entered {{ trigger.zone.attributes.friendly_name }} {% endif %}

我在自动化中使用了两个“配对”——一个用于首页,一个用于学校.您可以复制/粘贴这些以添加更多的区域到自动化。我找不到这些可以组合在一起的地方变成这样的东西,进一步简化它(也许未来的更新会解决它):

区:区。首页- zone.school

行动Section是服务打电话给你在通知:配置文件的一部分。中的模板数据部分简单地从trigger.eventtrigger.entity_id.请注意,模板是通用的,当您有更多的区域到触发器部分时,不需要更改。

澄清一下:我不能完全测试它,但它确实通过了配置检查……: crossed_fingers:

如果你遇到问题,让我知道!

2喜欢

谢谢KSC把这些都打出来,你们太棒了,我等不及回家试一试了。在我弄乱所有东西之前,我会备份我的配置。我真的很感激,先生!

是的,我终于为我所有的配置文件建立了一个自动备份…

1像

是的,要把所有的东西都重新制作出来还挺费劲的。这是一件我无法相信的事情,你必须做的智能的事情,很高兴看到它可以在家庭助理,我有大约15个备份,在Zwave之前,在Caseta之前,等等…哈哈…19463331伟德国际

我正在思考这个问题,还有一个问题。在我的到达家庭自动化,我让它伟德betvictor手机版打开前灯,关闭我们的警报,然后通知我和我的妻子。这个功能也能实现吗还是通知功能可以单独实现报警和照明功能呢?

这绝对可以做到,我也会这么做。将其他服务添加到行动自动化的一部分。例如:

操作:—service: notify。family_devices数据:标题:通知消息:> {% if触发器。Event == "leave" %} {{trigger.from_state.attributes.friendly_name}} left {{trigger.zone.attributes.friendly_name}} {% else %} {{trigger.from_state.attributes.friendly_name}}进入{{trigger.zone.attributes.friendly_name}} {% endif %} - service: light. friendly_nameturn_on entity_id: light.front_lights #你也可以添加属性,比如亮度和过渡。

你可以通过添加逻辑来确定太阳是升起还是落下来让它更聪明一点service_template(确保你有太阳组件在你configuration.yaml文件:

- service_template: > {% if is_state('sun.sun','below_horizon') %} light。打开{% else %}灯。turn_off entity_id: light.front_lights

再次感谢,我无法表达我有多感激。我花这么多时间在这上面,我的妻子和孩子都很生气,哈哈。这一切可以在UI或不麻烦,只是直接在yaml文件中完成?

把它们都放进去,然后试着执行它,但是什么也没发生。我会继续摆弄它。

你不能执行它,你需要进入/离开一个区域。当您手动触发它时,它将跳过所有条件和触发器,直接跳转到动作部分,动作部分无法工作,因为它使用了来自触发器的数据,而当您手动触发它时,这些数据是不可用的。
要测试区域不离开您的家,您可以使用device_tracker。看到服务

1像

感谢的人。给了我希望,多么伟大的社区。谢谢你对我这么宽容,哈哈。

1像

嘿,伙计们,再试一次,我在automations.yaml的别名行中得到一个重复的映射键错误。

它说在第156行第3列有重复的映射键:
别名:测试

误差是谷歌。

您不止一次地列出了一个参数。如果你发布你的自动化,我们可以帮你解决。有时它不是确切的一行,而是它附近的一行(取决于这里是否有语法错误)

是的,这就是为什么我不能完全测试我发布的内容…

谢谢KSC会发布代码…