H
HASS.Agent•2mo ago
Ellie

command does work with mqtt topic, works without

sorry to bring up another one of these 😅 i have a command i want to run
nircmd setdisplay monitor:0 1920 1080 32
nircmd setdisplay monitor:0 1920 1080 32
it runs fine like that, but i want the last 3 arguments to change so i tried to set it up as an mqtt action topic the command is
nircmd setdisplay monitor:0
nircmd setdisplay monitor:0
and the mqtt action is
action: mqtt.publish
metadata: {}
data:
evaluate_payload: false
qos: 0
topic: homeassistant/button/PC/SetResolution/action
payload: "\"1920 1080 32\""
action: mqtt.publish
metadata: {}
data:
evaluate_payload: false
qos: 0
topic: homeassistant/button/PC/SetResolution/action
payload: "\"1920 1080 32\""
14 Replies
HASS.Agent Helper
HASS.Agent Helper•2mo ago
Help us Help Others!
To help others find answers, you can mark your question as solved via Right click solution message -> Apps -> ✅ Mark Solution
From An unknown user
HASS.Agent Helper
HASS.Agent Helper•2mo ago
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 app.
You can find it by clicking the ? at the bottom of the main page and checking under the logo that shows.
We will help as soon as possible. While you're waiting you can try the following:
- Checkout the documentation. - Search here in discord for previously solved similar issues.
HASS.Agent Helper
HASS.Agent Helper•2mo ago
@Amadeo
Ellie
EllieOP•2mo ago
hass agent seems to be recieving the command, i get the following error in logs https://dpaste.com/F93G39K27 adding the exe or specifying the file path (which is C:\Windows\nircmd.exe) doesnt change anything only time it works is if i skip the action topic and put the whole command in hass agent
Amadeo
Amadeo•2mo ago
nircmd.exe
this exe is directly in C:\Windows?
Ellie
EllieOP•5w ago
yes sorry idk how it took me so long to see this 😅 it just happened to me again with another powershell command the following payload with an empty command in Hass Agent does not work
action: mqtt.publish
metadata: {}
data:
evaluate_payload: false
qos: 0
retain: false
topic: homeassistant/button/PC/StopProcess/action
payload: "\"Stop-Process -Name powershell_ise -Force\""
action: mqtt.publish
metadata: {}
data:
evaluate_payload: false
qos: 0
retain: false
topic: homeassistant/button/PC/StopProcess/action
payload: "\"Stop-Process -Name powershell_ise -Force\""
but setting the command in Hass Agent to
Stop-Process -Name powershell_ise -Force
Stop-Process -Name powershell_ise -Force
and just hitting the button entity for the command in HA does work i just picked powershell ise for testing purposes
Amadeo
Amadeo•5w ago
commands do not support payload parameters
DrR0x
DrR0x•5w ago
powershell commands?
Amadeo
Amadeo•5w ago
oh, you're rigt to be specific powershell commands with command in configuration (instead of path to ps1 script)
DrR0x
DrR0x•5w ago
was not trying to mean that, but sure 😂 So powershell commands don't allow for payloads, but a script path and then payload does work?
Amadeo
Amadeo•5w ago
yeah
DrR0x
DrR0x•5w ago
Docs note im gonna forget, but ill just search the server for messages with docs so this'll do as a reminder
Ellie
EllieOP•4w ago
gotcha. im assuming this is a security thing? but youre also saying paths to ps1 script do support payload parameters?
Amadeo
Amadeo•4w ago
im assuming this is a security thing?
I'll be honest with you, that's how it's been from the start 😄 (the original hass.agent)
paths to ps1 script do support payload parameters?
ya, if you put a ps1 script instead of command then you can get parms in code example:
$wshell = New-Object -ComObject Wscript.Shell
$wshell.Popup("runs " + $PsBoundParameters.Values + $args,1,"Done",0x1)
$wshell = New-Object -ComObject Wscript.Shell
$wshell.Popup("runs " + $PsBoundParameters.Values + $args,1,"Done",0x1)
will give you popup with parms that were provided via payload

Did you find this page helpful?