-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update the home assistant discovery type interface (#12)
update the home assistant discovery type interface
- Loading branch information
Showing
3 changed files
with
39 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
"""docker2mqtt helpers.""" | ||
|
||
from typing import Dict, Union | ||
|
||
from .type_definitions import ContainerEntry | ||
|
||
|
||
def clean_for_discovery( | ||
val: ContainerEntry, | ||
) -> Dict[str, Union[str, int, float, object]]: | ||
"""Cleanup a typed dict for home assistant discovery, which is quite picky and does not like empty of None values. | ||
Parameters | ||
---------- | ||
val | ||
The TypedDict to cleanup | ||
Returns | ||
------- | ||
dict | ||
The cleaned dict | ||
""" | ||
|
||
return { | ||
k: v | ||
for k, v in dict(val).items() | ||
if isinstance(v, (str, int, float, object)) and v not in (None, "") | ||
} |