Skip to content

Commit

Permalink
0.16.0 Release
Browse files Browse the repository at this point in the history
  • Loading branch information
Adminiuga authored Apr 15, 2020
2 parents d26b5bb + 28cabcb commit 68fba66
Show file tree
Hide file tree
Showing 17 changed files with 492 additions and 201 deletions.
4 changes: 2 additions & 2 deletions bellows/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
MAJOR_VERSION = 0
MINOR_VERSION = 15
PATCH_VERSION = "2"
MINOR_VERSION = 16
PATCH_VERSION = "0"
__short_version__ = "{}.{}".format(MAJOR_VERSION, MINOR_VERSION)
__version__ = "{}.{}".format(__short_version__, PATCH_VERSION)
32 changes: 21 additions & 11 deletions bellows/cli/application.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,14 @@
import asyncio
import binascii

import bellows.config
import bellows.ezsp
import bellows.types as t
import bellows.zigbee.application
import click
import zigpy.config
import zigpy.endpoint
import zigpy.exceptions

from . import opts, util
from .main import main
Expand Down Expand Up @@ -88,8 +91,15 @@ def print_clusters(title, clusters):
for cluster_id, cluster in clusters:
click.echo(" %s (%s)" % (cluster.name, cluster_id))

ezsp = bellows.ezsp.EZSP()
app = bellows.zigbee.application.ControllerApplication(ezsp, database)
loop = asyncio.get_event_loop()
config = {
zigpy.config.CONF_DATABASE: database,
bellows.config.CONF_DEVICE: {bellows.config.CONF_DEVICE_PATH: "/dev/null"},
}
config = bellows.config.CONFIG_SCHEMA(config)
app = loop.run_until_complete(
bellows.zigbee.application.ControllerApplication.new(config, start_radio=False)
)
for ieee, dev in app.devices.items():
click.echo("Device:")
click.echo(" NWK: 0x%04x" % (dev.nwk,))
Expand Down Expand Up @@ -137,7 +147,7 @@ async def endpoints(ctx):
click.echo("Non-success response: %s" % (v,))
else:
click.echo(v[2])
except bellows.zigbee.exceptions.DeliveryError as e:
except zigpy.exceptions.ZigbeeException as e:
click.echo(e)


Expand All @@ -160,7 +170,7 @@ async def get_endpoint(ctx, endpoint):
click.echo("Non-success response: %s" % (v,))
else:
click.echo(v[2])
except bellows.zigbee.exceptions.DeliveryError as e:
except zigpy.exceptions.ZigbeeException as e:
click.echo(e)


Expand All @@ -181,7 +191,7 @@ async def bind(ctx, endpoint, cluster):
try:
v = await dev.zdo.bind(endpoint, cluster)
click.echo(v)
except bellows.zigbee.exceptions.DeliveryError as e:
except zigpy.exceptions.ZigbeeException as e:
click.echo(e)


Expand All @@ -202,7 +212,7 @@ async def unbind(ctx, endpoint, cluster):
try:
v = await dev.zdo.unbind(endpoint, cluster)
click.echo(v)
except bellows.zigbee.exceptions.DeliveryError as e:
except zigpy.exceptions.ZigbeeException as e:
click.echo(e)


Expand All @@ -216,7 +226,7 @@ async def leave(ctx):
try:
v = await app.remove(ctx.obj["node"])
click.echo(v)
except bellows.zigbee.exceptions.DeliveryError as e:
except zigpy.exceptions.ZigbeeException as e:
click.echo(e)


Expand Down Expand Up @@ -261,7 +271,7 @@ async def read_attribute(ctx, attribute, manufacturer):
)
else:
click.echo("%s=%s" % (attribute, v[0][attribute]))
except bellows.zigbee.exceptions.DeliveryError as e:
except zigpy.exceptions.ZigbeeException as e:
click.echo(e)


Expand All @@ -286,7 +296,7 @@ async def write_attribute(ctx, attribute, value, manufacturer):
{attribute: value}, manufacturer=manufacturer
)
click.echo(v)
except bellows.zigbee.exceptions.DeliveryError as e:
except zigpy.exceptions.ZigbeeException as e:
click.echo(e)


Expand Down Expand Up @@ -330,7 +340,7 @@ async def command(ctx, command, parameters, manufacturer):
click.echo(v)
except ValueError as e:
click.echo(e)
except bellows.zigbee.exceptions.DeliveryError as e:
except zigpy.exceptions.ZigbeeException as e:
click.echo(e)


Expand Down Expand Up @@ -358,5 +368,5 @@ async def configure_reporting(
attribute, min_interval, max_interval, reportable_change
)
click.echo(v)
except bellows.zigbee.exceptions.DeliveryError as e:
except zigpy.exceptions.ZigbeeException as e:
click.echo(e)
28 changes: 20 additions & 8 deletions bellows/cli/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@
import functools
import logging

import bellows.config as config
import bellows.ezsp
import bellows.types as t
import click
import zigpy.config as zigpy_conf

LOGGER = logging.getLogger(__name__)

Expand All @@ -26,7 +28,7 @@ class ZigbeeNodeParamType(click.ParamType):
def convert(self, value, param, ctx):
if ":" not in value or len(value) != 23:
self.fail("Node format should be a 8 byte hex string seprated by ':'")
return t.EmberEUI64([t.uint8_t(p, base=16) for p in value.split(":")])
return t.EmberEUI64.convert(value)


def background(f):
Expand Down Expand Up @@ -90,11 +92,15 @@ def channel_mask(channels):


async def setup(dev, baudrate, cbh=None, configure=True):
s = bellows.ezsp.EZSP()
device_config = {
config.CONF_DEVICE_PATH: dev,
config.CONF_DEVICE_BAUDRATE: baudrate,
}
s = bellows.ezsp.EZSP(device_config)
if cbh:
s.add_callback(cbh)
try:
await s.connect(dev, baudrate)
await s.connect()
except Exception as e:
LOGGER.error(e)
raise click.Abort()
Expand All @@ -119,11 +125,17 @@ async def cfg(config_id, value):


async def setup_application(dev, baudrate, database_file, startup=True):
s = bellows.ezsp.EZSP()
await s.connect(dev, baudrate)
app = bellows.zigbee.application.ControllerApplication(s, database_file)
if startup:
await app.startup()
app_config = {
config.CONF_DEVICE: {
config.CONF_DEVICE_PATH: dev,
config.CONF_DEVICE_BAUDRATE: baudrate,
},
zigpy_conf.CONF_DATABASE: database_file,
}
app_config = bellows.zigbee.application.ControllerApplication.SCHEMA(app_config)
app = await bellows.zigbee.application.ControllerApplication.new(
app_config, startup
)
return app


Expand Down
26 changes: 26 additions & 0 deletions bellows/config/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import voluptuous as vol
from zigpy.config import ( # noqa: F401 pylint: disable=unused-import
CONF_DEVICE,
CONF_DEVICE_PATH,
CONFIG_SCHEMA,
SCHEMA_DEVICE,
cv_boolean,
)

from .ezsp import EZSP_SCHEMA

CONF_DEVICE_BAUDRATE = "baudrate"
CONF_EZSP_CONFIG = "ezsp_config"
CONF_PARAM_SRC_RTG = "source_routing"

SCHEMA_DEVICE = SCHEMA_DEVICE.extend(
{vol.Optional(CONF_DEVICE_BAUDRATE, default=57600): int}
)

CONFIG_SCHEMA = CONFIG_SCHEMA.extend(
{
vol.Required(CONF_DEVICE): SCHEMA_DEVICE,
vol.Optional(CONF_PARAM_SRC_RTG, default=False): cv_boolean,
vol.Optional(CONF_EZSP_CONFIG, default={}): vol.Schema(EZSP_SCHEMA),
}
)
Loading

0 comments on commit 68fba66

Please sign in to comment.