_homeassistant.py 456 B

1234567891011
  1. # https://github.com/fphammerle/wireless-sensor-mqtt/blob/v0.3.0/wireless_sensor_mqtt/_homeassistant.py
  2. # https://github.com/fphammerle/systemctl-mqtt/blob/v0.5.0/systemctl_mqtt/_homeassistant.py
  3. import re
  4. # https://www.home-assistant.io/docs/mqtt/discovery/#discovery_prefix
  5. OBJECT_ID_ALLOWED_CHARS = r"a-zA-Z0-9_-"
  6. def validate_object_id(object_id: str) -> bool:
  7. return re.match(r"^[{}]+$".format(OBJECT_ID_ALLOWED_CHARS), object_id) is not None