找回密码
 立即注册

微信扫码登录

搜索
查看: 29882|回复: 42

[进阶教程] 大神发新帖子【HA弹出链接】【TTS语音播报】【persistent_noti...

[复制链接]

219

主题

1070

回帖

8066

积分

超级版主

积分
8066
金钱
6747
HASS币
86

教程狂人论坛风云人物突出贡献

发表于 2017-6-16 17:05:58 | 显示全部楼层 |阅读模式
本帖最后由 lidicn 于 2018-2-8 17:02 编辑

TIM截图20180208165309.jpg
原理简介:
  • 通过Scrapy sensor获取uid=4的用户的帖子数量【css_selectors选择器】
  • binary_sensor.trend趋势传感器,用来检测帖子数量是否增加了

sensor:
  - platform: scrape
    resource: https://bbs.hassbian.com/home.php?mod=space&uid=4
    name: new_topic
    select: a[href="home.php?mod=space&uid=4&do=thread&view=me&type=thread&from=space"]
    value_template: '{{ value.split(" ")[1] }}'



binary_sensor:
  - platform: trend
    sensors:
      new_topic_increase:
        entity_id: sensor.new_topic
automation:
  - alias: "Newtopic"
    trigger:
      platform: state
      entity_id: sensor.new_topic
    condition:
      - condition: state
        entity_id: binary_sensor.new_topic_increase
        state: 'on'
    action:
      - service: notify.notifypushbullet
        data_template:
          title: '大神有新帖子'
          message: "大神有新帖子快去看看!"
      - service: tts.baidu_say
        data_template:
          entity_id: media_player.vlc_player
          message:  >
            "大神有新帖子快去看看!"
          cache: false
      - service: persistent_notification.create
        data:
          message: "https://bbs.hassbian.com/home.php?mod=space&uid=4&do=thread&view=me&type=thread&from=space"
          title: "大神囧帅,他终于发新帖子了,快去看看!"[hide]
参考资料:
  • https://home-assistant.io/components/sensor.scrape/
  • https://home-assistant.io/components/binary_sensor.trend/
  • http://www.w3school.com.cn/cssref/css_selectors.asp
  • https://home-assistant.io/components/persistent_notification/
[/hide]


评分

参与人数 1金钱 +5 收起 理由
+ 5 灵活运用,融汇贯通,牛了!

查看全部评分

回复

使用道具 举报

2

主题

66

回帖

234

积分

中级会员

积分
234
金钱
165
HASS币
0
发表于 2018-7-10 22:30:25 | 显示全部楼层
学习了。
回复

使用道具 举报

3

主题

155

回帖

537

积分

高级会员

积分
537
金钱
379
HASS币
0
发表于 2018-4-17 21:28:38 | 显示全部楼层
学习学习~
回复

使用道具 举报

4

主题

64

回帖

353

积分

论坛分享达人

积分
353
金钱
285
HASS币
0
发表于 2018-4-17 21:11:47 来自手机 | 显示全部楼层
好好学习
回复

使用道具 举报

219

主题

1070

回帖

8066

积分

超级版主

积分
8066
金钱
6747
HASS币
86

教程狂人论坛风云人物突出贡献

 楼主| 发表于 2018-2-10 16:07:00 | 显示全部楼层
czweb 发表于 2018-2-10 16:04
有时候明明是发帖了,主题数字也更新,没有收到提醒反应呢?
你是怎么登录的,下面这样吗?我用postman测 ...

帖子数量不用登陆都能看到。
我没试过登陆,不是有一个滑竿验证吗?估计过不了吧。
没提醒,是你没用趋势传感器吧
回复

使用道具 举报

42

主题

482

回帖

2547

积分

金牌会员

积分
2547
金钱
2018
HASS币
30
发表于 2018-2-10 16:04:15 | 显示全部楼层
lidicn 发表于 2018-2-8 16:40
试了下,不登陆是不能访问用户发帖的列表的

有时候明明是发帖了,主题数字也更新,没有收到提醒反应呢?
你是怎么登录的,下面这样吗?我用postman测试basic测试登录没有反应的


sensor:
  # 检测论坛作者lidicn版主帖子数
  - platform: scrape
    resource: https://bbs.hassbian.com/home.php?mod=space&uid=136
    name: topic_lidicn
    select: a[href="home.php?mod=space&uid=136&do=thread&view=me&type=thread&from=space"]
    value_template: '{{ value.split(" ")[1] }}'
    unit_of_measurement: '贴'
    authentication:basic
    username:lidicn
    password:password

回复

使用道具 举报

219

主题

1070

回帖

8066

积分

超级版主

积分
8066
金钱
6747
HASS币
86

教程狂人论坛风云人物突出贡献

 楼主| 发表于 2018-2-8 16:40:24 | 显示全部楼层
czweb 发表于 2018-2-8 15:00
https://home-assistant.io/components/persistent_notification/

没有查到这个支持HTML的标签呢 ...

试了下,不登陆是不能访问用户发帖的列表的
回复

使用道具 举报

219

主题

1070

回帖

8066

积分

超级版主

积分
8066
金钱
6747
HASS币
86

教程狂人论坛风云人物突出贡献

 楼主| 发表于 2018-2-8 15:12:42 | 显示全部楼层
czweb 发表于 2018-2-8 15:00
https://home-assistant.io/components/persistent_notification/

没有查到这个支持HTML的标签呢 ...

直接网址就可以的了
回复

使用道具 举报

42

主题

482

回帖

2547

积分

金牌会员

积分
2547
金钱
2018
HASS币
30
发表于 2018-2-8 15:00:56 | 显示全部楼层
lidicn 发表于 2018-2-8 13:51
https://home-assistant.io/components/persistent_notification/
https://bbs.hassbian.com/home.php?mo ...

https://home-assistant.io/components/persistent_notification/

没有查到这个支持HTML的<a href></a>标签呢
回复

使用道具 举报

219

主题

1070

回帖

8066

积分

超级版主

积分
8066
金钱
6747
HASS币
86

教程狂人论坛风云人物突出贡献

 楼主| 发表于 2018-2-8 13:51:29 | 显示全部楼层
回复

使用道具 举报

42

主题

482

回帖

2547

积分

金牌会员

积分
2547
金钱
2018
HASS币
30
发表于 2018-2-7 18:43:56 | 显示全部楼层
有什么办法加个URL跳转,点击大神头像,跳转到论坛看帖子呢?
TIM截图20180207184228.png
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

Archiver|手机版|小黑屋|Hassbian ( 晋ICP备17001384号-1 )

GMT+8, 2025-9-18 03:05 , Processed in 0.574210 second(s), 14 queries , MemCached On.

Powered by Discuz! X3.5

© 2001-2025 Discuz! Team.

快速回复 返回顶部 返回列表