diff --git a/custom_components/linktap/switch.py b/custom_components/linktap/switch.py index c1d9c49..f7f387b 100644 --- a/custom_components/linktap/switch.py +++ b/custom_components/linktap/switch.py @@ -2,6 +2,7 @@ import json import logging import random +import re import aiohttp import homeassistant.helpers.config_validation as cv @@ -82,14 +83,12 @@ def name(self): @property def duration_entity(self): - name = self._name.replace(" ", "_") - name = name.replace("-", "_") + name = re.sub('[^0-9a-zA-Z]+', '_', self._name) return f"number.{DOMAIN}_{name}_watering_duration".lower() @property def volume_entity(self): - name = self._name.replace(" ", "_") - name = name.replace("-", "_") + name = re.sub('[^0-9a-zA-Z]+', '_', self._name) return f"number.{DOMAIN}_{name}_watering_volume".lower() async def async_turn_on(self, **kwargs):