在\scripts\mqtt-autodiscovery.sh下找到这个
# Motor up/down/left/right
/system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "$AUTODISCOVERY_PREFIX/cover/$DEVICE_NAME/motor_up_down/config" ${MOSQUITTOPUBOPTS} ${MOSQUITTOOPTS} -r -m "{"name": "$DEVICE_NAME move up/down", "unique_id": "$MAC_SIMPLE-move-up-down", "device": {"identifiers": "$MAC_SIMPLE", "connections": [["mac", "$MAC"]], "manufacturer": "$MANUFACTURER", "model": "$MODEL", "name": "$MANUFACTURER $MODEL", "sw_version": "$VER"}, "set_position_topic": "$TOPIC/motors/vertical/set", "position_topic": "$TOPIC/motors/vertical", "command_topic": "$TOPIC/motors/vertical/set", "payload_close": "down", "payload_open": "up", "optimistic": "false", "value_template": "{{ ((value|int)/($MAX_Y/$STEP))|round }}", "set_position_template": "{{ ((position|int)*($MAX_Y/$STEP))|round }}"}"
/system/sdcard/bin/mosquitto_pub.bin -h "$HOST" -p "$PORT" -u "$USER" -P "$PASS" -t "$AUTODISCOVERY_PREFIX/cover/$DEVICE_NAME/motor_left_right/config" ${MOSQUITTOPUBOPTS} ${MOSQUITTOOPTS} -r -m "{"name": "$DEVICE_NAME move left/right", "unique_id": "$MAC_SIMPLE-move-left-right", "device": {"identifiers": "$MAC_SIMPLE", "connections": [["mac", "$MAC"]], "manufacturer": "$MANUFACTURER", "model": "$MODEL", "name": "$MANUFACTURER $MODEL", "sw_version": "$VER"}, "set_position_topic": "$TOPIC/motors/horizontal/set", "position_topic": "$TOPIC/motors/horizontal", "command_topic": "$TOPIC/motors/horizontal/set", "payload_close": "right", "payload_open": "left", "optimistic": "false", "value_template": "{{ ((value|int)/($MAX_X/$STEP))|round }}", "set_position_template": "{{ ((position|int)*($MAX_X/$STEP))|round }}"}"
结合google 到的资料,配置如下:
cover:
- platform: mqtt
name: "dafang move up/down"
set_position_topic: "myhome/dafang/motors/vertical/set"
position_topic: "myhome/dafang/motors/vertical"
# state_topic: "myhome/dafang/motors/vertical"
command_topic: "myhome/dafang/motors/vertical/set"
# qos: 1
payload_close: "down"
payload_open: "up"
# state_open: "up_endstop"
# state_close: "down_endstop"
optimistic: false
value_template: "{{ ((value|int)/7.3)|round }}"
set_position_template: "{{ ((value|int)/7.3)|round }}"
- platform: mqtt
name: "dafang move left/right"
set_position_topic: "myhome/dafang/motors//horizontal/set"
position_topic: "myhome/dafang/motors//horizontal"
# state_topic: "myhome/dafang/motors/horizontal"
command_topic: "myhome/dafang/motors/horizontal/set"
# qos: 1
payload_close: "right"
payload_open: "left"
# state_open: "left_endstop"
# state_close: "right_endstop"
optimistic: false
value_template: "{{ ((value|int)/27)|round }}"
set_position_template: "{{ ((position|int)/27)|round }}"
其中的value_template和set_position_template下的参数是google到的(貌似记得是启动日志里的)
然后关闭自动发现,重启HA,水平不能控,垂直能控但是有问题...
|