Thanks so much, it worked like a charm!
I feel like I’m missing something obvious. Created a powershell script to do a screen capture. In Windows I can execute it and see it store the image in config/www. The script is in D:\HA\HAscreencapture.ps1.
When I create the command in HASS.Agent, I use this configuration but it doesn’t work. What did I forget? Pressing the button in HA does nothing and I can’t see anything in any log.
Hi, this might be far fetched but would it be possible to turn the screen off,
and turn it on when the webcam detects an object?
Where would i start on this?
That looks ok, I don’t know what could be going wrong. Does the script work when you run it manually?
You can try this example (haven’t tested it myself):
Hey @cemara,
You can use the display on/off commands in the latest beta.
For the webcam detection: you could use netcam studio. It’s free for 2 sources. Enable motion detection for your webcam (blob detection works fine). Then create a rule that triggers on motion detection. Use RunApp
as the action, and curl.exe
as the path (you can get curl here). Then enter this as the argument: -d "" http://your_hass_ip:8123/api/webhook/your_webhook_name
.
In HA, create an automation:
- alias: whatever you want
initial_state: true
mode: single
trigger:
platform: webhook
webhook_id: your_webhook_name
action:
- service: switch.turn_on
data:
entity_id: switch.your_display_on_switch
Restart HA afterwards.
That’s the script I’m using. I can call it directly in Windows and it places the image in /config/www but from HASS.Agent it doesn’t do anything.
Finally checked the Event Viewer and found this:
> Error Message = File D:\HA\HAscreenshot.ps1 cannot be loaded because running scripts is disabled on this system. For more information, see about_Execution_Policies at https:/go.microsoft.com/fwlink/?LinkID=135170.
> Fully Qualified Error ID = UnauthorizedAccess
Ran PowerShell as Administrator and ran
Set-ExecutionPolicy RemoteSigned and now it works.
Good catch! Added to the example
@SamKr I have been keeping an eye on development of this with interest for a while now and decided to jump in and give it a try. Firstly, thank you for all your effort and work on this!
I’ve searched this ever expanding thread and haven’t been able to find anyone posting about the same issue, but I am finding that sensors are not holding their states between restarts of Home Assistant.
For example, I have enabled the MicrophoneActive and WebcamActive sensors, which are super useful for triggering status updates when in Teams Meetings (I’m really looking forward to be able to filter the process using these in the next release for more accuracy). These show up and work flawlessly in Home Assistant, until I restart at which point they then show as unknown
until I go back into HASS.Agent and store and activate them again, or wait for the first update of state to be sent. What this means is that I always miss the first state change after a restart as they are changing from unknown
instead of off
or on
. If I change my automations to ignore the from
state and just use the to
state, one of the automations gets triggered whenever they first update after a restart.
I have temporarily created input_boolean
helpers to store the states between restarts and have automations that update the helpers whenever they change. This is a decent workaround, but doesn’t actually resolve the issue I am experiencing. Maybe it’s just me that’s having this issue? I am running this on a work laptop that is preventing the notifications from working (ports are being blocked by security software which I am unable to circumvent), so maybe a message is sent to the laptop from Home Assistant to query the states after a restart that is not being received?
I’m no expert on MQTT, but I can see in MQTT Explorer that the Retain
flag is not set on the messages in my instance. I’m not sure if setting this would solve this, or if this is something I can do, or needs to be changed in HASS.Agent?
Any advice on how to resolve this and remove the need for the input_booleans
would be appreciated. I did think of creating an automation to query and update the states after a restart (i.e. using an event
trigger of start
), but I don’t know what I need to do to query it (i.e. what I need in the action
). Given the ports on the laptop are blocked, it would need to query the MQTT broker. Also wondering if I am alone with this issue and it’s being caused by the ports being blocked on my laptop, or it’s something others are experiencing. TIA.
Just switched over from IOTLink and really impressed so far - especially the windows gui!
In IOTLink you have the command to turn off/on the display. Is this possible in Hass.Agent?
I can’t seem to figure out the commands? You do have a YAML example of creating a light entity for the display in your docs.
Thanks!
I also wanted to turn on/off the display.
for turning display on, i send a ctrl key press via HA to the pc.
For turning off i tried to install nircmd, which has a function nircmd.exe monitor off.
That is working very well, when i type that in the cmd and hit Enter.
But if i try to add a command, it does not work.
I have set the external tools to “C:\Windows\System32\cmd.exe” with interpreter name “cmd”.
and try to set a CustomExecutorCommand:
But if i try to execute this command via HA, there is nothing happening.
This is great and I just started using this app. I’m very interested in using the LastActive sensor to turn off my office lights when I haven’t been actively using my computer for a while. But it seems like sensor is always active, even if I’m not making any user input.
The description says “Provides a datetime value containing the last moment the user provided any input.” but it doesn’t seem to work that way for me.
Hi @robertwigley, thanks!
This is a known issue that I’m working on, for now you can use a PublishAllSensors
command. Run that in an automation after a HA restart, and all values will get republished.
Hopefully that’ll be useful for you until a more permanent fix is in place
Hi @sebbaT, those have been added in the latest beta: Release 2022.13.0-beta2 · LAB02-Research/HASS.Agent · GitHub
Hey @flyinglow, it might be that you have a tool running that prevents your system from going to sleep by emulating input. The sensor simply retrieves the value from Windows, and it’s based on mouse & keyboard input.
OK. That’s good to know. Thanks.
Is PublishAllSensors
a service? I can’t see it in Developer Tools. I couldn’t find it in the documentation either. Could you advise how to use it?
If I can create an automation to do this on start, it will completely get rid of the problem. Thanks.
It’s a command in HASS.Agent. You can then use this trigger in your automation:
trigger:
- platform: homeassistant
event: start
Then simply call the command you created (depending on what type you made it):
- service: switch.turn_on
data:
entity_id: switch.hass_agent_publish_all_sensors
Excellent! I hadn’t looked in the commands. This should be added to the Wiki/Docs. I can confirm that this has solved the problem. Thank you.
trigger:
- platform: homeassistant
event: start
action:
- service: button.press
target:
entity_id: button.laptop_publish_all_sensors
Great! I’ll add it
Thanks @SamKr, that was a good tip. I tried diligently closing any software that could have been running in the background and didn’t find anything. Then I started thinking about hardware devices and when I unplugged my game controller I found it was the source of the “user activity” that was making the LastActive sensor always be active.