Skip to content

Commit

Permalink
Merge pull request #29 from BigNocciolino/dev
Browse files Browse the repository at this point in the history
Merge new documentation
  • Loading branch information
BigNocciolino authored Mar 15, 2022
2 parents cf80b68 + cfb3237 commit ce68fdc
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 20 deletions.
38 changes: 28 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

Component for tracking data generated by the API created by [fawazahmed0](https://github.com/fawazahmed0/currency-api). Which provides updated data every 24 hours, with a coverage of 150+ cryptocurrencies.

**Note:** For those who have the component already configured from the config file, it will no longer work. Now it can only be configured from UI
**Note:** For those who have the component already configured from the config file, it will no longer work. Now it can only be configured from UI. [See this section](#moving-from-the-config-file)

## Features

Expand All @@ -14,28 +14,46 @@ Component for tracking data generated by the API created by [fawazahmed0](https:

## Installation

The component is available in the hacs store, you only need to search it and after you can configure it from IU.
This integration is distributed using [HACS](https://hacs.xyz/)

Go to `Configuration` => `Devices & Services` => `+ Add Integration` => `Cryptostate`.
After installing it go to `Configuration` => `Devices & Services` => `+ Add Integration` and search for `Cryptostate`.

**Note:** To add multiple sensors you need to repeat the previous instructions.
**Note:** To add multiple sensors you need add multiple instaces of the sensor.

## Setup
## Setup

Now the component can be configured from the graphical interface, setting the value of `crypto` and the value of `base` (i.e. the value with which we want to convert crypto)

### My configuration
To get a full list of available currencies visit this [page](https://cdn.jsdelivr.net/gh/fawazahmed0/currency-api@1/latest/currencies.json).

### My configuration

Sience the api update itself every day i suggest to use the built in `Statistic graph` card.
Sience the api update itself every day i suggest to use the built in [Statistic graph](https://www.home-assistant.io/lovelace/statistics-graph/) card.

**Example:**

![Example](https://github.com/PepegaBruh/CryptoTracker/blob/main/images/long_term_example.png?raw=true)

## Information
## Moving from the config file

To get a full list of available currencies visit this [page](https://cdn.jsdelivr.net/gh/fawazahmed0/currency-api@1/latest/currencies.json).
Moving from the config fil to the UI is really simple, first of all you need to look all the `-compare:` options in your sensor configuration in the yaml.

``` yaml
sensor:
- platform: cryptostate
resources:
# This will gi in the (Crypto ticker) - (Base ticker) section UI.
- compare: doge-eur
# This will go in the (Name) section of the UI
name: dogecoin
```
This up here can be an example of configuration, to move this to the UI we need to take the `Crypto ticker`, the `Base ticker` and the `Name`.

- `Crypto ticker` => `doge`
- `Base ticker` => `eur`
- `Name` => `dogecoin`

## Credit
## Credit

- Special thanks to [fawazahmed0](https://github.com/fawazahmed0/currency-api), consider to star his project
4 changes: 1 addition & 3 deletions custom_components/cryptostate/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,7 @@ async def _async_update_data(self):
async def async_unload_entry(hass: HomeAssistant, entry: ConfigEntry) -> bool:
"""Handle removal of an entry."""
# coordinator = hass.data[DOMAIN][entry.entry_id]
unloaded = await asyncio.gather(
[hass.config_entries.async_forward_entry_unload(entry, "sensor")]
)
unloaded = await hass.config_entries.async_unload_platforms(entry, "sensor")
if unloaded:
hass.data[DOMAIN].pop(entry.entry_id)

Expand Down
13 changes: 6 additions & 7 deletions custom_components/cryptostate/config_flow.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
from email.policy import default
from homeassistant import config_entries
"""Config flow for cryptotracker"""
from homeassistant.core import callback
import voluptuous as vol

from homeassistant import config_entries
from homeassistant.helpers.aiohttp_client import async_create_clientsession
from .const import DOMAIN, CONF_BASE, CONF_CRYPTO, DEFAULT_NAME
from .const import DOMAIN, CONF_BASE, CONF_CRYPTO
from homeassistant.const import CONF_NAME
from .api import CryptoTrackerApiClient
import voluptuous as vol


class CryptoTrackerConfigFlow(config_entries.ConfigFlow, domain=DOMAIN):
Expand Down Expand Up @@ -68,6 +67,6 @@ async def _test_credentials(self, crypto, base):
else:
self._errors[CONF_CRYPTO] = "invalid_crypto"
return False
except Exception:
except Exception: # pylint: disable=broad-except
pass
return False
return False

0 comments on commit ce68fdc

Please sign in to comment.