Scrape file on pc of same network

So first things first, hi im mike and im computer illiterate .

Im currently running hass.io on a pi4 and would like to scrape a file on my laptop to use for information.Can anyone point me in the right direction please? i tried search function here at the top but alas were here, mind you my search ability does seem limited by my illiteracy.

my template is coming along as follows …

sensor:

  • platform: file_restore
    unit_of_measurement: ‘PPM , PH , TEMP’
    file_path: DESKTOP *****/C:/Users/****/AppData/Roaming/Bluelab/Connect/logs/GR1.csv
    name: File

the file im scraping is formatted as follows, id like to take the 3 spaces of information at the end of each line
1710
4.7
69

Time (America/New_York),Conductivity unit,Temperature unit,c0kb Conductivity,c0kb pH,c0kb Temperature
2021-12-10 06:02:00,ppm500,F,1710,4.7,69
2021-12-10 06:03:00,ppm500,F,1710,4.7,69
2021-12-10 06:04:00,ppm500,F,1710,4.7,69

Hi Mike,
I believe this is a challenge and I don’t expect native support for it. My preferred approach would be to store the file from my Windows machine on the SMB share of HA.

Next you can use the File Integration to read the file. It might be possible to use the UNC of your desktop, but I have no experience with it.

Ideally one would generate the file using HA by the way, but I totally understand a step by step approach.

1 Like

i will try that, ive gotten myself into a bit of a rabbit hole with possible ssh scrape

ill see if i can get the files to save to that section, when the replacement parts get in friday. might be easier than ripping from one platform to another

That’s exactly my idea. If you can set a location to store the CSV, a UNC path shouldn’t be an issue from the Windows side towards HA. If it is, you could mount it to a drive letter as-wel of course.

Not sure what you mean with this. You can ssh from your HA if that’s what you want. You can create a shell command that can be scheduled using HA so you might even save some electricity shutting your Windows machine and let the Pi do the trick for you. But as said, I don’t know your situation and despite that, it’s wise to set one step at a time :call_me_hand:

1 Like

shared folder with samba made the day easier

so i went the ssh route after setting shared file for educational purposes…or i just like figuring out the hard way

ssh to cllient
add password
scp the files to pi folder designated
password
log out

im going to see if shell command can handle the task next, just wanted update on progress so far

shell_command:
ssh_client: ssh ^&%@pc ip
password_input: ****
change_drive: cd AppData\Roaming\Bluelab\Connect\Logs
send_files: scp *.csv root@pi ip:~\config\BlueLogs
password_input: ****

i swear these are offfset 2 spaces under shell_command: but it doesnt show it

Good to see the progress.
You could consider using a script instead of adding the code in your configuration.yaml.

shell_command:
  my_script: bash /config/shell/script.sh

About posting code on the forum, try using the code formatting button in the top bar </>

have more issues writing the script than anything

gonna keep plugging at it but

script:
alias: File Grab
sequence:
-service: ssh_client
-service: ssh_client_passwd
-service: ssh_client_cd
-service: ssh_client_scp
-service: host_passwd

shell_command:
  ssh_client: ssh 
  ssh_client_passwd:
  ssh_client_cd: cd AppData\Roaming\Bluelab\Connect\Logs\
  ssh_client_scp: scp *.csv root@pi ip:~\config\BlueLogs\
  host_passwd:

You don’t need to make it this complicated. Just use scp right away to copy the file from the Windows machine to the RPi.

scp 'windows_host:AppData/Roaming/Bluelab/Connect/Logs/*.csv' /config/BlueLogs/

Use ssh public key authentication to avoid having to deal with passwords. See SSH'ing from a command line sensor or shell command

2 Likes

one line ripper well done, thank you @ondras12345

just wanted to update!

Thanks to both of you guys for your help. i was able to automate a script using @ondras12345 scp command to get the files then a file sensor to extract the information.

Thanks for the feedback and great to see you got it working.
To help others, you could mark the post of @ondras12345 as solution :+1:

1 Like

it doesnt give me the option here for some reason

That’s probably because this topic does not have a category assigned. Move it to configuration and it should work.

1 Like

cant make 2 solutions on same topic … but ill listen whenever you give advice

figure ill tidy this up with this:

Goto Automations and add new script, give it a name.

action call service:

add scp line of code:
scp ‘windows_host:AppData/Roaming/Bluelab/Connect/Logs/*.csv’ /config/Filename/

  • change windows_host for your username @ ip hosting file

then add file sensors to configuration.yaml or sensors.yaml file

if in config youll need to identify them properly

example:

sensor:

  • platform: file
    name: ‘Accurate Temp’
    file_path: /config/BlueLogs.csv
    value_template: ‘{{ value.split(",")[5] }}’
    unit_of_measurement: “F”

Change number 5 for which , , space you want to pull data from and you should be golden

edit:: forgot to mention youll need to whitelist the directory as well

homeassistant:
whitelist_external_dirs:

  • /config/
    those dots should be -

tinkering around this weekend and found another more efficent work around.

Bluelab program can save anywhere on same network, using this line as your “Log Data Directory”

i used it to save to my pi running hassio directly then file sensor it onto lovelace

/run/user/1000/gvfs/sftp:host=YOURIPADDRESSTOSAVEFILE,user=YOURUSERNAME/config/FILETOSAVETO

so off the csv file you guys helped me figure out ive then used it as the main part of my automation. i first used it as a monitoring system once i parsed the file on lovelace. In node red its the main setup. i tail the file then parse it to use it to control switches that are told to come on/ off for a brief moment. eventaully id like it to check the timestamp inside the file to the current time - seconds but havent quite looked at how that would be possible…

just a mini update ill keep you posted as things come together, again thank you all