I am trying to extract values for sensors from this site:
I have so far been playing with this:
- platform: rest
name: MSI
resource: https://api.minerstat.com/v2/stats/SENSURED/hauglandmsi
scan_interval: 30
timeout: 60
force_update: true
verify_ssl: false
value_template: 'OK'
json_attributes:
- hashrate
- uptime
- accepted_share
- rejected_share
- temp
- power
- usd_day
- usd_week
- usd_month
- platform: template
sensors:
msi_hashrate:
value_template: '{{ state_attr(''sensor.msi'', ''hashrate'') }}'
unit_of_measurement: 'MH/s'
msi_accepted_shares:
value_template: '{{ state_attr(''sensor.msi'', ''accepted_share'') }}'
unit_of_measurement: 'shares'
msi_rejected_shares:
value_template: '{{ state_attr(''sensor.msi'', ''rejected_share'') }}'
unit_of_measurement: 'shares'
msi_power:
value_template: '{{ state_attr(''sensor.msi'',''power'')[0][''power''] }}'
unit_of_measurement: 'W'
msi_temperature:
value_template: '{{ state_attr(''sensor.msi'', ''temp'')[0][''temperature'']|round(1) }}'
msi_uptime:
value_template: >-
{%- set uptime = state_attr('sensor.msi', 'uptime') | round -%}
{%- set sep = ':' -%}
{%- set space = ' - ' -%}
{%- set TIME_MAP = {
'week': (uptime / 604800) % 604800,
'day': (uptime / 86400) % 7,
'hour': (uptime / 3600) % 24,
'minute': (uptime / 60) % 60,
'second': (uptime % 60)
}
-%}
{%- for unit, duration in TIME_MAP.items() if duration >= 1 -%}
{%- if unit == 'week' -%}
{{ (duration | string).split('.')[0] }} {{ unit }}
{%- if duration >= 2 -%}
s
{%- endif -%}
{{ space }}
{%- endif -%}
{%- if unit == 'day' -%}
{{ (duration | string).split('.')[0] }} {{ unit }}
{%- if duration >= 2 -%}
s
{%- endif -%}
{{ space }}
{%- endif -%}
{%- if unit == 'hour' -%}
{%- if duration <= 10 -%}
{{ '0' }}{{ (duration | string).split('.')[0] }}{{ sep }}
{%- endif -%}
{%- if duration >= 10 -%}
{{ (duration | string).split('.')[0] }}{{ sep }}
{%- endif -%}
{%- endif -%}
{%- if unit == 'minute' -%}
{%- if duration <= 10 -%}
{{ '0' }}{{ (duration | string).split('.')[0] }}{{ sep }}
{%- endif -%}
{%- if duration >= 10 -%}
{{ (duration | string).split('.')[0] }}{{ sep }}
{%- endif -%}
{%- endif -%}
{%- if unit == 'second' -%}
{%- if duration <= 10 -%}
{{ '0' }}{{ (duration | string).split('.')[0] }}
{%- endif -%}
{%- if duration >= 10 -%}
{{ (duration | string).split('.')[0] }}
{%- endif -%}
{%- endif -%}
Which only results in either unknown or unavailable status from my created sensors.
Can anyone point me in the right direction?