I am trying to use multiscrape to load a table of data into the attributes of a sensor â one attribute would be a list of times, the other a list of corresponding forecast temperatures â so that I can then create a plot of these forecasts in lovelace using ApexCharts. Ideally I would get a sensor which looks a little like this:
but multiscrape only takes the first item. Iâve tried using some sort of list or .split() filters, but this just filters the first item and not the others.
Is it possible to do some sort of iteration/split the selected row of table data into a list of some sort, without defining a separate attribute for each data point in the forecast?
@danieldotnl has very kindly introduced a new feature in multiscrape 5.2, select_list to deal with use cases such as scraping a data table into a sensor. Here is my example config to scrape the next 24h of weather forecast from my local provider:
- name: in-poÄasi Praha
resource: "https://www.in-pocasi.cz/predpoved-pocasi/cz/praha/praha-324/"
scan_interval: 300
sensor:
- unique_id: inpo_praha_temperature
name: In-PoÄasi Temperature Now
select: ".alfa"
value_template: "{{(value|trim)[:-2]|float}}"
unit_of_measurement: °C
attributes:
- name: "Forecast Time"
select_list: ".day-hour-ext.flex-column .day-hour-time"
value_template: |
{%-set value = value.split(",")-%}
{%for x in value%}
- {{x}}
{%-endfor-%}
- name: "Forecast Temperature"
select_list: ".day-hour-ext .h-100 .font-weight-bold"
value_template: |
{%-set value = value.split(",")-%}
{%for x in value%}
- {{x[0:-2]|float}}
{%-endfor-%}
Looks like values are injected by javascript⊠Network monitor shows some promising json responses though. If they contain the data you are looking for, you could retrieve it with the rest sensor.
Hi @danieldotnl, Iâm try to add my (scraped) Solar values into the new Energy Monitor.
There are a few requirements for that and one of them is the last_reset parameter.
- name: Energy Solar Total
device_class: energy
state_class: measurement
last_reset: '1970-01-01T00:00:00+00:00'
unit_of_measurement: "kWh"
icon: "mdi:solar-panel"
select: "#param_link_15684226"
value_template: "{{value.split(' ')[0] | replace(',', '.')}}"
Configuration invalid
Invalid config for [multiscrape]: [last_reset] is an invalid option for [multiscrape]. Check: multiscrape->multiscrape->0->sensor->6->last_reset. (See /config/configuration.yaml, line 55).
However, the last_reset parameter isnât a valid option for Multiscrape sensor (yet).
Is it perhaps possible to add this parameter for the Multiscrape Component?
It would be very helpful.
Pre-release v5.4.0 supports fixed values for sensors/attributes by using the value_template and omitting a select. So you can add the last_reset attribute like this:
Iâm trying to scrape from this site https://covidlive.com.au to look at the New Cases in the Last 24 hours, but no matter which way I try, I get an invalid response from the integration.
Looks like something has broken since the core September updates: my sensors, which were working perfectly until the end of August, now all have the value âunknownâ.
What is weird is that, in the debug log, the multiscrape integration happily shows the right values. For instance: