跳转至

24节气

node_red_jieqi

  • 节点信息如下

    [{"id":"67c41f6e.7823a","type":"tab","label":"24节气","disabled":false,"info":""},{"id":"5cf06af3.deffa4","type":"inject","z":"67c41f6e.7823a","name":"每天夜里12:01执行","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"01 00 * * *","once":false,"onceDelay":0.1,"x":154,"y":58,"wires":[["51eec8da.be45f8"]]},{"id":"cd4681ed.af587","type":"http request","z":"67c41f6e.7823a","name":"获取节气","method":"GET","ret":"obj","url":"https://www.sojson.com/open/api/lunar/json.shtml","tls":"","x":551,"y":139,"wires":[["d4ee0bcd.288348"]]},{"id":"aeb3b880.421108","type":"debug","z":"67c41f6e.7823a","name":"调式节点","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","x":680,"y":260,"wires":[]},{"id":"51eec8da.be45f8","type":"function","z":"67c41f6e.7823a","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":396,"y":140,"wires":[["cd4681ed.af587"]]},{"id":"d4ee0bcd.288348","type":"switch","z":"67c41f6e.7823a","name":"","property":"payload.status","propertyType":"msg","rules":[{"t":"eq","v":"200","vt":"str"}],"checkall":"true","repair":false,"outputs":1,"x":696,"y":139,"wires":[["42eed5d7.5d5e7c"]]},{"id":"cfb8116.1c260f","type":"function","z":"67c41f6e.7823a","name":"数据处理","func":"msg.payload = msg.payload.data\nvar jieqi = msg.payload.jieqi\nvar newJieQi = ''\nfor(var day in jieqi) {\n    newJieQi = newJieQi + day + ':' + jieqi[day] + ' '\n}\nmsg.payload.newJieQi = newJieQi\nreturn msg;","outputs":1,"noerr":0,"x":466,"y":325,"wires":[["aeb3b880.421108","3d688df7.6062a2"]]},{"id":"3d688df7.6062a2","type":"mqtt out","z":"67c41f6e.7823a","name":"mqtt转发","topic":"node-red/jieqi","qos":"0","retain":"","broker":"5ad12292.c083cc","x":672,"y":354,"wires":[]},{"id":"42eed5d7.5d5e7c","type":"link out","z":"67c41f6e.7823a","name":"节气转换","links":["6b57830b.9ce23c"],"x":846,"y":137,"wires":[]},{"id":"6b57830b.9ce23c","type":"link in","z":"67c41f6e.7823a","name":"节气转换接收","links":["42eed5d7.5d5e7c"],"x":317,"y":324,"wires":[["cfb8116.1c260f"]]},{"id":"6357f57b.5eae2c","type":"inject","z":"67c41f6e.7823a","name":"1个小时执行一次","topic":"","payload":"","payloadType":"date","repeat":"3600","crontab":"","once":false,"onceDelay":0.1,"x":140,"y":130,"wires":[["51eec8da.be45f8"]]},{"id":"3e3ba7eb.9c5c08","type":"mqtt in","z":"67c41f6e.7823a","name":"","topic":"node-red/homeassistant-setup","qos":"2","broker":"5ad12292.c083cc","x":140,"y":200,"wires":[["51eec8da.be45f8"]]},{"id":"5ad12292.c083cc","type":"mqtt-broker","z":"","name":"N1","broker":"192.168.3.10","port":"1883","clientid":"","usetls":false,"compatmode":true,"keepalive":"60","cleansession":true,"birthTopic":"node-red/server/status","birthQos":"0","birthPayload":"在线","closeTopic":"node-red/server/status","closeQos":"0","closePayload":"关闭","willTopic":"node-red/server/status","willQos":"0","willPayload":"不可用"}]
    

  • jieqi.yaml
    因为所有的信息都放在group里面,所有需要在自己需要放的位置配置一下 group.jieqi

    sensor:
      - platform: mqtt
        name: "jieqi_day"
        friendly_name: "日期"
        state_topic: "node-red/jieqi"
        value_template: "{{ value_json.cnmonth }}月{{ value_json.cnday }}"
      - platform: mqtt
        name: "jieqi_jieqi"
        friendly_name: "节气"
        state_topic: "node-red/jieqi"
        value_template: "{{ value_json.newJieQi }}"
      - platform: mqtt
        name: "jieqi_animal"
        friendly_name: "属相"
        state_topic: "node-red/jieqi"
        value_template: "{{ value_json.animal }}"
      - platform: mqtt
        name: "jieqi_suit"
        friendly_name: "宜"
        state_topic: "node-red/jieqi"
        value_template: "{{ value_json.suit }}"
      - platform: mqtt
        name: "jieqi_taboo"
        friendly_name: "忌"
        state_topic: "node-red/jieqi"
        value_template: "{{ value_json.taboo }}"
    
    
    
    homeassistant:
      customize:
        sensor.jieqi_day:
          friendly_name: 日期
        sensor.jieqi_jieqi:
          friendly_name: 节气
        sensor.jieqi_animal:
          friendly_name: 属相
        sensor.jieqi_suit:
          friendly_name: 
        sensor.jieqi_taboo:
          friendly_name: 
    
    
    group:
    
      jieqi:
        name: 农历
        view: no  
        entities:
          - sensor.jieqi_day
          - sensor.jieqi_jieqi
          - sensor.jieqi_animal
          - sensor.jieqi_suit
          - sensor.jieqi_taboo