How To: Ethereum Mining Dashboard. HiveOS, Ethermine pool, Crypto Prices and DB Historical data statistics

Check part 4 in OP.

Isn’t this what you want?

sensor:
  - platform: sql
    db_url: !secret hassioslave_db_link  ###can be omitted if using default recorder settings
    queries:
#....
      - name: eth_mined_total_history_24h
        query: SELECT * FROM states WHERE entity_id = 'sensor.eth_mined_total' AND created < DATE_ADD(NOW(), INTERVAL -3-24 HOUR) ORDER BY state_id DESC LIMIT 1;
        column: 'state'
        unit_of_measurement: "ETH"

I saw that but I don’t have a separate database that holds the history from Home Assistant. I’m sorry if that doesn’t make sense. New to this! Would I need to set up a separate database to push the information to?

No, i think you can do it with the default database, by removing this line:

db_url: !secret hassioslave_db_link ###can be omitted if using default recorder settings

So it should be somewhat like this:

sensor:
  - platform: sql
    queries:
    ...

I have not tested it, but it should work according to the documentation.
Give it a try and let us know.

Hi @krash, that didn’t seem to work. I did as you stated and removed the db_url completely but I get unknown for the total history.

Note: I’m using the unpaid sensor because I haven’t cashed out yet.

 - platform: sql
    queries:
      - name: eth_mined_total_history_1h
        query: SELECT * FROM states WHERE entity_id = 'sensor.eth_unpaid' AND created < DATE_ADD(NOW(), INTERVAL -3-1 HOUR) ORDER BY state_id DESC LIMIT 1;
        column: 'state'
        unit_of_measurement: "ETH"
      - name: eth_mined_total_history_6h
        query: SELECT * FROM states WHERE entity_id = 'sensor.eth_unpaid' AND created < DATE_ADD(NOW(), INTERVAL -3-6 HOUR) ORDER BY state_id DESC LIMIT 1;
        column: 'state'
        unit_of_measurement: "ETH"
      - name: eth_mined_total_history_12h
        query: SELECT * FROM states WHERE entity_id = 'sensor.eth_unpaid' AND created < DATE_ADD(NOW(), INTERVAL -3-12 HOUR) ORDER BY state_id DESC LIMIT 1;
        column: 'state'
        unit_of_measurement: "ETH"
      - name: eth_mined_total_history_24h
        query: SELECT * FROM states WHERE entity_id = 'sensor.eth_unpaid' AND created < DATE_ADD(NOW(), INTERVAL -3-24 HOUR) ORDER BY state_id DESC LIMIT 1;
        column: 'state'
        unit_of_measurement: "ETH"

@krash How do you solve hiveos2mqtt.sh, that stops sending information after some time?

I did not use the original script as explained in the link.
I created a cron job that runs it every 60 sec as explained above.
It’s been working for weeks now.

Hi Paulo, I have the same problem, I have two gpus 0 and I cannot split the results, could you solve this concern?

statsminer

what I need is to create a template to be able to separate those results, do you think it is possible? I couldn’t do it.

THX

@gabriel600r

I split it like Harry. My code is:

# HiveOS Sensor
  - platform: mqtt
    name: hiveos_stats
    state_topic: "hiveos"
    value_template: "{{ value_json.params.miner_stats.uptime }}"
    json_attributes_topic: "hiveos"
    json_attributes_template: "{{ value_json.params.miner_stats | to_json }}"
  - platform: mqtt
    name: hiveos_params
    state_topic: "hiveos"
    value_template: "{{ value_json.params.miner_stats.uptime }}"
    json_attributes_topic: "hiveos"
    json_attributes_template: "{{ value_json.params | to_json }}"

# Sensor - Template
  - platform: template
    sensors:

# GPU 0
      gpu_0_index:
        value_template: '0'
        friendly_name_template: "{{states.sensor.gpu_0_name.state}} Index"
      gpu_0_name:
        value_template: "RTX 3080 X Trio"
      gpu_0_hash:
        value_template: "{{ ((states.sensor.hiveos_stats.attributes['hs'][states.sensor.gpu_0_index.state|int])/1000000)|round(1) }}"
        friendly_name_template: "{{states.sensor.gpu_0_name.state}} Hashrate"
        unit_of_measurement: "MH/s"
      gpu_0_core:
        value_template: "{{ (states.sensor.hiveos_params.attributes['temp'][states.sensor.gpu_0_index.state|int]) }}"
        friendly_name_template: "{{states.sensor.gpu_0_name.state}} Temperatura"
        unit_of_measurement: "°C"
      gpu_0_fan:
        value_template: "{{ (states.sensor.hiveos_params.attributes['fan'][states.sensor.gpu_0_index.state|int]) }}"
        friendly_name_template: "{{states.sensor.gpu_0_name.state}} Velocidade"
        unit_of_measurement: "%"
      gpu_0_pwr:
        value_template: "{{ (states.sensor.hiveos_params.attributes['power'][states.sensor.gpu_0_index.state|int]) }}"
        friendly_name_template: "{{states.sensor.gpu_0_name.state}} Consumo"
        unit_of_measurement: "W"
      gpu_0_ef:
        friendly_name_template: "{{states.sensor.gpu_0_name.state}} Eficiência"
        value_template: '{{ ((states.sensor.gpu_0_hash.state|float)/(states.sensor.gpu_0_pwr.state|float))|round(3) }}'
        unit_of_measurement: "MHs/W"



# GPU 1
      gpu_1_index:
        value_template: '1'
        friendly_name_template: "{{states.sensor.gpu_1_name.state}} Index"
      gpu_1_name:
        value_template: "RTX 3080 Suprim X"
      gpu_1_hash:
        value_template: "{{ ((states.sensor.hiveos_stats.attributes['hs'][states.sensor.gpu_1_index.state|int])/1000000)|round(1) }}"
        friendly_name_template: "{{states.sensor.gpu_1_name.state}} Hashrate"
        unit_of_measurement: "MH/s"
      gpu_1_core:
        value_template: "{{ (states.sensor.hiveos_params.attributes['temp'][states.sensor.gpu_1_index.state|int]) }}"
        friendly_name_template: "{{states.sensor.gpu_1_name.state}} Temperatura"
        unit_of_measurement: "°C"
      gpu_1_fan:
        value_template: "{{ (states.sensor.hiveos_params.attributes['fan'][states.sensor.gpu_1_index.state|int]) }}"
        friendly_name_template: "{{states.sensor.gpu_1_name.state}} Velocidade"
        unit_of_measurement: "%"
      gpu_1_pwr:
        value_template: "{{ (states.sensor.hiveos_params.attributes['power'][states.sensor.gpu_1_index.state|int]) }}"
        friendly_name_template: "{{states.sensor.gpu_1_name.state}} Consumo"
        unit_of_measurement: "W"
      gpu_1_ef:
        friendly_name_template: "{{states.sensor.gpu_1_name.state}} Eficiência"
        value_template: '{{ ((states.sensor.gpu_1_hash.state|float)/(states.sensor.gpu_1_pwr.state|float))|round(3) }}'
        unit_of_measurement: "MHs/W"

1 Like

Thanks Paulo for your answer, my problem is that I have two GPUS_0. one Nvdia and another ATI. and the TEMP result gives me two values. What I don’t know is how to separate that result.

Hiveos reports 2X gpu0?
Are u sure?

Hello good morning, when you have ATI and NVIDIA takes them as GPU0.
Here I attach a screenshot of the HiveOS.

two gpus 0

I was also able to solve my problem by creating some templates, I leave them in case someone else happens.
These templates are created thanks to the information provided in this post.

{% set t = (states.sensor.hiveos_params.attributes['miner_stats2']['temp'][0]) | float %}
{% set u = (states.sensor.hiveos_params.attributes['miner_stats']['temp'][0]) | float %}
{{ ((t + u)) }}

{% set t = (states.sensor.hiveos_params.attributes['total_khs']) | float %}
{% set u = (states.sensor.hiveos_params.attributes['total_khs2']) | float %}
{{ ((t + u) / 1000) }}

{% set t = (states.sensor.hiveos_params.attributes['miner_stats2']['fan'][0]) | float %}
{% set u = (states.sensor.hiveos_params.attributes['miner_stats']['fan'][0]) | float %}
{{ ((t + u)) }}

Basically what I do I take the values and add them to have a unique reference value.
sorry for my bad english.

Strange, I too have duplicate numbers in the hiveos ui but they are numbered uniquely when reading the logs in HA.

Hey Harry,

I’ve been trying to run monitoring on my rig using your (nice!) guide, but I ran into some issues:

  1. I’ve installed the linux script with modifications, add it to cron, and in mosquitto broker I got:
1628416263: New connection from 192.168.XXX.XXX on port 1883.
1628416263: New client connected from 192.168.XXX.XXX as mosqpub|6916-GTX1060 (p1, c1, k60, u'rig').
1628416263: Client mosqpub|6916-GTX1060 disconnected.

in HA I’ve created sensor.yaml included it in configuration.yaml and fill with the code you posted, but when I check in Developer Tools → States I see there is no data in there

and trying to create a template with your example I got:
UndefinedError: ‘mappingproxy object’ has no attribute ‘uptime’

It seems that no data is gathered? Any clues?

Hey,
It feels like there’s some issue in the config, either in the Linux topic, or in the HA’s mqtt sensor configuration.
I would check the code again and if nothing comes up, try connecting to the broker with an mqtt browser (create a new account and with the mqtt client subscribe to # (everything) to see what the Linux machine is broadcasting)
Those two should help you figure out where the data is going.

I followed the instructions and everything works great!!! Awesome! The problem i have is once i add multiple rigs, i cannot get the gpus to display their proper attributes as they all seem to share the same index #s. Ie: Gpu_0 is the same on all three rigs…
How can i fix this?

Hey, to be honest I never thought about it, as I have 1 rig.
Let me think about it a little :slight_smile:

edit:
(ignore my previous answer)
Try appending rig number on the name of the sensors and topics.
You will also need to set a different topic in the hive OS script of each rig hive_mqtt_1, hive_mqtt_2
And probably different MQTT client user names, in case they try to connect simultaneously and get blocked.

example:
Rig 1:

  - platform: mqtt
    name: hiveos_stats_rig1
    state_topic: "hive_mqtt_1"
    value_template: "{{ value_json.params.miner_stats.uptime }}"
    json_attributes_topic: "hive_mqtt_1"
    json_attributes_template: "{{ value_json.params.miner_stats | to_json }}"

  - platform: mqtt
    name: hiveos_params_rig1
    state_topic: "hive_mqtt_1"
    value_template: "{{ value_json.params.miner_stats.uptime }}"
    json_attributes_topic: "hive_mqtt_1"
    json_attributes_template: "{{ value_json.params | to_json }}"

Rig2:

  - platform: mqtt
    name: hiveos_stats_rig2
    state_topic: "hive_mqtt_2"
    value_template: "{{ value_json.params.miner_stats.uptime }}"
    json_attributes_topic: "hive_mqtt_2"
    json_attributes_template: "{{ value_json.params.miner_stats | to_json }}"

  - platform: mqtt
    name: hiveos_params_rig2
    state_topic: "hive_mqtt_2"
    value_template: "{{ value_json.params.miner_stats.uptime }}"
    json_attributes_topic: "hive_mqtt_2"
    json_attributes_template: "{{ value_json.params | to_json }}"

Then you will need to name your GPUs something like rig1_gpu0, rig2_gpu0 and get their data like this:

### rig_1gpu0
      rig_1gpu_0_index:
        value_template: '0'
        friendly_name_template: "{{states.sensor.rig_1gpu_0_name.state}} Index"
     rig_1 gpu_0_name:
        value_template: "1660S-ASUS1"
     rig_1 gpu_0_hash:
        value_template: "{{ (states.sensor.hiveos_stats_rig1.attributes['hs'][states.sensor.rig_1gpu_0_index.state|int])/1000 }}"
        friendly_name_template: "{{states.sensor.rig_1gpu_0_name.state}} Hash"
        unit_of_measurement: "MH/s"

It needs some careful editing, as there’s a lot of code, but i think this is the way.
At least A way, there’s probably a more proper way to get all these stuff but i’m not that experienced :slight_smile:

Hmm, ive been playing around with the way you described… it still wont work… i get a whole slew of errors

Do it step by step, first just create 6 mqtt sensors, two for each machine.
something like this:
example:
Rig 1:

  - platform: mqtt
    name: hiveos_stats_rig1
    state_topic: "hive_mqtt_1"
    value_template: "{{ value_json.params.miner_stats.uptime }}"
    json_attributes_topic: "hive_mqtt_1"
    json_attributes_template: "{{ value_json.params.miner_stats | to_json }}"

  - platform: mqtt
    name: hiveos_params_rig1
    state_topic: "hive_mqtt_1"
    value_template: "{{ value_json.params.miner_stats.uptime }}"
    json_attributes_topic: "hive_mqtt_1"
    json_attributes_template: "{{ value_json.params | to_json }}"

Rig2:

  - platform: mqtt
    name: hiveos_stats_rig2
    state_topic: "hive_mqtt_2"
    value_template: "{{ value_json.params.miner_stats.uptime }}"
    json_attributes_topic: "hive_mqtt_2"
    json_attributes_template: "{{ value_json.params.miner_stats | to_json }}"

  - platform: mqtt
    name: hiveos_params_rig2
    state_topic: "hive_mqtt_2"
    value_template: "{{ value_json.params.miner_stats.uptime }}"
    json_attributes_topic: "hive_mqtt_2"
    json_attributes_template: "{{ value_json.params | to_json }}"

Rig3:

  - platform: mqtt
    name: hiveos_stats_rig3
    state_topic: "hive_mqtt_3"
    value_template: "{{ value_json.params.miner_stats.uptime }}"
    json_attributes_topic: "hive_mqtt_3"
    json_attributes_template: "{{ value_json.params.miner_stats | to_json }}"

  - platform: mqtt
    name: hiveos_params_rig3
    state_topic: "hive_mqtt_3"
    value_template: "{{ value_json.params.miner_stats.uptime }}"
    json_attributes_topic: "hive_mqtt_3"
    json_attributes_template: "{{ value_json.params | to_json }}"

Do not create any template sensors yet.
Do these work?
What error are you getting?

Hello,

I’m stuck at the very beginning.
Installed version 1.0.1 of EthermineInfo on latest releases (up to date as of today)

And looks like the ethermine sensor doesn’t retrieve anything.

I followed your steps but nothing, I’ll try uninstalling reinstalling so I can check if everything is good.

I let you know, but if in the meantime you remember something (port to open, security, …) tell me :slight_smile:

active_workers: null
current_hashrate: null
invalid_shares: null
last_update: null
reported_hashrate: null
stale_shares: null
unpaid: null
valid_shares: null
start_block: null
end_block: null
amount: null
txhash: null
paid_on: null
average_hashrate_24h: null
unconfirmed: null
single_coin_in_local_currency: null
unpaid_in_local_currency: null
coins_per_minute: null
unit_of_measurement: ​
friendly_name: EthermineInfo ETH
icon: mdi:ethereum

Nico

Regarding ethermineInfo, I think you could get better help by asking the author directly, through the forums (I have his name mentioned in the beginning of the post) , or through github (link there too)