Monitor your cryptocurrency mining on Ethermine, Flexpool and 2miners!

The template sensor for me isn’t working at least not with the current code i have:

sensor:
  - platform: ethermineinfo
    miner_address: "walletaddress"
    currency_name: USD
    name_override: "Wallet"
  - platform: template
    sensors:
    average_hashrate_24h:
    value_template: "{{ (state_attr('sensor.ethermineinfo_wallet','average_hashrate_24h') | float(default = 0)/1000000)| round(2)}}"
  - platform: template
    sensors:
    current_hashrate:
    value_template: "{{ (state_attr('sensor.ethermineinfo_wallet','current_hashrate')| float(default = 0)/1000000)| round(2)}}"
  - platform: template
    sensors:
    reported_hashrate:
    value_template: "{{ (state_attr('sensor.ethermineinfo_wallet','reported_hashrate')| float(default = 0)/1000000)| round(2)}}"
  - platform: template
    sensors:
    unpaid_in_local_currency:
    friendly_name: "unpaid"
    value_template: "{{ (state_attr('sensor.ethermineinfo_wallet','unpaid_in_local_currency'))}}"
  - platform: template
    sensors:
    paid_on:
    friendly_name: "paid"
    value_template: "{{ (state_attr('sensor.ethermineinfo_wallet','paid_on'))}}"

It gives me the following error


                    Invalid config for [sensor.template]: expected dictionary for dictionary value @ data['sensors']. Got None
extra keys not allowed @ data['average_hashrate_24h']. Got None
extra keys not allowed @ data['value_template']. Got "{{ (state_attr('sensor.ethermineinfo_wallet','average_hashrate_24h') | float(default = 0)/1000000)| round(2)}}". (See ?, line ?). 
Invalid config for [sensor.template]: expected dictionary for dictionary value @ data['sensors']. Got None
extra keys not allowed @ data['current_hashrate']. Got None
extra keys not allowed @ data['value_template']. Got "{{ (state_attr('sensor.ethermineinfo_wallet','current_hashrate')| float(default = 0)/1000000)| round(2)}}". (See ?, line ?). 
Invalid config for [sensor.template]: expected dictionary for dictionary value @ data['sensors']. Got None
extra keys not allowed @ data['reported_hashrate']. Got None
extra keys not allowed @ data['value_template']. Got "{{ (state_attr('sensor.ethermineinfo_wallet','reported_hashrate')| float(default = 0)/1000000)| round(2)}}". (See ?, line ?). 
Invalid config for [sensor.template]: expected dictionary for dictionary value @ data['sensors']. Got None
extra keys not allowed @ data['friendly_name']. Got 'unpaid'
extra keys not allowed @ data['unpaid_in_local_currency']. Got None
extra keys not allowed @ data['value_template']. Got "{{ (state_attr('sensor.ethermineinfo_wallet','unpaid_in_local_currency'))}}". (See ?, line ?). 
Invalid config for [sensor.template]: expected dictionary for dictionary value @ data['sensors']. Got None
extra keys not allowed @ data['friendly_name']. Got 'paid'
extra keys not allowed @ data['paid_on']. Got None
extra keys not allowed @ data['value_template']. Got "{{ (state_attr('sensor.ethermineinfo_wallet','paid_on'))}}". (See ?, line ?). 
                  

Your formatting is off.

sensor:
  - platform: template
    sensors:
      stale_shares:
        friendly_name: "Stale shares"
        value_template: "{{ states.sensor.ethermineinfo_miner_address.attributes['stale_shares'] }}"
      current_hashrate:
        friendly_name: "Current hash rate"
        value_template: "{{ states.sensor.ethermineinfo_miner_address.attributes['current_hashrate'] }}"
        unit_of_measurement: "MH/s"
1 Like

For anybody who wants to have the template:

  - platform: template
    sensors:
      stale_shares:
        friendly_name: "Stale shares"
        value_template: "{{ states.sensor.ethermineinfo_wallet.attributes['stale_shares'] }}"
      current_hashrate:
        friendly_name: "Current hash rate"
        value_template: "{{ (states.sensor.ethermineinfo_wallet.attributes['current_hashrate'] | float(default = 0)/1000000)| round(2)}}"
        unit_of_measurement: "MH/s"
      reported_hashrate:
        friendly_name: "Reported hashrate"
        value_template: "{{ (states.sensor.ethermineinfo_wallet.attributes['reported_hashrate'] | float(default = 0)/1000000)| round(2)}}"
        unit_of_measurement: "MH/s"
      unpaid_in_local_currency:
        friendly_name: "Unpaid in USD"
        value_template: "{{ states.sensor.ethermineinfo_wallet.attributes['unpaid_in_local_currency'] }}"
      paid_on:
        friendly_name: "Last Paid On"
        value_template: "{{ states.sensor.ethermineinfo_wallet.attributes['paid_on'] }}"
2 Likes

Hello @thomasprior,

I’m trying 2Miners integration but when i want to do the same exercise as i made with ethermine I’ve got config errors.

  - platform: template
    sensors:
      rvn_current:
        friendly_name: "Current Hashrate 2Miners RVN"
        value_template: "{{ states.sensor.2minersinfo_rvn_binance_wallet.attributes['current_hashrate_mh_sec'] }}"
        unit_of_measurement: "RVN"
      rvn_unpaid:
        friendly_name: "Unpaid RVN"
        value_template: "{{ (states.sensor.2minersinfo_rvn_binance_wallet.attributes['unpaid'] /100000000 )|round(2)}}"
        unit_of_measurement: "RVN"
      rvn_eur_value:
        value_template: "{{ (states.sensor.2minersinfo_rvn_binance_wallet.attributes['single_coin_in_local_currency']) }}"
        unit_of_measurement: "EUR"
      rvn_unpaid_eur:
        friendly_name: "Unpaid EUR 2Miners RVN"
        value_template: "{{
            (((
            (states.sensor.2minersinfo_rvn_binance_wallet.attributes['unpaid'])
            / (states.sensor.2minersinfo_rvn_binance_wallet.attributes['single_coin_in_local_currency'])
            ))|round(2)
            )/100000000
        }}"
        unit_of_measurement: "EUR"

In Home Assistant File editor it appears ok and when I do a check configuration :

Invalid config for [sensor.template]: invalid template (TemplateSyntaxError: expected token ')', got 'minersinfo_rvn_binance_wallet') for dictionary value @ data['sensors']['rvn_eur_value']['value_template']. Got "{{ (states.sensor.2minersinfo_rvn_binance_wallet.attributes['single_coin_in_local_currency']) }}"
invalid template (TemplateSyntaxError: expected token ')', got 'minersinfo_rvn_binance_wallet') for dictionary value @ data['sensors']['rvn_unpaid']['value_template']. Got "{{ (states.sensor.2minersinfo_rvn_binance_wallet.attributes['unpaid'] /100000000 )|round(2)}}"
invalid template (TemplateSyntaxError: expected token ')', got 'minersinfo_rvn_binance_wallet') for dictionary value @ data['sensors']['rvn_unpaid_eur']['value_template']. Got "{{ ((( (states.sensor.2minersinfo_rvn_binance_wallet.attributes['unpaid']) / (states.sensor.2minersinfo_rvn_binance_wallet.attributes['single_coin_in_local_currency']) ))|round(2) )/100000000 }}"
invalid template (TemplateSyntaxError: expected token 'end of print statement', got 'minersinfo_rvn_binance_wallet') for dictionary value @ data['sensors']['rvn_current']['value_template']. Got "{{ states.sensor.2minersinfo_rvn_binance_wallet.attributes['current_hashrate_mh_sec'] }}". (See ?, line ?).

What appears to be odd is the “got ‘minersinfo_rvn_binance_wallet’” where have gone the 2 from 2miners…

Thanks for you help

As I understand it, this is an issue with the template, not the component (unless you count naming the component 2minersInfo, in which case it is) :wink:

Jinja/HomeAssistant is interpreting the name in the sensor instead of simply reading it as a whole. Try another method to expose attributes as sensors, this worked for me just now:

state_attr('sensor.wallet_id', 'unpaid')

The ' marks force homeassistant to read the name of the sensor as it is written, instead of trying to interpret the name, and that’s where things are getting messy.

If this works, pleas let me know and I’ll update the documentation.

1 Like

This worked for me too !!

You can update the documentation.

I will try to make something similar to this Topic in order to replace what was done with ETH in ethermine but with 2miners, I’ll try to have a look to Flexpool also but since I’m mining on 2Miners… :slight_smile:

1 Like

Hello, delighted Thomas, I’m trying to modify your code base to be able to implement firo in 2miners. Change the api address from zxc to firo.2miners. since it was outdated and an infinite number of things. But I can’t get it to work. Could you help me get firo working at 2miners.com Thank you very much. PS any advice would also help me :slight_smile:

Show me your progress in a PR and I’ll do what I can to help.

I changed the api to the new firo one. but I’m stuck it doesn’t return information. I’m very new, sorry for the inconvenience. https://github.com/alavadomanuel/2miners--firo-mod/blob/67935a1ed87a210c665e261d4f155bfa9a0f502a/2minersInfo-firo.rar