1
0
mirror of https://github.com/esphome/esphome.git synced 2025-09-10 07:12:21 +01:00

EntityBase: Move ObjectId to Flash (#4569)

* Move EntityBase Object Id from memory to flash.

* Sprinkler use common `setup_entity` method.

* Remove `EntityBase` from Sprinkler.

* Support for entity names set to None

* change so gh PR picks up commit.

---------

Co-authored-by: Your Name <you@example.com>
Co-authored-by: Jesse Hills <3060199+jesserockz@users.noreply.github.com>
This commit is contained in:
Fabian
2023-03-28 11:00:34 +02:00
committed by GitHub
parent 922344811f
commit 3ac7bf3761
5 changed files with 82 additions and 8 deletions

View File

@@ -7,6 +7,7 @@ from pathlib import Path
from typing import Union
import tempfile
from urllib.parse import urlparse
import re
_LOGGER = logging.getLogger(__name__)
@@ -334,3 +335,13 @@ def add_class_to_obj(value, cls):
if type(value) is type_: # pylint: disable=unidiomatic-typecheck
return add_class_to_obj(func(value), cls)
raise
def snake_case(value):
"""Same behaviour as `helpers.cpp` method `str_snake_case`."""
return value.replace(" ", "_").lower()
def sanitize(value):
"""Same behaviour as `helpers.cpp` method `str_sanitize`."""
return re.sub("[^-_0-9a-zA-Z]", r"", value)