REST Sensor no graphic (K1Pool import to Home Assistant)

Good evening everyone.
I hope I’m in the right place.
I want to create the current information for my K1Pool (Miner) as sensors in HA.

I have managed to do this so far that it pulls the values from K1Pool and outputs them as sensors in HA.
But unfortunately I can’t get it to show me the values as a graphic when I open the sensor. (Like with energy sensors, for example)
Currently I only get them as a timestamp.

Does anyone know how I can correct this?

That would be my yaml:

rest:

  • authentication: basic
    resource_template: https://k1pool.com/api/miner/kaspa/XXXXXXXXX (This is where the wallet address would go)
    method: GET
    scan_interval: 300
    sensor:
    • name: “K1Pool Current Hashrate (30min)”
      value_template: ‘{{ value_json.miner.curHashrateStr}}’
    • name: “K1Pool Average Hashrate (3h)”
      value_template: ‘{{ value_json.miner.avgHashrateStr}}’
    • name: “K1Pool Average 24h Hashrate”
      value_template: ‘{{ value_json.miner.dayHashrateStr }}’
    • name: “K1Pool Total Paid, KAS”
      value_template: ‘{{ value_json.miner.paidBalance }}’
    • name: “K1Pool Pending Balance”
      value_template: ‘{{ value_json.miner.pendingBalance }}’
    • name: “K1Pool Workers Online”
      value_template: ‘{{ value_json.miner.workersOnline }}’
    • name: “K1Pool Coins Per Day, KAS”
      value_template: ‘{{ value_json.miner.coinsPerDay }}’
    • name: “K1Pool BTC Price”
      value_template: ‘{{ value_json.pool.coinPriceBtc }}’
    • name: “K1Pool USD Price (KAS Price)”
      value_template: ‘{{ value_json.pool.coinPriceUsd }}’

If someone would like to use this, it is of course free for everyone :slight_smile:

I have also tried to achieve something with these but when I enter them I only get that it no longer works.
unit_of_measurement: ‘W’
state_class: measurement
device_class: power

(I realize that these are current attributes but I just wanted to get a graph somehow and if it doesn’t give me the values in the correct unit so be it…) but unfortunately it didn’t work either).

I would be very happy if someone could help me here.

Many thanks
Greetings from Switzerland

I think you need a unit of measurement to get a graph.

Yes, and strip the unit of measurement from the data. The data is a string containing numbers and text, you need numbers only for the state, and the unit of measurement must be set in the sensor.

1 Like

Good morning nickrout and Edwin_D

Thank you very much for the quick feedback.
Unfortunately, I don’t quite understand what you two
want to tell me here and what I should add or remove.

Can you add your suggestion to my yaml template?
This would make it easier and better for me to understand what exactly needs to be done and, above all, how exactly it needs to be done.

Thank you very much and have a nice day.
Greetings

I was able to figure it out myself.
If anyone would also like to import their data from K1Pool into Home Assistant, here is the finished “script”:

rest:
  - authentication: basic
    resource_template: https://k1pool.com/api/miner/kaspa/XXXXX (this is where the wallet address from K1Pool comes in)
    method: GET
    scan_interval: 300
    sensor:
      - name: "K1Pool Current Hashrate (30min)"
        unique_id: k1pool_current_hashrate_30min
        value_template: "{{ (value_json.miner.curHashrate | float / 1000000000000) | round(2, 'floor') }}"
        unit_of_measurement: "TH/s"
      - name: "K1Pool Average Hashrate (3h)"
        unique_id: k1pool_average_hashrate_3h
        value_template: "{{ (value_json.miner.avgHashrate | float / 1000000000000) | round(2, 'floor') }}"
        unit_of_measurement: "TH/s"
      - name: "K1Pool Average 24h Hashrate"
        unique_id: k1pool_average_24h_hashrate
        value_template: "{{ (value_json.miner.dayHashrate | float / 1000000000000) | round(2, 'floor') }}"
        unit_of_measurement: "TH/s"
      - name: "K1Pool Total Paid, KAS"
        unique_id: k1pool_total_paid_kas
        value_template: '{{ value_json.miner.paidBalance }}'
        unit_of_measurement: "KAS"
      - name: "K1Pool Pending Balance"
        unique_id: k1pool_pending_balance
        value_template: '{{ value_json.miner.pendingBalance }}'
        unit_of_measurement: "KAS"
      - name: "K1Pool Workers Online"
        unique_id: k1pool_workers_online
        value_template: '{{ value_json.miner.workersOnline }}'
        unit_of_measurement: "Online"
      - name: "K1Pool Coins Per Day, KAS"
        unique_id: k1pool_coins_per_day_kas
        value_template: '{{ value_json.miner.coinsPerDay }}'
        unit_of_measurement: "KAS"
      - name: "K1Pool BTC Price"
        unique_id: k1pool_btc_price
        value_template: '{{ value_json.pool.coinPriceBtc }}'
        unit_of_measurement: "BTC"
      - name: "K1Pool USD Price (KAS Price)"
        unique_id: k1pool_coins_usd_value
        value_template: '{{ value_json.pool.coinPriceUsd }}'
        unit_of_measurement: "$"

Here are two additional sensors that calculate the daily revenue in USD and what you have earned in total.

template:
  - sensors:
      k1pool_coins_usd_value:
        friendly_name: "K1Pool Coins USD Value"
        unique_id: k1pool_coins_usd_value
        unit_of_measurement: "$"
        value_template: "{{ states('sensor.k1pool_coins_per_day_kas') | float * states('sensor.k1pool_usd_price_kas_price') | float | round(2) }}"

  - sensors:
      k1pool_total_coins_usd_value:
        friendly_name: "K1Pool total Coins USD Value"
        unique_id: k1pool_total_coins_usd_value
        unit_of_measurement: "$"
        value_template: "{{ states('sensor.k1pool_total_paid_kas') | float * states('sensor.k1pool_usd_price_kas_price') | float | round(2) }}"

Have fun with it.
Greetings from Switzerland