Does there exist a json template (for python) that can be used to auto discover mqtt devices?.
I found a github where this nice fellow has made a python wrapper for a Horman Bisecur device that I have.
The github page is here: GitHub - smar000/bisecur2mqtt: MQTT wrapper to Hormann Bisecur Gateway Library
There is a home assistant auto discovery part in there, but it’s not been tested properly.
And when I try it, the Biscur is discovered as a single entity, and not as a device with multiple entities.
I suspect this comes down to proper json formatting, but I don’t know where to start.
The current code looks like this:
def init_ha_discovery():
payload = {"door_commands_list": ["impulse",
"up", "down", "partial", "stop", "light"],
"json_attributes_topic": f"{MQTT_TOPIC_BASE}/attributes",
"name": "Bisecur Gateway: Garage Door", "schema": "state",
"supported_features": ["impulse", "up", "down", "partial", "stop", "light", "get_door_state", "get_ports", "login", "sys_reset"],
"availability_topic": f"{MQTT_TOPIC_BASE}/state",
"payload_available": "online",
"payload_not_available": "offline",
"unique_id": "bs_garage_door",
"device_class": "garage",
"payload_close": "down",
"payload_open": "up",
"payload_stop": "impulse",
"position_open": 100,
"position_closed": 0,
"position_topic": f"{MQTT_TOPIC_BASE}/garage_door/position",
"state_topic": f"{MQTT_TOPIC_BASE}/garage_door/state",
"command_topic": f"{MQTT_TOPIC_BASE}/{MQTT_COMMAND_SUBTOPIC}/command"}
bisecur_mac = config.get("bisecur_mac", "").replace(':', '')
bisecur_ip = config.get("bisecur_ip", None)
payload["connections"] = ["mac", bisecur_mac, "ip", bisecur_ip]
payload["sw_version"] = VERSION
# _, payload["gw_hw_version"] = get_gw_version()
payload["gw_hw_version"] = '1.0.0'
mqtt_topic_HA_discovery = config.get("mqtt_topic_HA_discovery", "homeassistant")
publish_to_mqtt("cover/bisecur/config", json.dumps(payload), f"{mqtt_topic_HA_discovery}")
publish_to_mqtt("attributes/system_version", VERSION)
publish_to_mqtt("attributes/gw_ip_address", bisecur_ip)
publish_to_mqtt("attributes/gw_mac_address", bisecur_mac)
Any pointers is greatly appreciated.
Thanks