『瀚思彼岸』» 智能家居技术论坛

 找回密码
 立即注册
查看: 113882|回复: 392

[教程系列] 【node-red】 24节气及节假日 - 抓取网站已经挂了

  [复制链接]

15

主题

108

帖子

1363

积分

论坛技术达人

积分
1363
金钱
1250
HASS币
20

教程狂人

发表于 2018-11-9 10:36:49 | 显示全部楼层 |阅读模式
本帖最后由 花开堪折枝 于 2024-5-7 13:47 编辑

先看流程


QQ截图20181109103458.png

mqtt数据如下

"data": {
    "year": 2018,
    "month": 11,
    "day": 9,
    "lunarYear": 2018,
    "lunarMonth": 10,
    "lunarDay": 2,
    "cnyear": "贰零壹捌 ",
    "cnmonth": "十",
    "cnday": "初二",
    "hyear": "戊戌",
    "cyclicalYear": "戊戌",
    "cyclicalMonth": "癸亥",
    "cyclicalDay": "乙巳",
    "suit": "祭祀,解除,破屋,坏垣,求医,治病,馀事勿取",
    "taboo": "嫁娶,安葬",
    "animal": "狗",
    "week": "Friday",
    "festivalList": [],
    "jieqi": {
      "8": "立冬",
      "22": "小雪"
    },
    "maxDayInMonth": 29,
    "leap": false,
    "lunarYearString": "戊戌",
    "bigMonth": false
  }



流程信息

[{"id":"fe3cb423.69e4f8","type":"tab","label":"流程2","disabled":false,"info":""},{"id":"b72d9cbe.6cde","type":"inject","z":"fe3cb423.69e4f8","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":125,"y":144,"wires":[["33aff5d3.5ea44a"]]},{"id":"dacd9b2f.6fe928","type":"http request","z":"fe3cb423.69e4f8","name":"获取节气","method":"GET","ret":"obj","url":"https://www.sojson.com/open/api/lunar/json.shtml","tls":"","x":490,"y":133,"wires":[["ce6cef22.456e4","437d983c.91e728"]]},{"id":"ce6cef22.456e4","type":"debug","z":"fe3cb423.69e4f8","name":"调式节点","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","x":704,"y":48,"wires":[]},{"id":"33aff5d3.5ea44a","type":"function","z":"fe3cb423.69e4f8","name":"数据处理","func":"msg.headers = {};\nmsg.headers['user-agent'] = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3440.106 Safari/537.36';\nreturn msg;","outputs":1,"noerr":0,"x":300,"y":138,"wires":[["dacd9b2f.6fe928"]]},{"id":"437d983c.91e728","type":"switch","z":"fe3cb423.69e4f8","name":"","property":"payload.status","propertyType":"msg","rules":[{"t":"eq","v":"200","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":487,"y":220,"wires":[["18c38ec3.e88781"]]},{"id":"18c38ec3.e88781","type":"function","z":"fe3cb423.69e4f8","name":"数据处理","func":"msg.payload = msg.payload.data\nreturn msg;","outputs":1,"noerr":0,"x":669,"y":217,"wires":[["ce6cef22.456e4","f5ed75bf.050da8"]]},{"id":"f5ed75bf.050da8","type":"mqtt out","z":"fe3cb423.69e4f8","name":"mqtt发送","topic":"/node-red/jieqi","qos":"0","retain":"","broker":"1550bab3.2a8365","x":920,"y":174,"wires":[]},{"id":"1550bab3.2a8365","type":"mqtt-broker","z":"","name":"home","broker":"shenfan.f3322.net","port":"2883","clientid":"","usetls":false,"compatmode":true,"keepalive":"60","cleansession":true,"birthTopic":"","birthQos":"0","birthPayload":"","closeTopic":"","closeQos":"0","closePayload":"","willTopic":"","willQos":"0","willPayload":""}]

回复

使用道具 举报

10

主题

680

帖子

5702

积分

论坛元老

Rank: 8Rank: 8

积分
5702
金钱
5017
HASS币
50
发表于 2018-12-21 16:05:01 | 显示全部楼层
情非殇 发表于 2018-12-21 10:43
怎么配置ha的yaml,求指教一下
sensor:
  - platform: mqtt
    name: "jieqi"
    state_topic: "/node-red/jieqi/"
    value_template: '{{ value_json.jieqi }}'
  - platform: mqtt
    name: "cnday"
    state_topic: "/node-red/jieqi/"
    value_template: "{{ value_json.cnday }}"
  - platform: mqtt
    name: "suit"
    state_topic: "/node-red/jieqi/"
    value_template: "{{ value_json.suit }}"
  - platform: mqtt
    name: "taboo"
    state_topic: "/node-red/jieqi/"
    value_template: "{{ value_json.taboo }}"
  - platform: mqtt
    name: "festivallist"
    state_topic: "/node-red/jieqi/"
    value_template: "{{ value_json.festivalList }}"
  - platform: mqtt
    name: "animal"
    state_topic: "/node-red/jieqi/"
    value_template: "{{ value_json.animal }}"
  - platform: mqtt
    name: "week"
    state_topic: "/node-red/jieqi/"
    value_template: "{{ value_json.week }}"
  - platform: template
    sensors:
      week2:
        friendly_name: '星期'
        value_template: >-
          {% if is_state('sensor.week', 'Monday') %}
            星期一
          {% elif is_state('sensor.week', 'Tuesday') %}
            星期二
          {% elif is_state('sensor.week', 'Wednesday') %}
            星期三
          {% elif is_state('sensor.week', 'Thursday') %}
            星期四
          {% elif is_state('sensor.week', 'Friday') %}
            星期五
          {% elif is_state('sensor.week', 'Saturday') %}
            星期六
          {% elif is_state('sensor.week', 'Sunday') %}
            星期天
          {% else %}
            failed
          {% endif %}

回复

使用道具 举报

0

主题

86

帖子

365

积分

论坛积极会员

积分
365
金钱
279
HASS币
0
发表于 2018-11-9 10:38:23 来自手机 | 显示全部楼层
谢谢,学习,
回复

使用道具 举报

2

主题

241

帖子

1765

积分

金牌会员

Rank: 6Rank: 6

积分
1765
金钱
1524
HASS币
0
发表于 2018-11-9 11:01:29 | 显示全部楼层
有中国风  学习
回复

使用道具 举报

2

主题

68

帖子

278

积分

中级会员

Rank: 3Rank: 3

积分
278
金钱
210
HASS币
0
发表于 2018-11-9 11:11:42 | 显示全部楼层
更新的真勤快啊     点赞
回复

使用道具 举报

5

主题

356

帖子

1411

积分

金牌会员

Rank: 6Rank: 6

积分
1411
金钱
1055
HASS币
0
发表于 2018-11-9 11:18:41 | 显示全部楼层
值得学习,node red 还不会。。。
回复

使用道具 举报

5

主题

231

帖子

4470

积分

元老级技术达人

积分
4470
金钱
4224
HASS币
40
发表于 2018-11-9 11:20:12 | 显示全部楼层

谢谢,学习,
回复

使用道具 举报

123

主题

4664

帖子

1万

积分

管理员

囧死

Rank: 9Rank: 9Rank: 9

积分
16442
金钱
11693
HASS币
45
发表于 2018-11-9 12:23:19 | 显示全部楼层
谢谢花兄,这个很强大的,特别是节假日功能
回复

使用道具 举报

4

主题

313

帖子

1967

积分

金牌会员

Rank: 6Rank: 6

积分
1967
金钱
1654
HASS币
0
发表于 2018-11-9 12:30:04 | 显示全部楼层
还是nodered好用
回复

使用道具 举报

10

主题

680

帖子

5702

积分

论坛元老

Rank: 8Rank: 8

积分
5702
金钱
5017
HASS币
50
发表于 2018-11-9 12:59:46 | 显示全部楼层
厉害了,学习一下
回复

使用道具 举报

23

主题

658

帖子

4643

积分

元老级技术达人

积分
4643
金钱
3970
HASS币
30

教程狂人

QQ
发表于 2018-11-9 13:27:04 | 显示全部楼层
很好很强大
回复

使用道具 举报

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

本版积分规则

Archiver|手机版|小黑屋|Hassbian

GMT+8, 2024-12-22 11:48 , Processed in 0.076754 second(s), 39 queries .

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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