Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit51ef166

Browse files
committed
Fix response from script
1 parent6b0afeb commit51ef166

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

‎custom_components/python_script/__init__.py‎

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
"""Some dummy docs for execute_script."""
12
importhashlib
23
importlogging
34

@@ -101,12 +102,14 @@ def handler(call: ServiceCall) -> ServiceResponse:
101102
defexecute_script(hass:HomeAssistant,data:dict,logger,code)->ServiceResponse:
102103
try:
103104
_LOGGER.debug("Run python script")
104-
exec(code, {**globals(),**locals()})
105+
vars= {**globals(),**locals()}
106+
exec(code,vars)
105107
response= {
106108
k:v
107-
fork,vinlocals().items()
109+
fork,vinvars.items()
108110
ifisinstance(v, (dict,list,str,int,float,bool))
109-
andknotin ("__builtins__","data")
111+
andknotinglobals()
112+
andk!="data"
110113
orvisNone
111114
}
112115
returnresponse

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp