H
HASS.Agent•4mo ago
Evostance

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"
No description
Solution:
Ah, escaping the quotes fixed it for the command too
Jump to solution
24 Replies
Evostance
Evostance•4mo ago
Interestingly, I tried the PowershellSensor and tested the script there, got this error
DrR0x
DrR0x•4mo ago
@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 expecting
Amadeo
Amadeo•4mo ago
Wait Didn't we already talk about it somewhere
Amadeo
Amadeo•4mo ago
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...
Amadeo
Amadeo•4mo ago
Although the "Desktop 2" should be in quotes either way - like I just written I think
Evostance
Evostance•4mo ago
Yep, so it is in quotes on the sensor. Hence why wondering if the command has the same problem
No description
Evostance
Evostance•4mo ago
Switch-Desktop -Desktop \"Desktop 2\" seems to work on the sensor
Solution
Evostance
Evostance•4mo ago
Ah, escaping the quotes fixed it for the command too
DrR0x
DrR0x•4mo ago
So fixed then?
Evostance
Evostance•4mo ago
No description
Evostance
Evostance•4mo ago
Yeah, would be ideal though if you didnt need to escape the quotes in the actual script within Hass agent, but "fixed"
DrR0x
DrR0x•4mo ago
nvm, sry this is in agent. that's weird. I assume its how we parse it right @Amadeo ?
Evostance
Evostance•4mo ago
no no, escaping those characters is needed in hass agent too oh ha = hass agent, not home assistant lmao
DrR0x
DrR0x•4mo ago
nah it means home assistant i just miss typed 🤣
Evostance
Evostance•4mo ago
oh 🤣
Amadeo
Amadeo•4mo ago
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
$@"& {{{command}}}"
$@"& {{{command}}}"
damnn, I'll need to install that Switch-Desktop thingy again so, this works:
Switch-Desktop -Desktop "Test123"
Switch-Desktop -Desktop "Test123"
but this doesn't
Switch-Desktop -Desktop "Test 123"
Switch-Desktop -Desktop "Test 123"
looks like it's not really fixable in code (easily, I'll fiddle with encoded parameters) and the only two options are:
Switch-Desktop -Desktop 'Test 123'
Switch-Desktop -Desktop 'Test 123'
or
Switch-Desktop -Desktop \"Test 123\"
Switch-Desktop -Desktop \"Test 123\"
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):
Switch-Desktop -Desktop "Test 123"
Switch-Desktop -Desktop "Test 123"
Switch-Desktop -Desktop 'Test 123'
Switch-Desktop -Desktop 'Test 123'
@Evostance what's your opinion 😄
DrR0x
DrR0x•4mo ago
Wait so right now single quotes work fine or are there issues with that?
Amadeo
Amadeo•4mo ago
they do at least on the fix/test branch I created
DrR0x
DrR0x•4mo ago
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
Amadeo
Amadeo•4mo ago
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 ""
DrR0x
DrR0x•4mo ago
Ah okay, look I would count that as a very minor breaking change so no need to worry about version stuff 😂
Evostance
Evostance•3mo ago
Did something change in the latest beta :/ Seems publishing no longer triggers the powershell stuff
Amadeo
Amadeo•3mo ago
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 😄
Evostance
Evostance•3mo ago
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
Want results from more Discord servers?
Add your server
More Posts