HASS.Agent: Bug: PowershellSensor as Satellite Service - error_during_execution

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:

  1. Go to Satellite Service
  2. Click on Sensors
  3. Click on Add New
  4. Select PowerShellSensor
  5. Add this as command $(get-date).ToUniversalTime().ToString('yyyy-MM-ddTHH:mm:ss')
  6. Click Store Sensor
  7. Click Send & Active Sensors

Expected behavior The date as state in Home Assistant

Screenshots image image

Misc info (please complete the following information):

  • Windows build (ideally screenshot/info of winver.exe output): Win10 22H2
  • Windows’ UI language: EN
  • HASS.Agent version: 2022.14.0

Please check what’s applicable (multiple answers possible):

  • Installed via installer
  • Installed manually
  • Problem occurs in HASS.Agent
  • Problem occurs in Satellite Service

About this issue

Most upvoted comments

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…

Hopefully this time I got if fully right, added the change to both PRs mentioned before 😃

I believe this is what you are searching for?

2023-09-15 16:33:36.382 +02:00 [ERR] ENCODING-TEST: currentCulture  {"ANSICodePage":0,"OEMCodePage":1,"MacCodePage":2,"EBCDICCodePage":500,"LCID":4096,"CultureName":"en-NL","IsReadOnly":true,"ListSeparator":",","IsRightToLeft":false}
2023-09-15 16:33:36.383 +02:00 [ERR] ENCODING-TEST: currentUICulture  {"ANSICodePage":1252,"OEMCodePage":437,"MacCodePage":10000,"EBCDICCodePage":37,"LCID":1033,"CultureName":"en-US","IsReadOnly":true,"ListSeparator":",","IsRightToLeft":false}
2023-09-15 16:33:36.383 +02:00 [ERR] ENCODING-TEST: currentInstalledUICulture  {"ANSICodePage":0,"OEMCodePage":1,"MacCodePage":2,"EBCDICCodePage":500,"LCID":4096,"CultureName":"en-NL","IsReadOnly":true,"ListSeparator":",","IsRightToLeft":false}
2023-09-15 16:33:36.383 +02:00 [ERR] ENCODING-TEST: invariantCulture  {"ANSICodePage":0,"OEMCodePage":1,"MacCodePage":2,"EBCDICCodePage":500,"LCID":4096,"CultureName":"en-NL","IsReadOnly":true,"ListSeparator":",","IsRightToLeft":false}
2023-09-15 16:33:36.383 +02:00 [ERR] ENCODING-TEST: first fail
2023-09-15 16:33:36.977 +02:00 [INF] [MQTT] Initial registration completed
2023-09-15 16:33:37.508 +02:00 [ERR] ENCODING-TEST: currentCulture  {"ANSICodePage":0,"OEMCodePage":1,"MacCodePage":2,"EBCDICCodePage":500,"LCID":4096,"CultureName":"en-NL","IsReadOnly":true,"ListSeparator":",","IsRightToLeft":false}
2023-09-15 16:33:37.508 +02:00 [ERR] ENCODING-TEST: currentUICulture  {"ANSICodePage":1252,"OEMCodePage":437,"MacCodePage":10000,"EBCDICCodePage":37,"LCID":1033,"CultureName":"en-US","IsReadOnly":true,"ListSeparator":",","IsRightToLeft":false}
2023-09-15 16:33:37.508 +02:00 [ERR] ENCODING-TEST: currentInstalledUICulture  {"ANSICodePage":0,"OEMCodePage":1,"MacCodePage":2,"EBCDICCodePage":500,"LCID":4096,"CultureName":"en-NL","IsReadOnly":true,"ListSeparator":",","IsRightToLeft":false}
2023-09-15 16:33:37.508 +02:00 [ERR] ENCODING-TEST: invariantCulture  {"ANSICodePage":0,"OEMCodePage":1,"MacCodePage":2,"EBCDICCodePage":500,"LCID":4096,"CultureName":"en-NL","IsReadOnly":true,"ListSeparator":",","IsRightToLeft":false}
2023-09-15 16:33:37.508 +02:00 [ERR] ENCODING-TEST: first fail

I see… well ya gotta love Microsoft Product Names

With the crappy internet connection installation will take a while. I try to get it compiled and tested tomorrow.

But now I finaly know where the Screenshot was taken lol

As requested:

There is indeed differences in the language settings. But as Skons has pointed out, this affects only the Service.

Server image PC image

.NET Runtime on the Server is 6.0.3 while on the PC it is 6.0.21

Now let me read up on the remainder of the Thread 😃

You’re using this branch? LAB02-Research/HASS.Agent.Staging#14

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

Fix added to the PR and merged to the bulk PR https://github.com/LAB02-Research/HASS.Agent.Staging/pull/24. Unfortunately for now the only reliable way to get it is to build the project yourself :\ (I don’t recommend accepting exe files/binaries from me or any other random internet user)