then you probably did not copy the value correctly as in your example there is a space between the A and .5…
If the A is directly close to the number, replace value_template: '{{value.split(" ")[0] | float}}'
with value_template: '{{value.split("A")[0] | float}}'
If there is indeed what looks like a space but the value template doesn’t work, try to toy with this: value_template: '{{value[:-4] | float}}'
( you may need to adjust the 4)
It works perfectly with the this line:
value_template: ‘{{value[:-4] | float}}’
Thank you so much, I will have to investigat more in this to understand what I have to do if I have to configure another one in the future. Looks a bit complex to me at the morment.
for scrape sensors, best is to look for classes (e.g. <div class="classname">).
Hopefully the value you’re after is after a class and it’s the only class with that name
For the actual value, value[:-4] means remove the last 4 chars from value
Now I have a new challegenge, which seems a bit more complicated: I have tried to use select command, but in this case I have no clue which word I could look for as the word I am trying to use is shown several times. Could you please look at it and come with suggestion. I would need the three yellow marked figures in the screenshot.
The weblink for the site is http://77.119.243.51:86
• Open up developer mode in Chrome (F12)
• Click on Elements
• Expand until you find location you want to get information
• Right click and choose Copy then Copy selector
• Paste into HA sensor under select:
I am trying to create a sensor with my next bus time to integrate into home assistant and this is my first attempt at using the scrape component. I’ve tried a number of ‘selects’ but continue to get Unable to extract data from HTML. What method of testing and debugging could be used to find out where it is failing? The link is below, and the data appears in
div.nextride-pattern__container > div.nextride-pattern__times.data-test-pattern-times-block
I need some help too using the scrape function.
I want to scrape a power value from an internal webinterface my Solis datalogger has. If I get it to work for one value it should be easier for me to figure out the rest.
In the Core log form HA I do receive:
2020-05-09 08:29:47 ERROR (SyncWorker_10) [homeassistant.components.scrape.sensor] Unable to extract data from HTML
The internal HTML interface does use authentication but it’s (I assume) of the basic type. In domotizc I had this scraping working using a php script that used the username:[email protected] and this worked.
For now I dont know if the issue is the authentication part or something wrong in my YML scrape configuration . I’m trying for hours, even days and can’t figure it out? Can someone point me in the right direction?
EDIT:
After I figured out to turn on debug logging:
It seems it reads the page correctly. In the home-assistant.log I do find:
</style>
<script type="text/javascript">
var height=0;function fileText(id,value){if(document.getElementById(id)){document.getElementById(id).innerHTML=value}}function changeFont(){reCon("main_div").style.fontFamily=window.parent.reFont()}function child_getH(){var nh=document.body.offsetHeight+100;if(nh<500||nh==null){nh=500}if(height!=nh){height=nh;window.parent.child_height(height)}}function reCon(id){return document.getElementById(id)}function ready(){try{window.parent.show_ifr()}catch(e){}child_getH()}function show(v){var c=document.getElementById(v);if(c!=null){c.style.display=""}}function hide(v){var c=document.getElementById(v);if(c!=null){c.style.display="none"}};
</script>
<script type="text/javascript">
var webdata_sn = "1234567890 ";
var webdata_msvn = "000C";
var webdata_ssvn = "001E";
var webdata_pv_type = "0078";
var webdata_rate_p = "";
var webdata_now_p = "4880";
var webdata_today_e = "11.0";
var webdata_total_e = "2233.0";
var webdata_alarm = "";
var webdata_utime = "0";
var cover_mid = "4013752125";
var cover_ver = "MW_08_0501_1.57";
var cover_wmode = "STA";
var cover_ap_ssid = "AP_111111111";
var cover_ap_ip = "10.1.1.1";
var cover_ap_mac = "11111111111";
var cover_sta_ssid = "my ssid";
var cover_sta_rssi = "100%";
var cover_sta_ip = "192.168.x.y";
var cover_sta_mac = "123456789";
var status_a = "1";
var status_b = "0";
var status_c = "0";
select: “.lab_l2”
This does not throw an error anymore but the value is now empty. There are multiple values with different ID= but how to select the right one? And is this the right approach? Or is it possible to directly scrape the value behind var webdata_now_p =
Hi, Frank
Thank you for the replies. I will test it today. Sorry I didn’t reply yesterday. I hope I get this working. It is realy important for me. Thanks a lot for working this out
Hi Frank, I think you have the same problem as I’m having with my solarpanel. As lolouk44 replied on this post in april 2019, I think that your values also are loaded after the page itself is loaded and that makes it not possible to read any of the values on the page. However since they appear in the log of your homeassistant, there has to be a way. You are already one step ahead of me.
I’v read all related topics I could find and believe that I need to do with a value template.
Is there a way to select “all html output” and then use a value tempate to filter the exact value? Or use something like a regex ?
The enitre HTML, including the desried values is in the Home Assitant Log.
Is it even possible to scrape just string values from this source?
I tried everything but can’t grab these values. Is is possible to select all and then use a regex?
Or is it possible to run a PHP script (as I have a working script)?
If you have the option to run php scripts then that is your solution.
Just host the PHP file somewhere and make it scrape and output the value you want, then in Home Assistant it’s a simple scrape.
I did that, I uploaded a scrape php page to my webpage that my Home Assistant contacts to get the values from a third party page.
Much easier to scrape with full programming tools.
Unfortunatelly I cannot find selector. I did try: title, .title, .minutecast-dial .title, .minutecast-dial.title and all this options with p at the end.
No luck. All the time error: ERROR (SyncWorker_18) [homeassistant.components.scrape.sensor] Unable to extract data from HTML
Any hint?
I managed to get this working from the Ginlong monitoring website after setting it to public but it doesn’t seem to be “recording” the information only displaying it on a card. Does anyone happen to know how I would get this to work please? I’m using InfluxDB atm for thermostats so would like to add it here if possible.