示例#1
0
def _homeassistant_cmd(ctx: Configuration, entities, cmd, action):
    """Run command on Home Assistant."""
    data = {'entity_id': entities}
    _LOGGING.debug("%s on %s", cmd, entities)
    result = api.call_service(ctx, 'homeassistant', cmd, data)

    _report(ctx, result, action)
def _homeassistant_cmd(ctx: Configuration, entities, cmd, action):
    """Run command on home assistant."""
    data = {'entity_id': entities}
    _LOGGING.debug("%s on %s", cmd, entities)
    result = api.call_service(ctx, 'homeassistant', cmd, data)

    _report(ctx, result, action)
示例#3
0
def call(ctx: Configuration, service, arguments):
    """Call a service."""
    ctx.auto_output('data')
    _LOGGING.debug("service call <start>")
    parts = service.split(".")
    if len(parts) != 2:
        _LOGGING.error("Service name not following <domain>.<service> format")
        sys.exit(1)

    _LOGGING.debug("Convert arguments %s to dict", arguments)
    data = to_attributes(arguments)

    _LOGGING.debug("service call_service")

    result = api.call_service(ctx, parts[0], parts[1], data)

    _LOGGING.debug("Formatting output")
    ctx.echo(format_output(ctx, result))
def call(ctx: Configuration, service, arguments):
    """Call a service."""
    ctx.auto_output('data')
    _LOGGING.debug("service call <start>")
    parts = service.split(".")
    if len(parts) != 2:
        _LOGGING.error("Service name not following <domain>.<service> format.")
        sys.exit(1)

    _LOGGING.debug("Convert arguments %s to dict", arguments)
    data = to_attributes(arguments)

    _LOGGING.debug("service call_service")

    result = api.call_service(ctx, parts[0], parts[1], data)

    _LOGGING.debug("Formatting ouput")
    ctx.echo(format_output(ctx, result))