MX10085 发表于 2023-5-13 15:21:41

分享一个修改版NodeRed定制推送信息流

本帖最后由 MX10085 于 2023-5-14 08:25 编辑

分享一个修改版NodeRed定制推送信息流,改自wshc1216 大佬的NodeRed流,根据自己的情况排版与美化了一下界面。
其中里面的模板节点,可以用135编辑器进行修改。

原帖:分享一些自用node-red流

定制推送介绍:
可设置多个不同的可推送内容。如:天气、电量统计、设备状态、油价、等多个独立内容。
可设置多个不同时间推送
所有用户都可以直接在微信上用指令实现 定制自己的推送内容,或者取消推送。

















sorrypqa 发表于 2023-5-14 08:21:32

够复杂,我一看到这么多框框头就晕了.....

aabbcc7788 发表于 2023-5-15 21:02:22

谢谢!!!!!!!!!!!!

[email protected] 发表于 2023-9-15 09:25:58

你好 大佬,企业微信自建应用还可以用吗,我域名备案与企业微信同名 都用不了

ylilike 发表于 2023-9-15 11:35:33

谢谢分享,学习备用。

Seven0418 发表于 2023-9-15 15:34:10

https://img.uvh.cc/i/2023/09/15/pcy5uy-1.png请问下这个是什么设备,怎么获取所有设备的状态

a_dongde 发表于 2023-9-15 16:06:34

改成钉钉推送好改吗?我是内建的钉钉插件,通过调用HA的推送服务的

MX10085 发表于 2023-9-16 19:28:51

Seven0418 发表于 2023-9-15 15:34
请问下这个是什么设备,怎么获取所有设备的状态

自建的HA传感器。

Seven0418 发表于 2023-9-18 12:36:07

MX10085 发表于 2023-9-16 19:28
自建的HA传感器。

能看一下这个传感器的config配置参数吗

MX10085 发表于 2023-9-18 18:46:54

Seven0418 发表于 2023-9-18 12:36
能看一下这个传感器的config配置参数吗

可以,


template:
- sensor:
      - unique_id: sidebar_mattias
      state: template
      attributes:
          time: >
            {% set hours = now().strftime('%H') %}
            {% set minutes = now().strftime('%M') %}
            {{ hours }}:{{ minutes }}

          date: >
            {% if strptime(states('sensor.date'), '%Y-%m-%d').day != None %}
            {% set days = ['星期一', '星期二', '星期三', '星期四', '星期五', '星期六', '星期日'] %}
            {% set months = ['1月', '2月', '3月', '4月', '5月', '6月',
            '7月', '8月', '9月', '10月', '11月', '12月'] %}
            {{ months }} {{ strptime(states('sensor.date'), '%Y-%m-%d').day }}日 {{ days }}
            {% endif %}

          weather: >
            {% set entity = 'weather.jia' %}
            {% if not is_state(entity, 'unknown') %}
            {% set temp = state_attr(entity, 'temperature') | round %}
            {% set precip = state_attr(entity, 'hourly_precipitation')['value'] | round %}
                温度{{ temp }}°, {{ '不会下雨' if precip == 0
                else precip | string + 'mm 雨水 \u2614\uFE0F' }}
            {% else %}
            无法加载天气信息...
            {% endif %}

          greet: >
            {% set time = now().hour %}
            {% if time <= 1 %} 夜深了,晚安!{{'\U0001F611'}}
            {% elif time <= 3 %} 夜深了,晚安! {{'\U0001F62A'}}
            {% elif time <= 5 %} 夜深了,晚安! {{'\U0001F634'}}
            {% elif time <= 7 %} 天亮了,美好的一天又开始了! {{'\u2615\uFE0F'}}
            {% elif time <= 9 %} 早上好!{{'\u2615\uFE0F'}}
            {% elif time <= 10 %} 早上好! {{'\U0001F642'}}
            {% elif time <= 13 %} 中午休息好了吗? {{'\U0001F60A'}}
            {% elif time <= 15 %} 很好的一天! {{'\U0001F60E'}}
            {% elif time <= 17 %} 很好的一天! {{'\U0001F44B\U0001F3FB'}}
            {% elif time <= 19 %} 晚上好! {{'\U0001F44B\U0001F3FB'}}
            {% elif time <= 22 %} 累了一天,休息一下吧! {{'\U0001F60C'}}
            {% elif time <= 23 %} 夜深了,该休息了! {{'\U0001F974'}}
            {% else %} 晚上好! {{'\U0001F974'}}
            {% endif %}

          device_active: >
            {% set lights = [
            states.light.yi_lou_ke_ting,
            states.light.yi_lou_fang_jian,
            states.light.yi_lou_fan_ting,
            states.light.ru_hu_zhao_ming,
            states.light.yi_lou_chu_fang,
            states.light.yi_lou_gong_wei,
            states.light.yi_lou_ti_jian,
            states.light.yi_lou_lou_ti,
            states.light.da_men_zhao_ming,
            states.light.er_lou_ti_tai,
            states.light.er_lou_ke_ting,
            states.light.er_lou_nan_fang,
            states.light.er_lou_bei_fang,
            states.light.er_lou_gong_wei,
            states.light.er_lou_lou_ti,
            states.light.er_lou_bei_yong,
            states.light.san_lou_ti_tai,
            states.light.san_lou_fang_jian,
            states.light.san_lou_gong_wei,
            states.light.san_lou_yang_tai,
            states.light.lumi_acn01_71fb_light
            ] %}

            {% set switches = [
            states.switch.lumi_ctrl_86plug_aq1_c2d1_switch,
            states.switch.lumi_ctrl_86plug_aq1_5dae_switch,
            states.switch.lumi_ctrl_86plug_aq1_0dd0_switch,
            states.switch.lumi_ctrl_86plug_aq1_6041_switch,
            states.switch.ccb5d1e8b8a1_outlet,
            states.switch.ccb5d1e8e7d7_outlet,
            states.switch.er_lou_ke_ting_s1,
            states.switch.er_lou_ke_ting_s2,
            states.switch.er_lou_ke_ting_s3,
            states.switch.er_lou_ke_ting_s4
            ] %}

            {% set lights_on = lights | selectattr('state','eq','on') | list %}
            {% set lights_name = lights | selectattr('state','eq','on') | map(attribute='name') | join(', ') %}

            {% set switches_on = switches | selectattr('state','search','(on|cool|fan_only|playing)') | list %}
            {% set switches_name = switches_on | map(attribute='name') | join(', ') %}

            {% if (lights_on | length == 0) and (switches_on | length == 1) %}
            {{ switches_name }} 正在开启

            {% elif (lights_on | length == 0) and (switches_on | length > 1) %}
            {{ switches_on | length }} 个插座正在开启

            {% elif (lights_on | length == 1) and (switches_on | length == 1) %}
            {{ lights_name }} 和 {{ switches_name }} 正在开启

            {% elif (lights_on | length == 1) and (switches_on | length > 1) %}
            {{ lights_name }}, 和{{ switches_on | length }} 个插座正在开启

            {% elif (lights_on | length > 1) and (switches_on | length == 1) %}
            {{ lights_on | length }} 盏灯, 和 {{ switches_name }} 正在开启

            {% elif (lights_on | length > 1) and (switches_on | length > 1) %}
            {{ lights_on | length }} 盏灯, {{ switches_on | length }} 个插座正在开启

            {% elif (lights_on | length == 1) and (switches_on | length == 0) %}
            {{ lights_name }} 正在开启

            {% elif (lights_on | length > 1) and (switches_on | length == 0) %}
            {{ lights_on | length }} 盏灯正在开启

            {% else %}
            <font color='#6a7377'>全部关闭</font>
            {% endif %}

          media_play_active: >
            {% set media_players = [
            states.media_player.yun_yin_le,
            states.media_player.owntone_server,
            states.media_player.er_lou_she_bei,
            states.media_player.mpd,
            states.media_player.tts
            ] %}

            {% set media_players_on = media_players | selectattr('state','search','(on|playing)') | list %}
            {% set media_players_name = media_players | selectattr('state','search','(on|playing)') | map(attribute='name') | join(', ') %}

            {% if (media_players_on | length == 1) %}
            {{ media_players_name }} 正在播放

            {% elif (media_players_on | length > 1) %}
            {{ media_players_on | length }} 个设备正在播放
            {% endif %}

          washing_machine: >
            {% set entity_id = 'sensor.washing_machine' %}
            {% if is_state(entity_id, '待机中') %}
            洗衣机正在待机中
            {% elif is_state(entity_id, '清洗中') %}
            洗衣机正在清洗中
            {% elif is_state(entity_id, '浸泡中') %}
            洗衣机正在浸泡中
            {% elif is_state(entity_id, '脱水中') %}
            洗衣机正在脱水中
            {% elif is_state(entity_id, '暂停中') %}
            洗衣机正在暂停中
            {% elif is_state(entity_id, '请检查') %}
            请检查洗衣机状态
            {% elif is_state(entity_id, '已完成') %}
            洗衣机清洗已完成
            {% endif %}

          washing_machine_time: >
            {% set washing_machine_time = states('sensor.washing_machine_time') %}
            {{ washing_machine_time }}

          vacuum: >
            {% set entity_id = 'vacuum.viomi_v17_7e3e_robot_cleaner' %}
            {% if is_state(entity_id, 'cleaning') %}
            扫地机器人正在清扫
            {% elif is_state(entity_id, 'returning') %}
            扫地机器人正在返回
            {% elif is_state(entity_id, 'docked') %}
            扫地机器人停靠充电
            {% endif %}

          mijia_message: >
            {% set mijia_message = states('sensor.mi_27741538_message') %}
            {{ mijia_message }}

          battery: >
            {% set entities = states.sensor
            | selectattr('entity_id', 'search', 'battery')
            | rejectattr('entity_id', 'search', 'iphone')
            | map(attribute = 'entity_id') | list %}
            {% for sensor in entities if states(sensor) != 'unknown' and states(sensor) !=
            'unavailable' and states(sensor) != 'None' and states(sensor) | int(default=0) == 5 %}
            {% if loop.first %} {{'\u26A0\uFE0F'}} 低电量 {% else %}, {% endif %}
            {{ state_attr(sensor, 'friendly_name') }} {{ states(sensor) }}%
            {% endfor %}

          ups: >
            {% if is_state('sensor.ups_status', 'Online') %}
            {% else %}
            {{-'\u26A0\uFE0F'}} UPS 不在线, 请检查!
            {% endif %}

      - unique_id: domain_counter
      state: >
          {{ states | count }}
      attributes:
          automation: >
            {{ states.automation | count }}
          binary_sensor: >
            {{ states.binary_sensor | count }}
          device_tracker: >
            {{ states.device_tracker | count }}
          light: >
            {{ states.light | count }}
          media_player: >
            {{ states.media_player | count }}
          sensor: >
            {{ states.sensor | count }}
          switch: >
            {{ states.switch | count }}
          other: >
            {{ states.calendar | count +
            states.camera | count +
            states.climate | count +
            states.fan | count +
            states.input_boolean | count +
            states.input_number | count +
            states.input_select | count +
            states.lock | count +
            states.person | count +
            states.remote | count +
            states.scene | count +
            states.script | count +
            states.select | count +
            states.sun | count +
            states.timer | count +
            states.vacuum | count +
            states.weather | count +
            states.zone | count }}
            
      - unique_id: sidebar_weather
      state: "{{ state_attr('sensor.template_sidebar_mattias', 'weather') }}"
      attributes:
          friendly_name: "下雨概率"

      - unique_id: sidebar_greet
      state: "{{ state_attr('sensor.template_sidebar_mattias', 'greet') }}"
      attributes:
          friendly_name: "问候语"

      - unique_id: sidebar_device_active
      state: "{{ state_attr('sensor.template_sidebar_mattias', 'device_active') }}"
      attributes:
          friendly_name: "活动设备"

      - unique_id: sidebar_media_play_active
      state: "{{ state_attr('sensor.template_sidebar_mattias', 'media_play_active') }}"
      attributes:
          friendly_name: "播放设备"

      - unique_id: sidebar_vacuum
      state: "{{ state_attr('sensor.template_sidebar_mattias', 'vacuum') }}"
      attributes:
          friendly_name: "扫地机"

      - unique_id: sidebar_battery
      state: "{{ state_attr('sensor.template_sidebar_mattias', 'battery') }}"
      attributes:
          friendly_name: "电量过低"

      - unique_id: sidebar_ups
      state: "{{ state_attr('sensor.template_sidebar_mattias', 'ups') }}"
      attributes:
          friendly_name: "备用电源"
页: [1] 2
查看完整版本: 分享一个修改版NodeRed定制推送信息流