Skip to content

Commit d3ddb2d

Browse files
authored
Merge pull request #57 from th3cube/alltimehigh_attr
add all time high price, date and change
2 parents 4a5e303 + a36fa08 commit d3ddb2d

File tree

3 files changed

+15
-0
lines changed

3 files changed

+15
-0
lines changed

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,9 @@ The entities have some important attributes:
7171
- market_cap This will return the total market cap of the 'cryptocurrency_id'(default = "bitcoin") displayed in 'currency_name'(default = "usd")
7272
- circulating_supply This will return the circulating supply of the 'cryptocurrency_id'(default = "bitcoin")
7373
- total_supply This will return the total supply of the 'cryptocurrency_id'(default = "bitcoin")
74+
- ath_price This will return the All Time High Price of the ''currency_name'(default = "usd") of the 'cryptocurrency_id'(default = "bitcoin")'
75+
- ath_date This will return the date when the All Time High was reached of the ''currency_name'(default = "usd") of the 'cryptocurrency_id'(default = "bitcoin")'
76+
- ath_change This will return the percentage change from the All Time High of the ''currency_name'(default = "usd") of the 'cryptocurrency_id'(default = "bitcoin")'
7477
```
7578

7679
Template example for usage of attributes.

custom_components/cryptoinfo/const/const.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@
2828
ATTR_MARKET_CAP = "market_cap"
2929
ATTR_CIRCULATING_SUPPLY = "circulating_supply"
3030
ATTR_TOTAL_SUPPLY = "total_supply"
31+
ATTR_ATH = "ath"
32+
ATTR_ATH_DATE = "ath_date"
33+
ATTR_ATH_CHANGE = "ath_change"
3134

3235
API_ENDPOINT = "https://api.coingecko.com/api/v3/"
3336

custom_components/cryptoinfo/sensor.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,9 @@
3737
ATTR_MARKET_CAP,
3838
ATTR_MULTIPLIER,
3939
ATTR_TOTAL_SUPPLY,
40+
ATTR_ATH,
41+
ATTR_ATH_DATE,
42+
ATTR_ATH_CHANGE,
4043
CONF_CRYPTOCURRENCY_IDS,
4144
CONF_CURRENCY_NAME,
4245
CONF_ID,
@@ -320,6 +323,9 @@ def extra_state_attributes(self):
320323
ATTR_MARKET_CAP: None,
321324
ATTR_CIRCULATING_SUPPLY: None,
322325
ATTR_TOTAL_SUPPLY: None,
326+
ATTR_ATH: None,
327+
ATTR_ATH_DATE: None,
328+
ATTR_ATH_CHANGE: None,
323329
}
324330

325331
data = self.coordinator.data[self.cryptocurrency_id]
@@ -341,6 +347,9 @@ def extra_state_attributes(self):
341347
ATTR_MARKET_CAP: data["market_cap"],
342348
ATTR_CIRCULATING_SUPPLY: data["circulating_supply"],
343349
ATTR_TOTAL_SUPPLY: data["total_supply"],
350+
ATTR_ATH: data.get("ath"),
351+
ATTR_ATH_DATE: data.get("ath_date"),
352+
ATTR_ATH_CHANGE: data.get("ath_change_percentage"),
344353
}
345354

346355
async def async_will_remove_from_hass(self) -> None:

0 commit comments

Comments
 (0)