Skip to content

Commit 279c134

Browse files
committed
replaced zmq with minimal internal implementation to avoid zmq requirement
1 parent d819cd3 commit 279c134

File tree

7 files changed

+544
-263
lines changed

7 files changed

+544
-263
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -606,7 +606,7 @@ Four logging functions are provided, with increasing levels of severity:
606606
The [Logger](/integrations/logger/) component can be used to specify the logging level. Log messages
607607
below the configured level will not appear in the log. Each log message function uses a log name of
608608
the form:
609-
```python
609+
```yaml
610610
homeassistant.components.pyscript.file.FILENAME.FUNCNAME
611611
```
612612
where `FUNCNAME` is the name of the top-level Python function (e.g., the one called by a trigger or

custom_components/pyscript/__init__.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,12 @@ async def jupyter_kernel_start(call):
122122
async def state_changed(event):
123123
var_name = event.data["entity_id"]
124124
# attr = event.data["new_state"].attributes
125+
if "new_state" not in event.data or event.data["new_state"] is None:
126+
_LOGGER.debug(
127+
"state_changed: missing new_state in event.data=%s; ignoring",
128+
event.data,
129+
)
130+
return
125131
new_val = event.data["new_state"].state
126132
old_val = event.data["old_state"].state if event.data["old_state"] else None
127133
new_vars = {var_name: new_val, f"{var_name}.old": old_val}

custom_components/pyscript/global_ctx.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,15 @@
33
from collections import OrderedDict
44
import io
55
import logging
6+
67
import yaml
78

89
from homeassistant.const import SERVICE_RELOAD
910
from homeassistant.exceptions import HomeAssistantError
1011
from homeassistant.helpers.service import async_set_service_schema
1112

1213
from .const import DOMAIN, LOGGER_PATH, SERVICE_JUPYTER_KERNEL_START
13-
from .eval import AstEval, EvalFunc
14+
from .eval import AstEval
1415
from .trigger import TrigInfo
1516

1617

@@ -42,6 +43,7 @@ def __init__(
4243
self.auto_start = False
4344

4445
async def trigger_init(self, func):
46+
"""Initialize any decorator triggers for a newly defined function."""
4547
func_name = func.get_name()
4648
trig_args = {}
4749
got_reqd_dec = False
@@ -238,6 +240,7 @@ async def do_service_call(func, ast_ctx, data):
238240
await self.start()
239241

240242
def set_auto_start(self, auto_start):
243+
"""Set the auto-start flag."""
241244
self.auto_start = auto_start
242245

243246
async def start(self):

0 commit comments

Comments
 (0)