本帖最后由 eyinhe 于 2020-8-27 15:12 编辑
感谢楼主,经过一番周折,M1终于又能控制了!
感觉就是那个easylink APP在作怪,换了路由器,用它来设置联网,原本在Home Assistant一切正常的M1,之后就是得不到数据。我又收了个M1回来,还是一样!最后只能刷楼主的zM1固件,装SmartControl_Android_MQTT APP,装MQTT服务器,然后集成到Home Assistant里,转了一大圈,才回到了换路由之前的状态。固件写入中:
另外贴一下我的Home Assistant的两个配置文件(其他不动):
configuration.yaml
homeassistant:
# Name of the location where Home Assistant is running
name: Home
# Location required to calculate the time the sun rises and sets
latitude: 24.057386
longitude: 114.581566
# Impacts weather/sunrise data (altitude above sea level in meters)
elevation: 0
# metric for Metric, imperial for Imperial
unit_system: metric
# Pick yours from here: http://en.wikipedia.org/wiki/List_of_tz_database_time_zones
time_zone: Asia/Shanghai
# Customization file
customize: !include customize.yaml
# Configure a default setup of Home Assistant (frontend, api, etc)
default_config:
# Show the introduction message on startup.
introduction:
# Uncomment this if you are using SSL/TLS, running in Docker container, etc.
# http:
# base_url: example.duckdns.org:8123
# Discover some devices automatically
discovery:
sensor:
- platform: mqtt
name: 'zm1_小写mac地址_temperature'
# friendly_name: 温度
state_topic: 'device/zm1/小写mac地址/sensor'
unit_of_measurement: '°C'
icon: 'mdi:thermometer'
value_template: '{{ value_json.temperature }}'
- platform: mqtt
name: 'zm1_小写mac地址_humidity'
# friendly_name: 湿度
state_topic: 'device/zm1/小写mac地址/sensor'
unit_of_measurement: '%'
icon: mdi:water-percent
value_template: '{{ value_json.humidity }}'
- platform: mqtt
name: 'zm1_小写mac地址_pm25'
# friendly_name: PM2.5
state_topic: 'device/zm1/小写mac地址/sensor'
unit_of_measurement: 'μg/m³'
icon: mdi:blur
value_template: '{{ value_json.PM25 }}'
- platform: mqtt
name: 'zm1_小写mac地址_hcho'
# friendly_name: 甲醛
state_topic: 'device/zm1/小写mac地址/sensor'
unit_of_measurement: 'mg/m³'
icon: mdi:chemical-weapon
value_template: '{{ value_json.formaldehyde }}'
light:
- platform: mqtt
name: zm1_小写mac地址_brightness
schema: template
command_topic: "device/zm1/小写mac地址/set"
state_topic: "device/zm1/小写mac地址/state"
command_on_template: >
{"mac": "小写mac地址"
{%- if brightness is defined -%}
, "brightness": {{ ((brightness-1) / 64 )|int +1 }}
{%- else -%}
, "brightness": 4
{%- endif -%}
}
command_off_template: '{"mac": "小写mac地址", "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_小写mac地址_brightness:
friendly_name: 亮度
sensor.zm1_小写mac地址_temperature:
friendly_name: 温度
sensor.zm1_小写mac地址_humidity:
friendly_name: 湿度
sensor.zm1_小写mac地址_pm25:
friendly_name: PM2.5
sensor.zm1_小写mac地址_hcho:
friendly_name: 甲醛
group.M1:
friendly_name: 悟空M1
group: !include groups.yaml
automation: !include automations.yaml
script: !include scripts.yaml
groups.yaml
default_view:
view: yes
icon: mdi:home-assistant
entities:
- group.M1
M1:
entities:
- sensor.zm1_小写mac地址_pm25
- sensor.zm1_小写mac地址_hcho
- sensor.zm1_小写mac地址_temperature
- sensor.zm1_小写mac地址_humidity
- light.zm1_小写mac地址_brightness
上面两个文件中的“小写mac地址”换成自己的就行了。我的Home Assistant版本是0.91.4,版本太新的话,不一定行。
完成之后的效果:
|