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

 找回密码
 立即注册
查看: 4706|回复: 28

[基础教程] [智能家居]: 实时监控家庭水流量情况

  [复制链接]

22

主题

319

帖子

3929

积分

论坛元老

Rank: 8Rank: 8

积分
3929
金钱
3605
HASS币
30
发表于 2024-3-1 17:44:48 | 显示全部楼层 |阅读模式
本帖最后由 MX10085 于 2024-3-2 19:42 编辑

[智能家居]: 实时监控家庭水流量情况
使用目的:实时监控家庭水流量情况,异常的话可以自动关闭水闸,不用担心会出现水浸地面的情况发生。

1. 使用环境
home-assistant
node-red
esphome
mariadb 数据库

2. 准备材料
esp32 板子
Screenshot_20240301_105348.png
压力传感器
Screenshot_20240301_105456.png
流量计
10103C0A0C84FF4E796302C5266A5113.png

3. esp32刷入程序
Screenshot_20240301_110240.png

控制代码:打x的地方自己更改
####################################################
#                    基本信息                       #
####################################################
esphome:
  name: esp32s-s3-water
  friendly_name: esp32s-s3-water

esp32:
  board: esp32-s3-devkitc-1
  framework:
    type: arduino

# Enable logging
logger:

# Enable Home Assistant API
api:
  encryption:
    key: "xxxxxxxxxxxxxxxxxxxxxxxxxx"

ota:
  password: "xxxxxxxxxxxxxxxxxxxxxxxxxxxx"

####################################################
#                    网络信息                       #
####################################################
wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password
  # manual_ip:
  #  static_ip: 192.168.2.50
  #  gateway: 192.168.2.1
  #  subnet: 255.255.255.0
  #  dns1: 223.5.5.5
  #  dns2: 223.6.6.6
  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: "Esp32s-s3-Water"
    password: "xxxxxxxxxxxxxxxxxxx"

captive_portal:

####################################################
#                    时间信息                       #
####################################################
time:
  - platform: sntp
    id: sntp_time
    timezone: Asia/Shanghai
    servers:
      - ntp1.aliyun.com
      - ntp2.aliyun.com
      - ntp3.aliyun.com

####################################################
#                    MQTT信息                       #
####################################################
# mqtt:
#  broker: 192.168.2.14
#  username: !secret mqtt_username
#  password: !secret mqtt_password

####################################################
#                     传感器                        #
####################################################
sensor:

####################  用水计量  #####################
  - platform: pulse_counter
    name: "Instant water consumption"
    pin: GPIO12
    id: water
    unit_of_measurement: 'L/Min'
    update_interval: 6s
    filters:
      # - multiply: 0.0020964360587002
      - lambda: return (x / 477.0);
    total:
      name: "Total water consumption"
      unit_of_measurement: "m³"
      device_class: water
      state_class: total_increasing
      accuracy_decimals: 3
      icon: "mdi:water"
      filters:
        - lambda: return (x / 477000.0);

  # - platform: pulse_meter
  #   pin: GPIO12
  #   id: water
  #   name: "Instant water consumption"
  #   unit_of_measurement: "L/min"
  #   icon: "mdi:water"
  #   timeout: 1s
  #   accuracy_decimals: 3
  #   filters:
  #     - lambda: return (x / 477.0);
  #   total:
  #     name: "Total water consumption"
  #     unit_of_measurement: "m³"
  #     device_class: water
  #     state_class: total_increasing
  #     accuracy_decimals: 3
  #     icon: "mdi:water"
  #     filters:
  #       - lambda: return (x / 477000.0);

  - platform: total_daily_energy
    name: "Daily water consumption"
    power_id: water
    unit_of_measurement: 'm³'
    filters:
      - multiply: 0.06

####################  进水压力  #####################
  - platform: adc
    name: "Water inlet pressure"
    icon: "mdi:gauge-low"
    pin: GPIO1
    id: water_inlet_pressure
    unit_of_measurement: "bar"
    update_interval: 6s
    accuracy_decimals: 2
    attenuation: 11db
    filters:
      - lambda: |-
          if(x-0.41<0) return 0.00;
          return (x-0.41) * 4.00;

####################  运行时间  #####################
  - platform: uptime
    name: Uptime Sensor
    id: uptime_sensor
    update_interval: 60s

4. home-assistant 设置
Screenshot_20240301_110645.png

Screenshot_20240301_110707.png


5. node-red 设置
Screenshot_20240301_111011.png

node-red 代码:
[
    {
        "id": "e14bf0df.21632",
        "type": "function",
        "z": "f6f2187d.f17ca8",
        "g": "5aabb8329669cca2",
        "name": "添加",
        "func": "\n//获取前一天的日期,这段不要改动\nvar dd = new Date();\ndd.setDate(dd.getDate() -1);\nvar y = dd.getFullYear();\nvar m = dd.getMonth() + 1 < 10 ? "0" + (dd.getMonth() + 1) : dd.getMonth() + 1;\nvar d = dd.getDate() < 10 ? "0" + dd.getDate() : dd.getDate();\nvar f = y + "-" + m + "-" + d;\n\n//water为表名,sj和dl字段名\n\nmsg.topic = "INSERT INTO water (sj,dl) VALUES (?,?)";\nmsg.payload = [f,msg.payload]\n\n//这里的f这个值是上面获取到的前一天的日期,要传递给数据库的sj字段\n//sj这个字段表示的是昨日的日期\n//msg.payload 是water的昨天电量更新后获取到的值,传递到dl里面\nreturn msg;\n",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 270,
        "y": 3720,
        "wires": [
            [
                "3a5b1f229d5ac474"
            ]
        ]
    },
    {
        "id": "4f5cb819.b6e44",
        "type": "server-state-changed",
        "z": "f6f2187d.f17ca8",
        "g": "5aabb8329669cca2",
        "name": "昨天用水量",
        "server": "99c664b867ad2e30",
        "version": 5,
        "outputs": 1,
        "exposeAsEntityConfig": "",
        "entityId": "sensor.yesterday_water_consumption",
        "entityIdType": "exact",
        "outputInitially": false,
        "stateType": "str",
        "ifState": "",
        "ifStateType": "str",
        "ifStateOperator": "is",
        "outputOnlyOnStateChange": true,
        "for": 0,
        "forType": "num",
        "forUnits": "minutes",
        "ignorePrevStateNull": false,
        "ignorePrevStateUnknown": false,
        "ignorePrevStateUnavailable": false,
        "ignoreCurrentStateUnknown": false,
        "ignoreCurrentStateUnavailable": false,
        "outputProperties": [
            {
                "property": "payload",
                "propertyType": "msg",
                "value": "",
                "valueType": "entityState"
            },
            {
                "property": "data",
                "propertyType": "msg",
                "value": "",
                "valueType": "eventData"
            },
            {
                "property": "topic",
                "propertyType": "msg",
                "value": "",
                "valueType": "triggerId"
            }
        ],
        "x": 120,
        "y": 3720,
        "wires": [
            [
                "e14bf0df.21632"
            ]
        ]
    },
    {
        "id": "d606da6b.8c25d8",
        "type": "function",
        "z": "f6f2187d.f17ca8",
        "g": "5aabb8329669cca2",
        "name": "查询",
        "func": "msg.topic = "SELECT (select round(SUM(dl),4) from water where yearweek(date_format(sj,'%Y-%m-%d'),1)=yearweek(now(),1)) as d1,(select round(SUM(dl),4) from water where yearweek(date_format(sj,'%Y-%m-%d'),1)=yearweek(now(),1)-1) as d2,(select round(SUM(dl),4) from water where date_format( sj, '%y%m' ) = date_format( curdate( ) , '%y%m' )) as d3,(select round(SUM(dl),4) from water where period_diff( date_format( now( ) , '%y%m' ) , date_format( sj, '%y%m' ) ) =1) as d4,(select round(SUM(dl),4) from water where date_format( sj, '%y' ) = date_format( curdate( ) , '%y' )) as d5";\nmsg.jt = msg.payload //把今日用电量保存在jt里面,后面要用\nreturn msg;\n\n// round(SUM(dl),3). 保留小数点后3位\n// yearweek(date_format(sj,'%Y-%m-%d'),1)  后面这个1表示从周一开始一周\n//water表示表名,当你多个dc插排,创建了多个表时,修改这个表名即可。",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 270,
        "y": 3880,
        "wires": [
            [
                "627b9fe6.71d368"
            ]
        ]
    },
    {
        "id": "39af7a27.7b04f6",
        "type": "mqtt out",
        "z": "f6f2187d.f17ca8",
        "g": "5aabb8329669cca2",
        "name": "本周",
        "topic": "esp32s_water/sensor/this_work",
        "qos": "0",
        "retain": "true",
        "respTopic": "",
        "contentType": "",
        "userProps": "",
        "correl": "",
        "expiry": "",
        "broker": "22b93c622b5df242",
        "x": 830,
        "y": 3720,
        "wires": []
    },
    {
        "id": "d71eaf9b.e70e8",
        "type": "change",
        "z": "f6f2187d.f17ca8",
        "g": "5aabb8329669cca2",
        "name": "本周",
        "rules": [
            {
                "t": "move",
                "p": "payload[0].d1",
                "pt": "msg",
                "to": "payload",
                "tot": "msg"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 550,
        "y": 3720,
        "wires": [
            [
                "b0f09ef3.4b0c9"
            ]
        ]
    },
    {
        "id": "9479aaf3.27cb38",
        "type": "mqtt out",
        "z": "f6f2187d.f17ca8",
        "g": "5aabb8329669cca2",
        "name": "上周",
        "topic": "esp32s_water/sensor/last_work",
        "qos": "0",
        "retain": "true",
        "respTopic": "",
        "contentType": "",
        "userProps": "",
        "correl": "",
        "expiry": "",
        "broker": "22b93c622b5df242",
        "x": 830,
        "y": 3760,
        "wires": []
    },
    {
        "id": "c6a6fdf8.09f01",
        "type": "change",
        "z": "f6f2187d.f17ca8",
        "g": "5aabb8329669cca2",
        "name": "上周",
        "rules": [
            {
                "t": "move",
                "p": "payload[0].d2",
                "pt": "msg",
                "to": "payload",
                "tot": "msg"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 550,
        "y": 3760,
        "wires": [
            [
                "9479aaf3.27cb38"
            ]
        ]
    },
    {
        "id": "b8160812.22e7e8",
        "type": "mqtt out",
        "z": "f6f2187d.f17ca8",
        "g": "5aabb8329669cca2",
        "name": "本月",
        "topic": "esp32s_water/sensor/this_month",
        "qos": "0",
        "retain": "true",
        "respTopic": "",
        "contentType": "",
        "userProps": "",
        "correl": "",
        "expiry": "",
        "broker": "22b93c622b5df242",
        "x": 830,
        "y": 3800,
        "wires": []
    },
    {
        "id": "ee67cdba.c347e",
        "type": "change",
        "z": "f6f2187d.f17ca8",
        "g": "5aabb8329669cca2",
        "name": "本月",
        "rules": [
            {
                "t": "move",
                "p": "payload[0].d3",
                "pt": "msg",
                "to": "payload",
                "tot": "msg"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 550,
        "y": 3800,
        "wires": [
            [
                "f5d351c.7fa6db"
            ]
        ]
    },
    {
        "id": "3ea0f493.f22634",
        "type": "mqtt out",
        "z": "f6f2187d.f17ca8",
        "g": "5aabb8329669cca2",
        "name": "上月",
        "topic": "esp32s_water/sensor/last_month",
        "qos": "0",
        "retain": "true",
        "respTopic": "",
        "contentType": "",
        "userProps": "",
        "correl": "",
        "expiry": "",
        "broker": "22b93c622b5df242",
        "x": 830,
        "y": 3840,
        "wires": []
    },
    {
        "id": "acb53b1b.0cd358",
        "type": "change",
        "z": "f6f2187d.f17ca8",
        "g": "5aabb8329669cca2",
        "name": "上月",
        "rules": [
            {
                "t": "move",
                "p": "payload[0].d4",
                "pt": "msg",
                "to": "payload",
                "tot": "msg"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 550,
        "y": 3840,
        "wires": [
            [
                "3ea0f493.f22634"
            ]
        ]
    },
    {
        "id": "b0f09ef3.4b0c9",
        "type": "function",
        "z": "f6f2187d.f17ca8",
        "g": "5aabb8329669cca2",
        "name": "相加",
        "func": "//将本周用电量加上今日实时用电量  得出最新的本周用电量\nmsg.payload = Number(msg.payload) + Number(msg.jt);\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 690,
        "y": 3720,
        "wires": [
            [
                "39af7a27.7b04f6"
            ]
        ]
    },
    {
        "id": "f5d351c.7fa6db",
        "type": "function",
        "z": "f6f2187d.f17ca8",
        "g": "5aabb8329669cca2",
        "name": "相加",
        "func": "//将本月用电量加上今日实时用电量  得出最新的本月用电量\nmsg.payload = Number(msg.payload) + Number(msg.jt);\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 690,
        "y": 3800,
        "wires": [
            [
                "b8160812.22e7e8"
            ]
        ]
    },
    {
        "id": "1aca4370.6e8785",
        "type": "server-state-changed",
        "z": "f6f2187d.f17ca8",
        "g": "5aabb8329669cca2",
        "name": "今日用水量",
        "server": "99c664b867ad2e30",
        "version": 5,
        "outputs": 1,
        "exposeAsEntityConfig": "",
        "entityId": "sensor.daily_water_consumption",
        "entityIdType": "exact",
        "outputInitially": false,
        "stateType": "str",
        "ifState": "",
        "ifStateType": "str",
        "ifStateOperator": "is",
        "outputOnlyOnStateChange": true,
        "for": 0,
        "forType": "num",
        "forUnits": "minutes",
        "ignorePrevStateNull": false,
        "ignorePrevStateUnknown": false,
        "ignorePrevStateUnavailable": false,
        "ignoreCurrentStateUnknown": false,
        "ignoreCurrentStateUnavailable": false,
        "outputProperties": [
            {
                "property": "payload",
                "propertyType": "msg",
                "value": "",
                "valueType": "entityState"
            },
            {
                "property": "data",
                "propertyType": "msg",
                "value": "",
                "valueType": "eventData"
            },
            {
                "property": "topic",
                "propertyType": "msg",
                "value": "",
                "valueType": "triggerId"
            }
        ],
        "x": 120,
        "y": 3880,
        "wires": [
            [
                "d606da6b.8c25d8"
            ]
        ]
    },
    {
        "id": "627b9fe6.71d368",
        "type": "mysql",
        "z": "f6f2187d.f17ca8",
        "g": "5aabb8329669cca2",
        "mydb": "f30e442.46d6a38",
        "name": "数据库",
        "x": 410,
        "y": 3880,
        "wires": [
            [
                "d71eaf9b.e70e8",
                "c6a6fdf8.09f01",
                "ee67cdba.c347e",
                "acb53b1b.0cd358",
                "2716b815c1611442"
            ]
        ]
    },
    {
        "id": "43567a10.ed7b74",
        "type": "mqtt out",
        "z": "f6f2187d.f17ca8",
        "g": "5aabb8329669cca2",
        "name": "本周用水量",
        "topic": "homeassistant/sensor/esp32s_water/1/config",
        "qos": "0",
        "retain": "true",
        "respTopic": "",
        "contentType": "",
        "userProps": "",
        "correl": "",
        "expiry": "",
        "broker": "22b93c622b5df242",
        "x": 1350,
        "y": 3720,
        "wires": []
    },
    {
        "id": "aced1bb.32392e8",
        "type": "inject",
        "z": "f6f2187d.f17ca8",
        "g": "5aabb8329669cca2",
        "name": "自动发现",
        "props": [
            {
                "p": "payload"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": true,
        "onceDelay": "1",
        "topic": "",
        "payload": "{"unit_of_measurement":"m³","device_class":"sensor","unique_id":"water_this_work","state_topic":"esp32s_water/sensor/this_work","name":"本周用水量"}",
        "payloadType": "json",
        "x": 1040,
        "y": 3720,
        "wires": [
            [
                "bf98089f.a7d578"
            ]
        ]
    },
    {
        "id": "bf98089f.a7d578",
        "type": "rbe",
        "z": "f6f2187d.f17ca8",
        "g": "5aabb8329669cca2",
        "name": "",
        "func": "rbe",
        "gap": "",
        "start": "",
        "inout": "out",
        "property": "payload",
        "x": 1190,
        "y": 3720,
        "wires": [
            [
                "43567a10.ed7b74"
            ]
        ]
    },
    {
        "id": "47f7fb79.b15ecc",
        "type": "mqtt out",
        "z": "f6f2187d.f17ca8",
        "g": "5aabb8329669cca2",
        "name": "上周用水量",
        "topic": "homeassistant/sensor/esp32s_water/2/config",
        "qos": "0",
        "retain": "true",
        "respTopic": "",
        "contentType": "",
        "userProps": "",
        "correl": "",
        "expiry": "",
        "broker": "22b93c622b5df242",
        "x": 1350,
        "y": 3760,
        "wires": []
    },
    {
        "id": "87599a40.d5562",
        "type": "inject",
        "z": "f6f2187d.f17ca8",
        "g": "5aabb8329669cca2",
        "name": "自动发现",
        "props": [
            {
                "p": "payload"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": true,
        "onceDelay": "1",
        "topic": "",
        "payload": "{"unit_of_measurement":"m³","device_class":"sensor","unique_id":"water_last_work","state_topic":"esp32s_water/sensor/last_work","name":"上周用水量"}",
        "payloadType": "json",
        "x": 1040,
        "y": 3760,
        "wires": [
            [
                "fada92ab.eacd3"
            ]
        ]
    },
    {
        "id": "fada92ab.eacd3",
        "type": "rbe",
        "z": "f6f2187d.f17ca8",
        "g": "5aabb8329669cca2",
        "name": "",
        "func": "rbe",
        "gap": "",
        "start": "",
        "inout": "out",
        "property": "payload",
        "x": 1190,
        "y": 3760,
        "wires": [
            [
                "47f7fb79.b15ecc"
            ]
        ]
    },
    {
        "id": "b9588b7a.b9b81",
        "type": "mqtt out",
        "z": "f6f2187d.f17ca8",
        "g": "5aabb8329669cca2",
        "name": "本月用水量",
        "topic": "homeassistant/sensor/esp32s_water/3/config",
        "qos": "0",
        "retain": "true",
        "respTopic": "",
        "contentType": "",
        "userProps": "",
        "correl": "",
        "expiry": "",
        "broker": "22b93c622b5df242",
        "x": 1350,
        "y": 3800,
        "wires": []
    },
    {
        "id": "a164a83d.756c78",
        "type": "inject",
        "z": "f6f2187d.f17ca8",
        "g": "5aabb8329669cca2",
        "name": "自动发现",
        "props": [
            {
                "p": "payload"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": true,
        "onceDelay": "1",
        "topic": "",
        "payload": "{"unit_of_measurement":"m³","device_class":"sensor","unique_id":"water_this_month","state_topic":"esp32s_water/sensor/this_month","name":"本月用水量"}",
        "payloadType": "json",
        "x": 1040,
        "y": 3800,
        "wires": [
            [
                "82c7517d.f97f6"
            ]
        ]
    },
    {
        "id": "82c7517d.f97f6",
        "type": "rbe",
        "z": "f6f2187d.f17ca8",
        "g": "5aabb8329669cca2",
        "name": "",
        "func": "rbe",
        "gap": "",
        "start": "",
        "inout": "out",
        "property": "payload",
        "x": 1190,
        "y": 3800,
        "wires": [
            [
                "b9588b7a.b9b81"
            ]
        ]
    },
    {
        "id": "402fecad.f6d254",
        "type": "inject",
        "z": "f6f2187d.f17ca8",
        "g": "5aabb8329669cca2",
        "name": "自动发现",
        "props": [
            {
                "p": "payload"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": true,
        "onceDelay": "1",
        "topic": "",
        "payload": "{"unit_of_measurement":"m³","device_class":"sensor","unique_id":"water_last_month","state_topic":"esp32s_water/sensor/last_month","name":"上月用水量"}",
        "payloadType": "json",
        "x": 1040,
        "y": 3840,
        "wires": [
            [
                "60a5d683.5d23"
            ]
        ]
    },
    {
        "id": "60a5d683.5d23",
        "type": "rbe",
        "z": "f6f2187d.f17ca8",
        "g": "5aabb8329669cca2",
        "name": "",
        "func": "rbe",
        "gap": "",
        "start": "",
        "inout": "out",
        "property": "payload",
        "x": 1190,
        "y": 3840,
        "wires": [
            [
                "fd29d03e.19de5"
            ]
        ]
    },
    {
        "id": "fd29d03e.19de5",
        "type": "mqtt out",
        "z": "f6f2187d.f17ca8",
        "g": "5aabb8329669cca2",
        "name": "上月用水量",
        "topic": "homeassistant/sensor/esp32s_water/4/config",
        "qos": "0",
        "retain": "true",
        "respTopic": "",
        "contentType": "",
        "userProps": "",
        "correl": "",
        "expiry": "",
        "broker": "22b93c622b5df242",
        "x": 1350,
        "y": 3840,
        "wires": []
    },
    {
        "id": "3a5b1f229d5ac474",
        "type": "mysql",
        "z": "f6f2187d.f17ca8",
        "g": "5aabb8329669cca2",
        "mydb": "f30e442.46d6a38",
        "name": "数据库",
        "x": 410,
        "y": 3720,
        "wires": [
            []
        ]
    },
    {
        "id": "2716b815c1611442",
        "type": "change",
        "z": "f6f2187d.f17ca8",
        "g": "5aabb8329669cca2",
        "name": "本年",
        "rules": [
            {
                "t": "move",
                "p": "payload[0].d5",
                "pt": "msg",
                "to": "payload",
                "tot": "msg"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 550,
        "y": 3880,
        "wires": [
            [
                "e954b3588272f65a"
            ]
        ]
    },
    {
        "id": "e954b3588272f65a",
        "type": "function",
        "z": "f6f2187d.f17ca8",
        "g": "5aabb8329669cca2",
        "name": "相加",
        "func": "//将本月用电量加上今日实时用电量  得出最新的本月用电量\nmsg.payload = Number(msg.payload) + Number(msg.jt);\nreturn msg;",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 690,
        "y": 3880,
        "wires": [
            [
                "56313c7539e5661a"
            ]
        ]
    },
    {
        "id": "56313c7539e5661a",
        "type": "mqtt out",
        "z": "f6f2187d.f17ca8",
        "g": "5aabb8329669cca2",
        "name": "本年",
        "topic": "esp32s_water/sensor/this_year",
        "qos": "0",
        "retain": "true",
        "respTopic": "",
        "contentType": "",
        "userProps": "",
        "correl": "",
        "expiry": "",
        "broker": "22b93c622b5df242",
        "x": 830,
        "y": 3880,
        "wires": []
    },
    {
        "id": "fa62e117cc0198c7",
        "type": "inject",
        "z": "f6f2187d.f17ca8",
        "g": "5aabb8329669cca2",
        "name": "自动发现",
        "props": [
            {
                "p": "payload"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": true,
        "onceDelay": "1",
        "topic": "",
        "payload": "{"unit_of_measurement":"m³","device_class":"sensor","unique_id":"water_this_year","state_topic":"esp32s_water/sensor/this_year","name":"本年用水量"}",
        "payloadType": "json",
        "x": 1040,
        "y": 3880,
        "wires": [
            [
                "457b3b8001534312"
            ]
        ]
    },
    {
        "id": "457b3b8001534312",
        "type": "rbe",
        "z": "f6f2187d.f17ca8",
        "g": "5aabb8329669cca2",
        "name": "",
        "func": "rbe",
        "gap": "",
        "start": "",
        "inout": "out",
        "property": "payload",
        "x": 1190,
        "y": 3880,
        "wires": [
            [
                "c8177c495fb470d0"
            ]
        ]
    },
    {
        "id": "c8177c495fb470d0",
        "type": "mqtt out",
        "z": "f6f2187d.f17ca8",
        "g": "5aabb8329669cca2",
        "name": "本年用水量",
        "topic": "homeassistant/sensor/esp32s_water/5/config",
        "qos": "0",
        "retain": "true",
        "respTopic": "",
        "contentType": "",
        "userProps": "",
        "correl": "",
        "expiry": "",
        "broker": "22b93c622b5df242",
        "x": 1350,
        "y": 3880,
        "wires": []
    },
    {
        "id": "99c664b867ad2e30",
        "type": "server",
        "name": "omv-homeassistant",
        "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": "at: ",
        "statusYear": "hidden",
        "statusMonth": "short",
        "statusDay": "numeric",
        "statusHourCycle": "h23",
        "statusTimeFormat": "h:m",
        "enableGlobalContextStore": true
    },
    {
        "id": "22b93c622b5df242",
        "type": "mqtt-broker",
        "name": "omv-emqx",
        "broker": "192.168.2.10",
        "port": "1883",
        "clientid": "node-red",
        "autoConnect": true,
        "usetls": false,
        "protocolVersion": "4",
        "keepalive": "60",
        "cleansession": true,
        "autoUnsubscribe": true,
        "birthTopic": "",
        "birthQos": "0",
        "birthPayload": "",
        "birthMsg": {},
        "closeTopic": "",
        "closeQos": "0",
        "closePayload": "",
        "closeMsg": {},
        "willTopic": "",
        "willQos": "0",
        "willPayload": "",
        "willMsg": {},
        "userProps": "",
        "sessionExpiry": ""
    },
    {
        "id": "f30e442.46d6a38",
        "type": "MySQLdatabase",
        "name": "",
        "host": "192.168.2.10",
        "port": "3306",
        "db": "esp32s_water",
        "tz": "",
        "charset": "UTF8"
    }
]

6. 完成效果
Screenshot_20240301_110749.png

Screenshot_20240301_110823.png

flows.zip (3.64 KB, 下载次数: 23)

评分

参与人数 8金钱 +63 收起 理由
翻滚吧暖菌 + 5 大神666!
cym9007 + 5 感谢楼主分享!
book123 + 10 论坛有你更精彩!
luosxn + 2 高手,这是高手!
kaka0992 + 10 高手,这是高手!
隔壁的王叔叔 + 10 高手,这是高手!
decoder + 5 在下对你的景仰犹如滔滔长江之水,连绵不绝.
sorrypqa + 16 大神666!

查看全部评分

回复

使用道具 举报

9

主题

225

帖子

2113

积分

论坛UI达人

积分
2113
金钱
1888
HASS币
0
发表于 2024-3-1 18:09:04 | 显示全部楼层
感谢大佬分享
回复

使用道具 举报

51

主题

1340

帖子

5600

积分

论坛DIY达人

积分
5600
金钱
4260
HASS币
20
发表于 2024-3-1 19:35:41 | 显示全部楼层
学习一下,谢谢楼主分享!
回复

使用道具 举报

25

主题

272

帖子

1858

积分

金牌会员

Rank: 6Rank: 6

积分
1858
金钱
1586
HASS币
0
发表于 2024-3-1 19:51:32 | 显示全部楼层
再加个电动球阀,做成自来水的测控
回复

使用道具 举报

4

主题

92

帖子

892

积分

论坛技术达人

积分
892
金钱
800
HASS币
8
发表于 2024-3-1 21:23:25 | 显示全部楼层
wpw72 发表于 2024-3-1 19:51
再加个电动球阀,做成自来水的测控

我就是安装了个球阀,只要人不在家,就关闭。有人回家就打开。同时也安装好几只小米的水浸传感器,也设定了漏水关阀。
回复

使用道具 举报

146

主题

2267

帖子

7004

积分

元老级技术达人

积分
7004
金钱
4732
HASS币
30
发表于 2024-3-1 21:52:14 | 显示全部楼层
怎么接线
回复

使用道具 举报

0

主题

86

帖子

746

积分

高级会员

Rank: 4

积分
746
金钱
660
HASS币
0
发表于 2024-3-1 21:56:45 | 显示全部楼层
压力传感器  是什么规格的?
回复

使用道具 举报

22

主题

319

帖子

3929

积分

论坛元老

Rank: 8Rank: 8

积分
3929
金钱
3605
HASS币
30
 楼主| 发表于 2024-3-1 22:20:14 | 显示全部楼层
xjol 发表于 2024-3-1 21:56
压力传感器  是什么规格的?

选5V电压,兼容Arduino的,
回复

使用道具 举报

22

主题

319

帖子

3929

积分

论坛元老

Rank: 8Rank: 8

积分
3929
金钱
3605
HASS币
30
 楼主| 发表于 2024-3-1 22:21:33 | 显示全部楼层

传感器就+-与信号3根线
回复

使用道具 举报

0

主题

12

帖子

130

积分

注册会员

Rank: 2

积分
130
金钱
118
HASS币
0
发表于 2024-3-2 11:55:19 | 显示全部楼层
流量计材质是不锈钢么?
回复

使用道具 举报

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

本版积分规则

Archiver|手机版|小黑屋|Hassbian

GMT+8, 2024-11-24 09:11 , Processed in 0.110736 second(s), 35 queries .

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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