Code Monkey home page Code Monkey logo

cipo's Introduction

Cipo

MIT License Crates.io Cargo Build & Test Copr build status

Crypto in, power out

Cipo makes it easy to let users pay for electricity for their camper-van, electric cars, boat, caravan and other high load cases.

Cipo currently supports the Shelly Pro 4PM relay and probably other Shelly relays supporting the same API.

Monero is the only platform for payment at the moment, other crypto currencies might be supported in the future.

The only user interface for end users are a QR-code per socket/outlet. This makes it possible to pay with the wallet they already have, but makes it hard to provide feedback to the end user. In the future it might be possible to add a screen or provide a QR-code with a webpage for status and notifications.

Config

The devices and price per watt hour is declared in the config file config.toml. You need to restart the program for it to read in changes.

As long as Cipo is versioned as 0.X, then the config format can change without an upgrade path.

Example file

[price]
xmr-per-kwh = 0.00129556

[monero-rpc]
host = 'localhost'
port = 18083

[[device]]
location = 'Camping#1'
host = '10.40.4.96'
switch = 3
monero = '46vp22XJf4CWcAdhXrWTW3AbgWbjairqd2pHE3Z5tMzrfq8szv1Dt7g1Pw7qj4gE87gJDJopNno6tDRcGDn8zUNg72h7eQt'

[[device]]
location = 'Camping#2'
host = '10.40.4.96'
switch = 2
monero = '84aGHMyaHbRg1rcZ9mCByuEMkAMorEqe4UCK3GFgcgTkHxQ1kJEJq6pBbHgdX1wRsRhJaZ2vbrxdoFTR7JNw7m7kMj6C1sm'

How to calculate the exchange rate?

This program does not support downloading the price of Monero nor the cost of electricity.

It is recommended to calculate a new price when the price of Monero or electricity changes enough.

For Norway this could be done like this:

  • 1 XMR = 230 USD
  • 1 USD = 8,83 NOK
  • 1 kWh = 1000 Wh = 2.63 NOK

TODO: Make formula

When is the exchange rate calculated?

For long term usage, the rate is calculated/bought at the time of payment.

When the program receive the payment it will register that the txid have been credited amount of Wh.

If you change the rate after the payment have been accepted by the program, then the program will use the old change rate.

State dir

As long as Cipo is versioned as 0.X, then the state format can change without an upgrade path.

The changes are written to files append-only log-file style, each transaction have their own file.

These files can be used for debugging and are used by the program on startup.

Folder structure

<journal-dir>/<receiving-address>/<txid>.log

File/log structure

<timestamp> <remaining-watt-hours>

Example

2022-04-18T18:23:15Z +3.04
2022-04-18T18:23:25Z +0.31
2022-04-18T18:23:35Z -0.04

License

This project is MIT licensed. For the full license, see LICENSE.

cipo's People

Contributors

hegjon avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.