Emulates an Edge hardware-based room sensor client purely as a CLI application

Overview

ambi_mock_client

Usage

You must have Rust installed to build ambi_mock_client. You can find documentation on installing Rust here.

Using cargo run

cargo run {"tempurature":"33.5","humidity":"39.6","pressure":"1100","dust_concentration":"8","air_purity":"FRESH_AIR"}">
> cargo build
> cargo run
{"tempurature":"23.7","humidity":"63.8","pressure":"945","dust_concentration":"999","air_purity":"DANGEROUS"}

# Or just

> cargo run
{"tempurature":"33.5","humidity":"39.6","pressure":"1100","dust_concentration":"8","air_purity":"FRESH_AIR"}

As an executable binary

> cargo build
> ./target/debug/ambi_mock_client
{"tempurature":"25.9","humidity":"43.4","pressure":"1076","dust_concentration":"322","air_purity":"DANGEROUS"}
You might also like...
Yet Another Texture Packer - a small and simple CLI application to pack multiple textures/sprites into a texture atlas/sprite sheet

YATP (Yet Another Texture Packer) A small and simple CLI application to pack multiple textures/sprites into a texture atlas/sprite sheet. Installation

CLI Web client for moedict.tw

meowdict CLI Web client for moedict.tw Usage Console Mode

A Rust CLI tool that helps you enforce Git policies through Git hooks both server and client side

GitPolicyEnforcer This is a command line utility written in Rust, that helps you utilize Git hooks, to enforce various policies. It currently supports

CLI client for the Jagiellonian University's BaCa online judge
CLI client for the Jagiellonian University's BaCa online judge

baca-cli CLI client for the Jagiellonian University's BaCa online judge Installation The latest release can be downloaded here. Windows users can use

Nostr CLI client built with Rust

Nostr CLI client built with Rust Encrypted chat inside Nostr leaks metadata of who talks to who. This small CLI app implements a "public inbox," which

๐Ÿง‘โ€๐Ÿ’ป CLI client for zer0bin

๐Ÿง‘โ€๐Ÿ’ป CLI client for zer0bin

Tree-based TUI chat client
Tree-based TUI chat client

cove Cove is a TUI client for euphoria.io, a threaded real-time chat platform. It runs on Linux, Windows and macOS. Manual installation This section c

Crunch is a command-line interface (CLI) to claim staking rewards  every X hours for Substrate-based chains
Crunch is a command-line interface (CLI) to claim staking rewards every X hours for Substrate-based chains

crunch ยท crunch is a command-line interface (CLI) to claim staking rewards every X hours for Substrate-based chains. Why use crunch To automate payout

A cli based pastebin in Rust, but very insecure

pasta A cli based pastebin in Rust, but very insecure Use nightly toolchain to build rustup override set nightly When this program is running, you can

Comments
  • Add an HTTP client

    Add an HTTP client

    Description

    This PR adds a very basic HTTP client which allows us to make requests to an actual local Ambi server.

    The URL is hardcoded at the moment as http://localhost:4000/api/readings/add which is the default endpoint for adding readings when running Ambi locally.

    I also updated the usage notes in the README

    it works

    ambi_mock_client

    [email protected] ambi_mock_client % ./target/debug/ambi_mock_client
    Sending POST request to http://localhost:4000/api/readings/add as JSON: {"tempurature":"28.8","humidity":"85.2","pressure":"964","dust_concentration":"930","air_purity":"DANGEROUS"}
    Response: Ok(
        Response {
            url: Url {
                scheme: "http",
                cannot_be_a_base: false,
                username: "",
                password: None,
                host: Some(
                    Domain(
                        "localhost",
                    ),
                ),
                port: Some(
                    4000,
                ),
                path: "/api/readings/add",
                query: None,
                fragment: None,
            },
            status: 200,
            headers: {
                "cache-control": "max-age=0, private, must-revalidate",
                "content-length": "60",
                "content-type": "application/json; charset=utf-8",
                "date": "Sat, 22 Jan 2022 19:28:08 GMT",
                "server": "Cowboy",
                "x-request-id": "FsyuX1U1NOj9m7IAAABB",
            },
        },
    )
    

    Ambi

    [info] POST /api/readings/add
    Verb: "POST"
    Host: "localhost"
    Headers: [{"accept", "*/*"}, {"content-length", "109"}, {"host", "localhost:4000"}]
    
    [debug] Processing with AmbiWeb.ApiController.add_reading/2
      Parameters: %{}
      Pipelines: [:api]
    [debug] Added new reading to the DB
    [info] Sent 200 in 1ms
    

    Testing

    I decided to not write tests for this step in the MVP

    Two options I considered were:

    • Finding library to provide some sort of mock that I could send requests to in tests.
      • This seemed like overkill a bit for a CLI at this stage
    • Use dependency injection and define a test Client
      • It would be really cool if reqwest provided a trait for Client that we could use to create a test client. For the moment this felt like overkill as well. Also, since we can assume the functions being used that are provided by reqwest are themselves tested within that crate maybe it does not make sense to re-test them here. We would essentially be writing a test for the main function.
    opened by calebbourg 2
Owner
Jim Hodapp
Software Engineering Coach (you can work with me!) and programmer for life.
Jim Hodapp
An feature packed Google Tasks CLI written purely in Rust

rChore A feature packed unofficial Google Tasks CLI to boost your producitvity, written purely in Rust. ?? What is rChore? rChore is an unofficial Goo

Hemanth Krishna 39 Nov 22, 2022
Humidity & Temperature CLI datalogger for DHT22 sensor on Raspberry Pi.

Datalogger Humidity & Temperature CLI datalogger for DHT22 sensor on Raspberry Pi. Index Install Git Cargo Master branch Latest release from crates.io

Marco Radocchia 2 Aug 2, 2022
Simple system monitoring app that runs on terminal. Made purely with Rust.

What is it? RCTOP is a simple WIP system monitoring app that runs purely on terminal and doesn't feature GUI. One can compare it to htop, but more str

Niko Huuskonen 7 Oct 14, 2022
Multiple precision floating point numbers implemented purely in Rust.

Multiple precision floating point numbers implemented purely in Rust. Rationale There are several notable implementations of numbers with increased pr

null 11 Nov 23, 2022
Simple but convenient CLI-based Matrix client app for sending and receiving (in Rust)

matrix-commander-rs simple but convenient CLI-based Matrix client app for sending and receiving Help create this Rust program! This project is current

null 7 Nov 24, 2022
cli application to visualize crate download metrics.

cli application to visualize crate download metrics.

Orhan Balci 1 Jan 28, 2022
CLI application to run clang-format on a set of files specified using globs in a JSON configuration file.

run_clang_format CLI application for running clang-format for an existing .clang-format file on a set of files, specified using globs in a .json confi

martin 5 Nov 7, 2022
laydown is a simple CLI application to help you prepare for your next Daily Standup

laydown is a simple CLI application to help you prepare for your next Daily Standup. No longer shall your name be called on only for you to stare into the abyss while you struggle to remember what you did yesterday.

badjr13 82 Nov 28, 2022
gfold is a CLI-driven application that helps you keep track of multiple Git repositories.

gfold is a CLI-driven application that helps you keep track of multiple Git repositories.

Nick Gerace 200 Nov 26, 2022
CLI application to run clang-tidy on a set of files specified using globs in a JSON configuration file.

run-clang-tidy CLI application for running clang-tidy for an existing .clang-tidy file on a set of files, specified using globs in a .json configurati

martin 7 Nov 4, 2022