Hi I am not very experienced with Hassio and as a result have used NodeRed to make up for my Hassio shortcomings. I would appreciate some help if anyone has some thoughts. I am running the latest Hassio on a VM.
I use NodeRed to write the output of my mqtt water meter to a file which is overwritten every hour. The file path in Nodered is /share/todaylog.txt. This file can be mounted on my windows pc. The text file only contains 1 line holding the current Water usage total for the day. ie 165.5.
The powershell below retrieves the value when run in powershell but when I try to incorporate it into my Yaml and add it as an Entity Card to Home Assistant it does not retrieve any values.The Card Just says unknown.
Can someone tell me what I am doing wrong?
How can I test if Hassio can access this share?
Thanks for responding. I did lift this PowerShell line from somewhere it did the job so I didn’t worry to much but yours is cleaner. The PowerShell Path is the same on my setup but unfortunately I still just get ‘unknown’ as the result in my Entity Card. I tested your line direct in CMD line and it worked fine. I have also tried just using Python to print the line instead of using PowerShell but this also does not work under YAML.
Does my Hassio need to actually see the path or does the script I provide do all the work and Hassio just collects the result? Here are the new commands I have tried.
I think HA just receives the response by the way. I have to be honest to tell that it is a bit guessing/trail and error now, but how about using return:
The command above handles the result as a variable and returns the variable. Next to that, I removed all the quotes just to make sure that is not causing any issues. You might want to try to put the whole command in between quotes like this:
Yes the command line is nested under the Sensor: Tag.
I tried both versions of your code, the top one works when run directly in powershell, the one in double quotes errors. It also errors in Yaml. Complained of ‘unknown escape sequence’.
Ok so I have looked a bit harder and discovered the Core Logs under Supervisor.
It is reporting the following. It seems to drop the ‘backslash’ in the powershell path. Also says /bin/sh: gc: not found.
/bin/sh: C:WindowsSystem32WindowsPowerShellv1.0powershell.exe: not found 2020-07-08 07:35:19 ERROR (SyncWorker_0) [homeassistant.components.command_line.sensor] Command failed: C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -Command { return $(gc //[192.168.86.159/share/todaylog.txt](http://192.168.86.159/share/todaylog.txt) -First 1) } /bin/sh: gc: not found
My Hassio System is installed on Ubuntu running as an Oracle VM on a Windows 10 PC so it’s looking like it can’t resolve to the Powershell exe. Have you had any luck running a Windows Command yourself? Perhaps they need to be Linux based.
I tried copying the today.log.txt file under the Hassio /config directory and ran in Yaml
command: tail /config/todaylog.txt
THIS WORKED! So I think I have 2 issue.
a) Hassio cant run Windows Commands,
b) Hassio cant see the Nodered Share.