I am running it on a Linux server, but should work just fine on windows.
the challenge might be to read the new directory, but the command or script could work that out.
If you give some more information I am happy to whip something up for you.
Information in textfile contains new sensor data every 30 second, this is printed on the bottom line of text file, like example below. First six digits are time like HH:MM:SS, all following digits are sensor data (temperature):
Unfortunately I don’t have HA running on Windows, but this should give you the last line of the file most recently written to. (Tail is really hard in “DOS” but very easy in Powershell.)
I think the value template should be easy for someone with a bit of template experience. I might give it a shot later, but I need to build and equivalent sensor on linux first. Hope this gets you going.
The above sensor should give you 00:04:00,9.93 as a result. {{TIME, VALUE}}
you could update the sensor every 10 seconds and still be close to your 30 seconds update of the file.
Or a fair bit slower, as the ground does not change its temperature that quickly …
this now splits the result at the “,” and returns the second part of the string. [0] = time, [1]= value
You won’t get the exact time the value got updated in the file, but you should still have the timestamp the sensor was refreshed.
Thanks for your help.This is one big step closer to the solution.
With the line value_template: ‘{{ ??? }}’ I get error message to check my config, if I just delete this line I receive the value from the last line in text file in HA sensor as expected.
I can also run the command: powershell -command “& {gc ( gci C:\logger -recurse | sort LastWriteTime | select -last 1).fullname -tail 1}” in command promt to verify this.
But when I run your last suggestion I´ve got som error messages from powershell, se below (HA i doesn´t read any value with this command line):
Great, this works perfect. Thank you datamonkey for your first class support, I really appreciate this!
I have added some more sensors from my Logger to HA, I only did write their unique name after C:\logger\ and your script find them without any problems.
I hope this topic will be useful for other users that have #Logger2020 used with #LoggerSoft or similar loggers that save data to text-file.
Once again, thank you very much for this support. Thanks to this I´m “on the road” with HA.
This command_line sensor has worked great for me under Windows, but now is Hassio is migrated to Ubuntu-server so hope to get some help how to translate this script for running with Hassio under Ubuntu.
It´s still the same file from Logger (windows program running with Wine under Ubuntu). Can I use part of the same command, what needs to be changed?