Source code for caspia.node.cli.commands.cmd_analog

import sys

import click

import caspia.node
from caspia.node.cli import utils


@utils.component_group_command(caspia.node.components.sensors.AnalogSensor)
def analog(*args, **kwargs):
    """Communicate with a AnalogSensor Component."""





@analog.command()
@utils.with_group_component
async def measure(component):
    """Measure current value and print."""
    value = await component.measure()
    print_data(value, value is None)


@analog.command('latest-measurement')
@utils.with_group_component
async def latest_measurement(component):
    """Print latest measurement."""
    state = await component.load_state()
    print_data(state.value, state.error)