Powershell command no longer working after update
Hey! Is there any way for me to log commands?
I have a custom powershell command that's just blank so I can run anything I need via home assistant through it, and I have in my path a script called "bt.ps1"
Before updating & migrating from the old version, this worked perfectly fine as such:
But now it doesn't work. Running the powershell command manually works just fine
Solution:Jump to solution
yeah i found out, because the apps have the exact same name and I started them from windows I kept starting different ones each time
The windows bar has a nifty feature when you have 2 programs with the same program name whenever you type it in the search bar it ALTERNATES between the two
So that messed up the config somehow, looks like on the new version the mqtt topic changed...
41 Replies
Help us Help Others!
To help others find answers, you can mark your question as solved via
Right click solution message -> Apps -> ✅ Mark Solution
Help us Help You!
Please don't delete messages or posts because it makes it impossible to understand what happened. If you don't want your messages to be seen then don't post here.
Please provide us with the version number of your client.
You can find it in the HA device info page after 'Firmware'.Make sure to provide detailed reports of bugs.
Please include error log uploads and info about the bug.
@Amadeo
https://github.com/hass-agent/HASS.Agent/pull/47 using the script from here to test won't even show up anything
GitHub
Fix: Powershell command argument binding by amadeo-alex · Pull Requ...
This PR fixes how action arguments are passed on to the PowershellCommand.
Previously whole action string was passed as a one argument, this prevented parameter binding - after the changes the acti...
I'm just a newb, but I'm pretty sure you need the full path to bt.ps1 in your payload?
at least, that's how mine are configured
I have it in a folder that's declared in my environment so anything I put in there can be used as a "command", e.g if I put the test.ps1 in that folder I can just run "test.ps1" from any powershell window
Even running it with the full path won't work
The key point here is that the only difference between when it worked before 1 hour ago and when it stopped working is me updating to the new client, so there must be something going on there
see? this is why i prefaced my comment! lol
Yeah all good, you learn something new every day, I'm a powershell noob too
that is clever though, and you've just made me change my entire setup, declaring once, is sooo much cleaner than having to do it for every script. thanks! ok, enough derailing 😉
FYI that PR has been merged into a development branch of 2.1.0 release (that's not released yet :D)
Yeah I'm just saying it doesn't pop up anything at all, no arguments or anything
Nothing runs
Just running a custom command not a powershell one works fine, I just add powershell to my command in HA and im all good
Well I guess that works but this seems really weird
@Amadeo doesn't the extended logs report when commands are run and info about them or is that something you enable in visual studio?
Should I make a PR for a feature request to be added in? I'd say that fits into extended logs and is quite useful, e.g
Command X ran with arguments <here>
You definitely could but I think we might have this so let's check with Amadeo first.
Would fit best as an extra toggle or even file but this will work. We can add stuff like this for v3
I think I missed smth, example from the PR mentioned below will not work with current version, are we talking right now about adding extended logging "always" ("always" because there will be "[POWERSHELL] [{name}] Launching PS {descriptor} with action '{action}' failed" logged when execution fails)
or about some bug 😄
there were additional changes before this PR that could of broken compatibility with the original one
Adding it always. Hence the reason I reckon an extra toggle but that's more complex. (And requires another 5 minute walk)😂
@barrelltitor can I please have the ps script? I'll test it on the PR branch to see it it'll start working again
oh wait
you've been providing command and the parameters as one payload
I'm not quite certain that it was ever supported, hmm
if the "action" doesn't end with ".ps1" it will be treated as a command and not script, this really worked before?
how is the command configured within HASS.Agent?
It worked before i updated
Changed nothing before or after updating, the only change was that it stopped working
I did get it working like this using just "Custom" instead of custom powershell, so that works for me
I can revert back to hass agent and take a video of it working if it helps in any way, but I've had it working like this forever
I didn'[t even know I had to provide an "action" lol
It always worked just with "payload" set to the entire command
na, not worth it 😄
I'd give logs but the logs don't record commands
For me personally it's kinda fixed as I can use custom
Oh @Amadeo I actually got it from the docs
Docs example:
when you configure a powershell command it'll be executed differently base of if it's "script" (ending with .ps1) or "command" (anything else) - in the "Command or Script" text box - if you then use payload it'll be added as a parameter to the "script" one
oh yeah, with "Custom" it should work as expected
How would it execute differently though? If the script is available in the path it's just a command
I can run it anywhere in my system by just doing "bt.ps1" as it's in my path
with "Custom" HASS.Agent says to system basicall "yo, here you have X, execute it", with powershell one it's appropriately passed on to powershell.exe either as a command or script
hm, that would partially explain why it worked before
(has no output, but it succeeded)
Could it have been something from a failed migration? I edited the action a few times, and now all of a sudden it works lol
was actually recording to show you at the time, the video shows it not working then working again after removing "test.ps1" from the field and confirming again
To clarify: I did have it empty before, I set it to test.ps1 a few minutes ago testing it
Mind you
Bt control is integrated in HASS.Agent itself
It's caled RadioCommand if memory serves me right :D
Not likely, the way that payload is passed on to the scripts/commands was changed with one of the PRs to fix a bug (not the PR mentioned above, other one) - most likely it was the cause
Wait so what was not working before works now?
And if you choose the "switch" as entity type in HASS.Agent it'll be feedback as well (will update when you change it on the system)
yup, no idea why, I've tried removing the command from the configuration and re-adding it several times before
now I'm more interested 😄
do you have a copy of the old config maybe?
so we could compare and check
I didn't take a backup unfortunately, I just took screenshots of everything as I didn't know where it stored stuff, figured I could quickly re-do them in case of anything
is it possible maybe it didn't properly subscribe to the topic or something and only did it when I changed something?
I didn't uninstall the old agent before, I just closed it, not sure if that could have caused issues too
They can both be installed at the same time so it should have been fine
@barrelltitor did you ever sort this out?
or more so figure out what couldve caused the issue?
Solution
yeah i found out, because the apps have the exact same name and I started them from windows I kept starting different ones each time
The windows bar has a nifty feature when you have 2 programs with the same program name whenever you type it in the search bar it ALTERNATES between the two
So that messed up the config somehow, looks like on the new version the mqtt topic changed
i did a bunch of stuff though in testing but I don't know if it was necessary, i removed hass integration + deleted the mqtt device and let the new version properly do its stuff, and I haven't had issues since
Why tf would they go to effort to make it alternate 🤣
unless for some reason it favours the oldest oppened one?
meaning its a bug?
yeah it opens the oldest opened one, not the latest, idk why
so weird