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

 找回密码
 立即注册
查看: 2091|回复: 5

[技术探讨] ESPURNA zm1 ztc1 怎么添加Homeassistant mqtt已连接

[复制链接]

17

主题

253

帖子

1833

积分

金牌会员

Rank: 6Rank: 6

积分
1833
金钱
1580
HASS币
0
发表于 2022-10-2 01:23:51 | 显示全部楼层 |阅读模式
本帖最后由 lqf1206 于 2022-10-2 01:38 编辑

ESPURNA  HASS中显示的代码复制到configuration.yaml 报错了怎么修改?
ESPURNA STATUS.png

ESPurna.png

HASS  .png

config.png

HASS.png

回复

使用道具 举报

17

主题

253

帖子

1833

积分

金牌会员

Rank: 6Rank: 6

积分
1833
金钱
1580
HASS币
0
 楼主| 发表于 2022-10-2 02:16:57 | 显示全部楼层
ZM1代码怎么加到Hass?
sensor:
  - platform: mqtt
    name: 'zm1_MACMAC_temperature'
    # friendly_name: 温度
    state_topic: 'device/zm1/MACMAC/sensor'
    unit_of_measurement: '°C'
    icon: 'mdi:thermometer'
    value_template: '{{ value_json.temperature }}'
  - platform: mqtt
    name: 'zm1_MACMAC_humidity'
    # friendly_name: 湿度
    state_topic: 'device/zm1/MACMAC/sensor'
    unit_of_measurement: '%'
    icon: mdi:water-percent
    value_template: '{{ value_json.humidity }}'
  - platform: mqtt
    name: 'zm1_MACMAC_pm25'
    # friendly_name: PM25
    state_topic: 'device/zm1/MACMAC/sensor'
    unit_of_measurement: 'μg/m³'
    icon: mdi:blur
    value_template: '{{ value_json.PM25 }}'
  - platform: mqtt
    name: 'zm1_MACMAC_hcho'
    # friendly_name: 甲醛
    state_topic: 'device/zm1/MACMAC/sensor'
    unit_of_measurement: 'mg/m³'
    icon: mdi:chemical-weapon
    value_template: '{{ value_json.formaldehyde }}'

light:
  - platform: mqtt
    name: zm1_MACMAC_brightness
    schema: template
    command_topic: "device/zm1/MACMAC/set"
    state_topic: "device/zm1/MACMAC/state"
    command_on_template: >
      {"mac": "MACMAC"
      {%- if brightness is defined -%}
      , "brightness": {{ ((brightness-1) / 64 )|int +1 }}
      {%- else -%}
      , "brightness": 4
      {%- endif -%}
      }
    command_off_template: '{"mac": "MACMAC", "brightness": 0}'
    state_template: >
      {%- if value_json.brightness == 0 -%}
        off
      {%- else -%}
        on
      {%- endif -%}
    brightness_template: >
      {%- if value_json.brightness is defined -%}
        {{ ( value_json.brightness *64 )|int }}
      {%- endif -%}


homeassistant:
  customize:
    light.zm1_MACMAC_brightness:
      friendly_name: 卧室M1亮度
    sensor.zm1_MACMAC_temperature:
      friendly_name: 卧室温度
    sensor.zm1_MACMAC_humidity:
      friendly_name: 卧室湿度
    sensor.zm1_MACMAC_pm25:
      friendly_name: 卧室PM2.5
    sensor.zm1_MACMAC_hcho:
      friendly_name: 卧室甲醛
回复

使用道具 举报

33

主题

2196

帖子

5838

积分

论坛元老

Rank: 8Rank: 8

积分
5838
金钱
3642
HASS币
60
QQ
发表于 2022-10-2 20:28:02 | 显示全部楼层
本帖最后由 zxyny1989 于 2022-10-2 20:29 编辑
1、使用新的mqtt写法,不然明年就用不了了。
2、 state_topic: 'device/zm1/MACMAC/sensor'    MACMAC改成自己M1的mac地址



mqtt:
  sensor:
    - name: 'zm1_MACMAC_temperature'
      # friendly_name: 温度
      state_topic: 'device/zm1/MACMAC/sensor'
      unit_of_measurement: '°C'
      icon: 'mdi:thermometer'
      value_template: '{{ value_json.temperature }}'
    - name: 'zm1_MACMAC_humidity'
      # friendly_name: 湿度
      state_topic: 'device/zm1/MACMAC/sensor'
      unit_of_measurement: '%'
      icon: mdi:water-percent
      value_template: '{{ value_json.humidity }}'
    - name: 'zm1_MACMAC_pm25'
      # friendly_name: PM25
      state_topic: 'device/zm1/MACMAC/sensor'
      unit_of_measurement: 'μg/m³'
      icon: mdi:blur
      value_template: '{{ value_json.PM25 }}'
    - name: 'zm1_MACMAC_hcho'
      # friendly_name: 甲醛
      state_topic: 'device/zm1/MACMAC/sensor'
      unit_of_measurement: 'mg/m³'
      icon: mdi:chemical-weapon
      value_template: '{{ value_json.formaldehyde }}'

  light:
    - name: zm1_MACMAC_brightness
      schema: template
      command_topic: "device/zm1/MACMAC/set"
      state_topic: "device/zm1/MACMAC/state"
      command_on_template: >
        {"mac": "MACMAC"
        {%- if brightness is defined -%}
        , "brightness": {{ ((brightness-1) / 64 )|int +1 }}
        {%- else -%}
        , "brightness": 4
        {%- endif -%}
        }
      command_off_template: '{"mac": "MACMAC", "brightness": 0}'
      state_template: >
        {%- if value_json.brightness == 0 -%}
          off
        {%- else -%}
          on
        {%- endif -%}
      brightness_template: >
        {%- if value_json.brightness is defined -%}
          {{ ( value_json.brightness *64 )|int }}
        {%- endif -%}


homeassistant:
  customize:
    light.zm1_MACMAC_brightness:
      friendly_name: 卧室M1亮度
    sensor.zm1_MACMAC_temperature:
      friendly_name: 卧室温度
    sensor.zm1_MACMAC_humidity:
      friendly_name: 卧室湿度
    sensor.zm1_MACMAC_pm25:
      friendly_name: 卧室PM2.5
    sensor.zm1_MACMAC_hcho:
      friendly_name: 卧室甲醛

评分

参与人数 1金钱 +5 收起 理由
lqf1206 + 5 在下对你的景仰犹如滔滔长江之水,连绵不绝.

查看全部评分

我不生产技术,我只是技术的搬运工。
回复

使用道具 举报

2

主题

39

帖子

404

积分

论坛分享达人

积分
404
金钱
365
HASS币
0
发表于 2022-10-5 17:47:41 | 显示全部楼层

多谢大佬~已搞定~~~
回复

使用道具 举报

0

主题

12

帖子

113

积分

注册会员

Rank: 2

积分
113
金钱
101
HASS币
0
发表于 2022-10-11 23:50:07 | 显示全部楼层
回复

使用道具 举报

17

主题

253

帖子

1833

积分

金牌会员

Rank: 6Rank: 6

积分
1833
金钱
1580
HASS币
0
 楼主| 发表于 2022-10-12 22:53:53 | 显示全部楼层
本帖最后由 lqf1206 于 2022-10-12 23:17 编辑

HASS.png
那里的问题?
回复

使用道具 举报

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

本版积分规则

Archiver|手机版|小黑屋|Hassbian

GMT+8, 2024-11-29 00:32 , Processed in 0.139298 second(s), 32 queries .

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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