-
-
Notifications
You must be signed in to change notification settings - Fork 76
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bug: PowershellSensor as Satellite Service - error_during_execution #343
Comments
this is mine:
I noticed i missed ApplyRounding and Round. Stopped the service, edited the json, started the service again. No success. After send and activate the custom config was gone. The satelite service is 2022.20.0.0. I am running the client from another disk (D:) then the satelite service (C:). I also tried to change the command to |
Any ETA on this? |
Yes, it is stated in the first post: 2022.14.0. if you want me to run a debug version, or enable debug logging (if possible), then i am happy to help |
I might have made some progress. My Service Log File on my PC is full with these messages: Digging into the Error Message searching for System.Text.Encoding.GetEncoding I found that "1" is indeed not a valid codepage. |
It could be that the .Net version makes a difference. Mine is Edit: Same here
|
Good find, thank you both! |
From what I've been able to research, it looks like this might be some kind of incompatibility between the .net/.netframework and the keyboard/system languages which are installed on a given system. |
Fix added to the PR and merged to the bulk PR LAB02-Research/HASS.Agent.Staging#24. |
What the...I'm quite certain that is neither English or Dutch :D |
Yeah, using unicode/utf-16 causes "normal" characters to become chinese and using utf-8 causes the chinese characters to be broken. How one cannot love text encoding... |
Just a side note: i saw that the implementation is done by executing powershell.exe. Are you aware that you could implement powershell c# natively? https://learn.microsoft.com/en-us/powershell/scripting/developer/hosting/host01-sample?view=powershell-7.3 And second: if you'll keep on using the commandline, did you know the command executed by powershell.exe can be base64 encoded? https://devblogs.microsoft.com/scripting/powertip-encode-string-and-execute-with-powershell/ |
I am unable to store the sensor with the latest version. The sensors.json is not created.:
|
You're using this branch? LAB02-Research/HASS.Agent.Staging#14 |
Ok, I've changed it to fallback to utf-8 since I need to drop from the PC and don't want to leave a borked PR hanging around. I tried to fiddle with the settings but no matter what/how I configure the process which is launched, the "normal" part of the output is malformed when utf-16 is used. |
Yes For what its worth, I also found this in regards to the OEMcodePage: https://stackoverflow.com/questions/1812104/relation-between-net-encoding-and-characterset |
Some thoughts..... Is it smart to call OEMCodePage? as afaik the OEM in this context would be the hardware manufacturer... and that can vary widely from a laptop over a desktop to a virtual machine. Sorry if these thoughts are silly... I am just an Escalation Engineer, not a Programmer :-) |
I have small progress with the investigation...so, the main culprit here is that even if the process running powershell has the input/output set to X or Y encoding, the powershell internally will still use system encoding. I've found a workaround where "injecting" for example: |
This is going to look like a personal notebook but maybe it'll be useful for someone someday :D What is interesting is that restoring the code setting "StandardOutputEncoding" to OEMCodePage changes nothing in the output. I'll rewind the git history of this file trying to find a good reasoning to remove this part of the code but if not, the safest way will be to set the StandardOutputEncoding when it is possible (OEMCodePage returns an actual value) and not touch it otherwise. |
It was added as part of https://lab02research.youtrack.cloud/issue/hassagent-164 due to #201 so it definitely stays. |
@Skons @Zarox666 could you please try this branch - https://github.com/amadeo-alex/HASS.Agent.Staging/tree/test-powershell-sensor-encoding - on the affected machines and then post the logs? (this branch will create the log entries each time the sensor is updated so don't run it too long) Expected output is something similar to this:
In case something goes wrong (which we expect) there'll be additional |
I tried to build the branch, but I get a lot of errors.
|
Oh, looks like you're trying to open the project in Visual Studio Code (it's a multipurpose "light" IDE). |
I see.... well ya gotta love Microsoft Product Names With the crappy internet connection installation will take a while. But now I finaly know where the Screenshot was taken lol |
|
Thanks for letting me know @Skons ! Could you please upload part of the logs I mentioned? They should be in the logs folder of satellite service. |
I believe this is what you are searching for?
|
I am getting exaclty the same Error Messages when trying to build from Visual Studio: But good that @Skons got it running and can provide feedback. |
@Zarox666 you’ll need to add nuget as a package manager. This url tells you how to add a custom, but in the screens nuget.org is visible after adding, the packages are added automatically i believe. |
Hopefully this time I got if fully right, added the change to both PRs mentioned before :) |
Ok, Not sure if I did something wrong there, but if you are certain enough that you found and fixed the problem, and @Skons seems to be able to confirm... what about porting this fix into the release version? |
I made a backup of the service folder in the program files folder. After copying the new service folder, i could also copy the config folder of the other to the test folder. |
Sorry for not responding for so long. |
is there any news on this? any ETA when this will be rolled out as update? |
has this been implemented by now? |
Yesn't :D |
Describe the bug
Powershell sensor does not work as satellite service. It works when Test Command/Script is executed, and it works as a hass.agent sensor.
To Reproduce
Steps to reproduce the behavior:
$(get-date).ToUniversalTime().ToString('yyyy-MM-ddTHH:mm:ss')
Expected behavior
The date as state in Home Assistant
Screenshots
![image](https://private-user-images.githubusercontent.com/13225002/260844701-5899f47f-e6e4-46e4-b138-8cf435020c6f.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MzkyNjY2NjcsIm5iZiI6MTczOTI2NjM2NywicGF0aCI6Ii8xMzIyNTAwMi8yNjA4NDQ3MDEtNTg5OWY0N2YtZTZlNC00NmU0LWIxMzgtOGNmNDM1MDIwYzZmLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNTAyMTElMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjUwMjExVDA5MzI0N1omWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTgzZWIwZTYzODMxZTM5MzhiNTQ4MjYxNjc4ZjExNmEyZTdmNjE5NjYzYTM3ZjJkY2M2MjY4ODE1ZjUzZDQyNGImWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.ZQQd3_MBQqDQWObqvMLpiX6EIp0qZJikEFAZqJZHlCI)
![image](https://private-user-images.githubusercontent.com/13225002/260845729-79f27c49-c4f0-4f36-8f7b-6c4b984e0be9.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MzkyNjY2NjcsIm5iZiI6MTczOTI2NjM2NywicGF0aCI6Ii8xMzIyNTAwMi8yNjA4NDU3MjktNzlmMjdjNDktYzRmMC00ZjM2LThmN2ItNmM0Yjk4NGUwYmU5LnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNTAyMTElMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjUwMjExVDA5MzI0N1omWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTM4YTA3MzdkY2ZlNWNjYzIzYzhkNDY2YWRlOGUxZDU5MzhlMzZhZTI5NmUyNTNmNDM1ZjM4N2VhYTU4NzU4YWImWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.omT_1sh1YtYWpUv5vmW_NGOM97dEy3b7p8dAql6uDpw)
Misc info (please complete the following information):
winver.exe
output): Win10 22H2Please check what's applicable (multiple answers possible):
The text was updated successfully, but these errors were encountered: