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

 找回密码
 立即注册
楼主: tangxingjie1991

[流程系列] 分享一个油价的nr流

  [复制链接]

4

主题

41

帖子

205

积分

中级会员

Rank: 3Rank: 3

积分
205
金钱
164
HASS币
0
发表于 2022-11-3 15:03:27 | 显示全部楼层
那段代码是写道哪个地方的呀?
<ha-icon icon="mdi:update"></ha-icon> {{ states.sensor.youjia.last_changed.strftime('%Y-%m-%d') }}
## <center>92# <ha-icon icon="mdi:gas-station"></ha-icon>  <font color=#ea4335> {{ state_attr('sensor.youjia', '92')}} </font>                 95# <ha-icon icon="mdi:gas-station"></ha-icon>  <font color=#fbbc05>  {{ state_attr('sensor.youjia', '95')}} </font> <p> 98# <ha-icon icon="mdi:gas-station"></ha-icon> <font color=#4285f4>  {{ state_attr('sensor.youjia', '98')}}</font>                    0#柴<ha-icon icon="mdi:gas-station"></ha-icon> <font color=#34a853>  {{ state_attr('sensor.youjia', '0')}} </font></center>
- {{ states('sensor.youjia') }}
- {{ state_attr('sensor.youjia','tips')}}
回复

使用道具 举报

1

主题

24

帖子

326

积分

中级会员

Rank: 3Rank: 3

积分
326
金钱
302
HASS币
0
发表于 2022-11-8 12:15:27 | 显示全部楼层
hyq 发表于 2022-9-11 21:25
各位大佬我的nr流正常,就是卡片不能更新数据。如果重启系统就能更新数据。 ...

我也是。周期性执行不起作用
回复

使用道具 举报

1

主题

24

帖子

326

积分

中级会员

Rank: 3Rank: 3

积分
326
金钱
302
HASS币
0
发表于 2022-11-10 09:24:49 | 显示全部楼层
hyq 发表于 2022-9-11 21:25
各位大佬我的nr流正常,就是卡片不能更新数据。如果重启系统就能更新数据。 ...

不是不更新,是因为状态都是“下次油价11月21日24时调整”,看不到变化。稍微改了下,更新时间换成了调用时的时间戳
[
    {
        "id": "d421b9ba0766c3a9",
        "type": "tab",
        "label": "油价",
        "disabled": false,
        "info": "",
        "env": []
    },
    {
        "id": "e8e943f5de1abc3f",
        "type": "inject",
        "z": "d421b9ba0766c3a9",
        "name": "",
        "props": [
            {
                "p": "payload"
            },
            {
                "p": "topic",
                "vt": "str"
            }
        ],
        "repeat": "14400",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "",
        "payloadType": "date",
        "x": 200,
        "y": 200,
        "wires": [
            [
                "7282855c93a546a1",
                "16aac348e3c27db8"
            ]
        ]
    },
    {
        "id": "7282855c93a546a1",
        "type": "http request",
        "z": "d421b9ba0766c3a9",
        "name": "",
        "method": "GET",
        "ret": "txt",
        "paytoqs": "ignore",
        "url": "http://www.qiyoujiage.com/shandong/jinan.shtml",
        "tls": "",
        "persist": false,
        "proxy": "",
        "insecureHTTPParser": false,
        "authType": "",
        "senderr": false,
        "headers": [],
        "x": 400,
        "y": 200,
        "wires": [
            [
                "8e042617a206c71b",
                "6e9eacff9401b324"
            ]
        ]
    },
    {
        "id": "8e042617a206c71b",
        "type": "html",
        "z": "d421b9ba0766c3a9",
        "name": "",
        "property": "payload",
        "outproperty": "payload",
        "tag": "#youjia > dl",
        "ret": "text",
        "as": "single",
        "x": 570,
        "y": 200,
        "wires": [
            [
                "da99b102b1838e40"
            ]
        ]
    },
    {
        "id": "da99b102b1838e40",
        "type": "split",
        "z": "d421b9ba0766c3a9",
        "name": "",
        "splt": "\\n",
        "spltType": "str",
        "arraySplt": 1,
        "arraySpltType": "len",
        "stream": false,
        "addname": "",
        "x": 710,
        "y": 200,
        "wires": [
            [
                "dfb1f4c74d08f35b"
            ]
        ]
    },
    {
        "id": "dfb1f4c74d08f35b",
        "type": "switch",
        "z": "d421b9ba0766c3a9",
        "name": "",
        "property": "payload",
        "propertyType": "msg",
        "rules": [
            {
                "t": "cont",
                "v": "92#",
                "vt": "str"
            },
            {
                "t": "cont",
                "v": "95#",
                "vt": "str"
            },
            {
                "t": "cont",
                "v": "98#",
                "vt": "str"
            },
            {
                "t": "cont",
                "v": "0#",
                "vt": "str"
            }
        ],
        "checkall": "true",
        "repair": false,
        "outputs": 4,
        "x": 830,
        "y": 200,
        "wires": [
            [
                "4e62104a0afdb9ef"
            ],
            [
                "7221463aedda161b"
            ],
            [
                "38dc4898932a5ec4"
            ],
            [
                "2923da012cd5c84b"
            ]
        ]
    },
    {
        "id": "4e62104a0afdb9ef",
        "type": "split",
        "z": "d421b9ba0766c3a9",
        "name": "",
        "splt": "\\n",
        "spltType": "str",
        "arraySplt": "4",
        "arraySpltType": "len",
        "stream": true,
        "addname": "topic",
        "x": 1030,
        "y": 140,
        "wires": [
            [
                "f8aeae44f661a801"
            ]
        ]
    },
    {
        "id": "7221463aedda161b",
        "type": "split",
        "z": "d421b9ba0766c3a9",
        "name": "",
        "splt": "\\n",
        "spltType": "str",
        "arraySplt": "4",
        "arraySpltType": "len",
        "stream": true,
        "addname": "topic",
        "x": 1030,
        "y": 180,
        "wires": [
            [
                "d884ac304fda8635"
            ]
        ]
    },
    {
        "id": "38dc4898932a5ec4",
        "type": "split",
        "z": "d421b9ba0766c3a9",
        "name": "",
        "splt": "\\n",
        "spltType": "str",
        "arraySplt": "4",
        "arraySpltType": "len",
        "stream": true,
        "addname": "topic",
        "x": 1030,
        "y": 220,
        "wires": [
            [
                "d9e3c8d2c27bde74"
            ]
        ]
    },
    {
        "id": "2923da012cd5c84b",
        "type": "split",
        "z": "d421b9ba0766c3a9",
        "name": "",
        "splt": "\\n",
        "spltType": "str",
        "arraySplt": "4",
        "arraySpltType": "len",
        "stream": true,
        "addname": "topic",
        "x": 1030,
        "y": 260,
        "wires": [
            [
                "078692d7b5644302"
            ]
        ]
    },
    {
        "id": "f8aeae44f661a801",
        "type": "change",
        "z": "d421b9ba0766c3a9",
        "name": "",
        "rules": [
            {
                "t": "set",
                "p": "92#",
                "pt": "global",
                "to": "payload",
                "tot": "msg"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 1260,
        "y": 140,
        "wires": [
            [
                "1ad9c828fb48a3f0"
            ]
        ]
    },
    {
        "id": "d884ac304fda8635",
        "type": "change",
        "z": "d421b9ba0766c3a9",
        "name": "",
        "rules": [
            {
                "t": "set",
                "p": "95#",
                "pt": "global",
                "to": "payload",
                "tot": "msg"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 1260,
        "y": 180,
        "wires": [
            [
                "1ad9c828fb48a3f0"
            ]
        ]
    },
    {
        "id": "d9e3c8d2c27bde74",
        "type": "change",
        "z": "d421b9ba0766c3a9",
        "name": "",
        "rules": [
            {
                "t": "set",
                "p": "98#",
                "pt": "global",
                "to": "payload",
                "tot": "msg"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 1260,
        "y": 220,
        "wires": [
            [
                "1ad9c828fb48a3f0"
            ]
        ]
    },
    {
        "id": "078692d7b5644302",
        "type": "change",
        "z": "d421b9ba0766c3a9",
        "name": "",
        "rules": [
            {
                "t": "set",
                "p": "0#",
                "pt": "global",
                "to": "payload",
                "tot": "msg"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 1260,
        "y": 260,
        "wires": [
            [
                "1ad9c828fb48a3f0"
            ]
        ]
    },
    {
        "id": "6e9eacff9401b324",
        "type": "html",
        "z": "d421b9ba0766c3a9",
        "name": "",
        "property": "payload",
        "outproperty": "payload",
        "tag": "#youjiaCont > div",
        "ret": "text",
        "as": "single",
        "x": 590,
        "y": 300,
        "wires": [
            [
                "bdf6b17e31eb5bba"
            ]
        ]
    },
    {
        "id": "bdf6b17e31eb5bba",
        "type": "change",
        "z": "d421b9ba0766c3a9",
        "name": "",
        "rules": [
            {
                "t": "set",
                "p": "payload",
                "pt": "msg",
                "to": "payload[1]",
                "tot": "msg"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 810,
        "y": 300,
        "wires": [
            [
                "84d44bfec1dc5014"
            ]
        ]
    },
    {
        "id": "84d44bfec1dc5014",
        "type": "split",
        "z": "d421b9ba0766c3a9",
        "name": "",
        "splt": "\\n",
        "spltType": "str",
        "arraySplt": 1,
        "arraySpltType": "len",
        "stream": false,
        "addname": "",
        "x": 990,
        "y": 300,
        "wires": [
            [
                "82d78b1f9aa34bb3"
            ]
        ]
    },
    {
        "id": "82d78b1f9aa34bb3",
        "type": "join",
        "z": "d421b9ba0766c3a9",
        "name": "",
        "mode": "custom",
        "build": "array",
        "property": "payload",
        "propertyType": "msg",
        "key": "topic",
        "joiner": "\\n",
        "joinerType": "str",
        "accumulate": false,
        "timeout": "",
        "count": "",
        "reduceRight": false,
        "reduceExp": "",
        "reduceInit": "",
        "reduceInitType": "",
        "reduceFixup": "",
        "x": 1110,
        "y": 300,
        "wires": [
            [
                "1e914c0e3c884128"
            ]
        ]
    },
    {
        "id": "1e914c0e3c884128",
        "type": "change",
        "z": "d421b9ba0766c3a9",
        "name": "",
        "rules": [
            {
                "t": "set",
                "p": "tips",
                "pt": "global",
                "to": "payload[2]",
                "tot": "msg"
            },
            {
                "t": "set",
                "p": "state",
                "pt": "global",
                "to": "payload[1]",
                "tot": "msg"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 1260,
        "y": 300,
        "wires": [
            [
                "1ad9c828fb48a3f0"
            ]
        ]
    },
    {
        "id": "1ad9c828fb48a3f0",
        "type": "ha-sensor",
        "z": "d421b9ba0766c3a9",
        "name": "油价",
        "entityConfig": "f85338be9197e1a4",
        "version": 0,
        "state": "state",
        "stateType": "global",
        "attributes": [
            {
                "property": "92#",
                "value": "92#",
                "valueType": "global"
            },
            {
                "property": "95#",
                "value": "95#",
                "valueType": "global"
            },
            {
                "property": "98#",
                "value": "98#",
                "valueType": "global"
            },
            {
                "property": "0#",
                "value": "0#",
                "valueType": "global"
            },
            {
                "property": "tips",
                "value": "tips",
                "valueType": "global"
            },
            {
                "property": "time",
                "value": "time",
                "valueType": "global"
            }
        ],
        "inputOverride": "allow",
        "outputProperties": [],
        "x": 1500,
        "y": 200,
        "wires": [
            []
        ]
    },
    {
        "id": "16aac348e3c27db8",
        "type": "function",
        "z": "d421b9ba0766c3a9",
        "name": "function",
        "func": "function timestampToTime(timestamp) {\n    var date = new Date(timestamp);\n    var Y = date.getFullYear() + '-';\n    var M = (date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1) + '-';\n    var D = date.getDate() + ' ';\n    var h = date.getHours() + ':';\n    var m = date.getMinutes() + ':';\n    var s = date.getSeconds();\n    return Y + M + D +  h + m + s;\n}\n\nvar data_t = {\n    payload: timestampToTime(msg.payload)\n}\n\nreturn data_t;",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 400,
        "y": 100,
        "wires": [
            [
                "2b8afe59f039c26f"
            ]
        ]
    },
    {
        "id": "2b8afe59f039c26f",
        "type": "change",
        "z": "d421b9ba0766c3a9",
        "name": "",
        "rules": [
            {
                "t": "set",
                "p": "time",
                "pt": "global",
                "to": "payload",
                "tot": "msg"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 1260,
        "y": 100,
        "wires": [
            [
                "1ad9c828fb48a3f0"
            ]
        ]
    },
    {
        "id": "f85338be9197e1a4",
        "type": "ha-entity-config",
        "server": "2564e51e05f374f6",
        "deviceConfig": "",
        "name": "sensor config for 油价",
        "version": "6",
        "entityType": "sensor",
        "haConfig": [
            {
                "property": "name",
                "value": "youjia"
            },
            {
                "property": "icon",
                "value": "mdi:gas-station"
            },
            {
                "property": "entity_category",
                "value": ""
            },
            {
                "property": "device_class",
                "value": ""
            },
            {
                "property": "unit_of_measurement",
                "value": ""
            },
            {
                "property": "state_class",
                "value": ""
            }
        ],
        "resend": true
    },
    {
        "id": "2564e51e05f374f6",
        "type": "server",
        "name": "Home Assistant",
        "version": 5,
        "addon": false,
        "rejectUnauthorizedCerts": true,
        "ha_boolean": "y|yes|true|on|home|open",
        "connectionDelay": true,
        "cacheJson": true,
        "heartbeat": false,
        "heartbeatInterval": "30",
        "areaSelector": "friendlyName",
        "deviceSelector": "friendlyName",
        "entitySelector": "friendlyName",
        "statusSeparator": ": ",
        "statusYear": "hidden",
        "statusMonth": "short",
        "statusDay": "numeric",
        "statusHourCycle": "default",
        "statusTimeFormat": "h:m",
        "enableGlobalContextStore": false
    }
]
回复

使用道具 举报

5

主题

471

帖子

2102

积分

金牌会员

Rank: 6Rank: 6

积分
2102
金钱
1631
HASS币
0
发表于 2022-11-10 18:40:08 | 显示全部楼层
Mew 发表于 2022-11-10 09:24
不是不更新,是因为状态都是“下次油价11月21日24时调整”,看不到变化。稍微改了下,更新时间换成了调用 ...

你好!请问这段代码放哪里?谢谢!
回复

使用道具 举报

1

主题

24

帖子

326

积分

中级会员

Rank: 3Rank: 3

积分
326
金钱
302
HASS币
0
发表于 2022-11-11 15:59:28 | 显示全部楼层
hyq 发表于 2022-11-10 18:40
你好!请问这段代码放哪里?谢谢!

替换原来的就行了flows.json就行了,相当于重新导入一遍

                               
登录/注册后可看大图
回复

使用道具 举报

5

主题

471

帖子

2102

积分

金牌会员

Rank: 6Rank: 6

积分
2102
金钱
1631
HASS币
0
发表于 2022-11-11 16:05:31 | 显示全部楼层
Mew 发表于 2022-11-11 15:59
替换原来的就行了flows.json就行了,相当于重新导入一遍

好的!谢谢!
回复

使用道具 举报

16

主题

234

帖子

1467

积分

金牌会员

Rank: 6Rank: 6

积分
1467
金钱
1233
HASS币
0
发表于 2022-11-18 00:34:48 | 显示全部楼层

油价.png

回复

使用道具 举报

16

主题

234

帖子

1467

积分

金牌会员

Rank: 6Rank: 6

积分
1467
金钱
1233
HASS币
0
发表于 2022-11-18 00:44:16 | 显示全部楼层
刻刻崖 发表于 2022-11-3 15:03
那段代码是写道哪个地方的呀?

编辑仪表盘  -添加卡片  找 Markdowm.png   
Markdowm1.png
回复

使用道具 举报

4

主题

41

帖子

205

积分

中级会员

Rank: 3Rank: 3

积分
205
金钱
164
HASS币
0
发表于 2022-11-20 00:25:04 | 显示全部楼层
lqf1206 发表于 2022-11-18 00:44
编辑仪表盘  -添加卡片  找

感谢回复,已经搞定了。
回复

使用道具 举报

1

主题

167

帖子

608

积分

高级会员

Rank: 4

积分
608
金钱
441
HASS币
0
发表于 2023-2-2 15:42:39 | 显示全部楼层
它的刷新是如何实现的?需要到Node-Red里点“注入”?
回复

使用道具 举报

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

本版积分规则

Archiver|手机版|小黑屋|Hassbian

GMT+8, 2024-5-2 22:55 , Processed in 0.488932 second(s), 32 queries .

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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