aaronsb / REC-BMSManager

Powershell based management for REC-BMS battery management
GNU Lesser General Public License v3.0
6 stars 0 forks source link

Send-MQTTValue Problem "Cannot bind parameter 'SecureString' Cannot convert the "password" value of type "System.String" to type "System.Security.SecureString". #5

Closed gnagflow80 closed 3 years ago

gnagflow80 commented 3 years ago

Hi Aaron, a last thing a cant get to run is the Send-MQTTValue (by the way in your Readme it is only called Send-MQTT). I installed the MQTT Server and Clilent. But, if i run your script i get following message and i cant get any values in MQTT explorer.

grafik

This is my mqtt config file: grafik

The defined password and user are the same as i use when applying your send-MQTTValue script. Any idea? thank you!

gnagflow80 commented 3 years ago

changed from: $PWD = ConvertFrom-SecureString -SecureString $Password -AsPlainText to: $PWD = ConvertFrom-SecureString -SecureString $Password -AsPlainText

in: Send-MQTTValue.ps1

error message is gone, but still my mqtt server doesnt receive data from topics, but receives only $SYS data.

aaronsb commented 3 years ago

There is a constructor (function) called use-bmsmqttconfiguration, the brokerpath is set from joined paths, that might be one thing. image

If you instance the module as you normally would (so you could get a bms parameter for example) What value is returned if you type "$BMSInstructionSet.Config.MQTT" at the powershell prompt?

aaronsb commented 3 years ago

Please remember that powershell returns objects, not strings. (even a string is actually an object). I would expect $BMSInstructionSet.Config.MQTT returns the object of type pscustomobject which was serialized from json, and includes the password text in it.

aaronsb commented 3 years ago

Isn't that the same command?

$PWD = ConvertFrom-SecureString -SecureString $Password -AsPlainText $PWD = ConvertFrom-SecureString -SecureString $Password -AsPlainText

changed from: $PWD = ConvertFrom-SecureString -SecureString $Password -AsPlainText to: $PWD = ConvertFrom-SecureString -SecureString $Password -AsPlainText

in: Send-MQTTValue.ps1

error message is gone, but still my mqtt server doesnt receive data from topics, but receives only $SYS data.

gnagflow80 commented 3 years ago

There is a constructor (function) called use-bmsmqttconfiguration, the brokerpath is set from joined paths, that might be one thing. image

If you instance the module as you normally would (so you could get a bms parameter for example) What value is returned if you type "$BMSInstructionSet.Config.MQTT" at the powershell prompt?

grafik

Usually i can accces the MQTT servier by: Server: 192.168.1.50 or localhost Port: 1883 Username: bauer Password: bauer

So, I dont know if the $BMSInstructionSet.Config.MQTT has the right properties. But, honestly i think i dont understand those things right.

gnagflow80 commented 3 years ago

Isn't that the same command?

$PWD = ConvertFrom-SecureString -SecureString $Password -AsPlainText $PWD = ConvertFrom-SecureString -SecureString $Password -AsPlainText

changed from: $PWD = ConvertFrom-SecureString -SecureString $Password -AsPlainText to: $PWD = ConvertFrom-SecureString -SecureString $Password -AsPlainText in: Send-MQTTValue.ps1 error message is gone, but still my mqtt server doesnt receive data from topics, but receives only $SYS data.

sorry was a mistake: grafik

gnagflow80 commented 3 years ago

There is a constructor (function) called use-bmsmqttconfiguration, the brokerpath is set from joined paths, that might be one thing. image

If you instance the module as you normally would (so you could get a bms parameter for example) What value is returned if you type "$BMSInstructionSet.Config.MQTT" at the powershell prompt?

The BrokerPath looks good, isn't it: grafik

aaronsb commented 3 years ago

maybe whats happening is you're not using the installer script? I updated some unfinished ends on it. Take a look at the relevant readme section here. (watch videos)

image

aaronsb commented 3 years ago

also I'd point out that once you have a service poller against the rec-bms, you need to be careful you're not issuing commands during the service poller. There's no lockout of resources (serial port, communication with bms hardware).

someday in the future I would like to change this to more of a typical service architecture, so the service module reads a command queue and returns the commands to the correct requester. This would eliminate device resource contention.

gnagflow80 commented 3 years ago

maybe whats happening is you're not using the installer script? I updated some unfinished ends on it. Take a look at the relevant readme section here. (watch videos)

image

Thank you a lot. It is working now! I did not install the REC-BMSMaanger within the right path. I followed your updated description and putted the module now into this path as you described: /opt/microsoft/powershell/7/....

MANY THANKS. Having the BMS Parameter within the MQTT opens up all kind of logging possibilities!!

aaronsb commented 3 years ago

Ok, closing this for now. Let me know what else happens, log bugs. You're officially the first person besides me to use this mqtt shipper. :)