增加了“蓝牙温湿度计2”,就是方方的那个:
elif db_pdid == 1371: #蓝牙温湿度计2
topic = "mqtttmhm/%s/%s"%(db_did,db_eid)
payload = int(revstr(db_edata),16)
if db_eid == 4100 or db_eid ==4102:
payload = payload / 10
elif db_eid != 4106:
syslog.syslog('蓝牙温湿度未知eid:%s' % respon)
这个蓝牙温湿度传感器,只有3条消息:
- 4100——温度,量纲0.1度
- 4102——湿度,量纲0.1%
- 4106——电量,量纲1%
相应地,hass中yaml配置:
sensor:
- platform: mqtt
name: btTemp
icon: 'mdi:thermometer'
state_topic: 'mqtttmhm/xxxxxx/4100'
device_class: temperature
unit_of_measurement: °C
- platform: mqtt
name: btHumi
icon: 'mdi:water-percent'
state_topic: 'mqtttmhm/xxxxxx/4102'
device_class: humidity
unit_of_measurement: '%'
- platform: mqtt
name: btBatt
icon: 'mdi:battery-charging'
state_topic: 'mqtttmhm/xxxxxx/4106'
homeassistant:
customize:
sensor.btTemp:
friendly_name: 蓝牙温度
sensor.btHumi:
friendly_name: 蓝牙湿度
sensor.btBatt:
friendly_name: 蓝牙电量
把xxxxxx替换成你自己的传感器pdid即可。
|