-
Notifications
You must be signed in to change notification settings - Fork 49
Description
Describe the bug
I'm using a custom profile script for my powershell (for Starship mainly) but looks like HASS.agent doesn't like this.
I've created a sensor script that outputs a state On\Off based on something and made HASS run it as "Powershell command or script" in the sensors window.
But whenever there's a custom profile script (at "D:\Roy\Documents\WindowsPowerShell\Microsoft.PowerShell_profile.ps1" for me) the output includes (appended to the desired output) an error stating scripts are disabled on this machine. see screenshot below..
I don't know how HASS is calling PS behind the scenes but maybe adding the -NoProfile argument is all we need..
To Reproduce
- in HASS GUI, got to "Sensors"
- create a new sensor with the following configuration:
- Type: PowershellSensor
- powershell command or script: echo "Hello World"
- now click on the test button
- observe the popup, it should say Test successfully executed, result value: Hello World
- dismiss the popup
- now create the file
<Documents-Path>\WindowsPowerShell\Microsoft.PowerShell_profile.ps1with any content, for me it's:
$env:STARSHIP_CONFIG = "$HOME\.config\starship\starship.toml"
Invoke-Expression (&starship init powershell)
- go back to HASS sensors window and click the test button again
- observe the result popup, it should say the same as before but now also includes a pipe and an error message
Expected behavior
HASS shouldn't use PS profiles and not attach the error to the output\payload. instead the error should be logged
Misc info (please complete the following information):
- Windows build (ideally screenshot/info of
winver.exeoutput):
- Windows' UI language: enUS
- HASS.Agent version: 2.1.1
Please check what's applicable (multiple answers possible):
- Installed via installer
- Installed manually
- Problem occurs in HASS.Agent
- Problem occurs in Satellite Service
Additional context
I only tested a custom profile script to add Starship to my terminal but maybe this issue will persist whenever the script exist. you should test that before installing Starship :)

