Triggering Powershell not working
Following on from https://discord.com/channels/932957721622360074/1208148867799982112
Currently running the forked version, but unable to get Powershell to trigger the command
Switch-Desktop -Desktop "Desktop 2"
37 Replies
Interestingly, I tried the PowershellSensor and tested the script there, got this error
@Amadeo
This is obvsly something to do with quotes in ha and stuff
@Evostance what it's saying is that there is no quotes around desktop 2 in the Hass agent call and so the command gets confused as to what 2 means. It sees:
- switch desktop
- desktop is
Desktop
- 2 is an extra argument the command is not expectingWait
Didn't we already talk about it somewhere
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...
Although the "Desktop 2" should be in quotes either way - like I just written I think
Yep, so it is in quotes on the sensor. Hence why wondering if the command has the same problem
Switch-Desktop -Desktop \"Desktop 2\"
seems to work on the sensorSolution
Ah, escaping the quotes fixed it for the command too
So fixed then?
Yeah, would be ideal though if you didnt need to escape the quotes in the actual script within Hass agent, but "fixed"
nvm, sry this is in agent. that's weird. I assume its how we parse it right @Amadeo ?
no no, escaping those characters is needed in hass agent too
oh
ha = hass agent, not home assistant lmao
nah it means home assistant i just miss typed 🤣
oh 🤣
With commands its just passed to powershell.exe but I'll see if there is smth on our side that forces the " to be escaped
hm, looks about right
damnn, I'll need to install that Switch-Desktop thingy again
so, this works:
but this doesn't
looks like it's not really fixable in code (easily, I'll fiddle with encoded parameters) and the only two options are:
or
ok, I got it working with the encoding option however with this only following work (excaping is not required and it breaks the pasring of parameters):
@Evostance what's your opinion 😄
Wait so right now single quotes work fine or are there issues with that?
they do
at least on the fix/test branch I created
Ah okay so either way you have to change it?
Yep just re read comment makes sense now
Look I reckon double quotes as long as it doesn't break anything else but that's just because most people use double quotes for paths and stuff in CMD/powershell
But I also get the argument for single quotes because this is being used in yaml
With the change both will work but I'm thinking that some ppl might have figured out the escape optiom with current build - which will break for them after the change
We might just mark it ad a breaking change, for me "" and '' make more sense than '' and ""
Ah okay, look I would count that as a very minor breaking change so no need to worry about version stuff 😂
Did something change in the latest beta :/
Seems publishing no longer triggers the powershell stuff
yes and no
Edit: not in case of this :D
goddamnit the powershell stuff is like a flip switch
you fix one thing and nother is borked
wait
^ this works for me
what is not working for you
the encoding change was not included in the 2.1.0-beta1
so it's as been before
details please 😄
hmmm
So actually, MQTT didnt work
but the button did
lol
So, might not be anything to do with encoding
Also, i changed it to
Switch-Desktop -Desktop 'Desktop 2'
still works fine@DrR0x
@koshi
Sorry for pings only but quite busy with work atm 😄
All goodz thx for that, knew we did this at some point 😂
same here 😉
quoting hell...
C:\"Program Files (x86)"\Steam\steam.exe
Does that work?
no - because discord is eating up half the escape codes itself
Use either side
this works
Hmm, have you tried on mqtt exp?
It shouldn't need to be this long
I just added the third escape at the beginning because I was afraid that it would mix it up with the directory slash
Yeah but still, it's been implemented to not require escaping assuming you have a newer beta
thats good to know - I will probably fiddle around with it more once I have more complicated stuff
but for the moment it works, so its good enough 😉
If it ain't broke don't fix it