-
Notifications
You must be signed in to change notification settings - Fork 37
Add discovery_topic option, descriptive error when stdout empty #419
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
Conversation
- indicates that we are unable to connect to the PlayStation, which would happen when it is powered off or there is a networking issue causing the PlayStation to not be reachable
…eachable devices * Throw string instead of error to prevent including stack trace in debugger (since we already know where the message is originating from). * Improve the message to include the scenario where are user's Playstation may be powered on, but it is unreachable on their network, which will also lead to empty `stdout`
Hi @RobertD502, Thanks for your contributions to the repository. They are much appreciated! The |
Will attempt to test tomorrow as I am away from my setup at the moment! |
@RobertD502 were you able to test the new image? 😊 |
@FunkeyFlo Sorry for getting back to you later than expected. Tested with the edge image and it works great! All functions work as expected (powering on, entering rest mode, current activity attributes, etc.). In addition, making the PS5 unavailable by fully shutting it down results in the new message being logged, as expected. One thing that I forgot to mention/suggest (it doesn't pertain to this PR), what do you think about, in the future, adding a polling timeout of a few seconds whenever the switch entity is used to power the system on/off? Reason being, when sending a power on/off command, it results in the switch flipping back to its previous state within the HA UI before it finally reverts back to the state that the user set it to - this is likely occurring because the backend is immediately polling the PS5 status after a command is sent and it takes a few seconds until the system enters into/returns the new state. I get around this in the integrations I built by sleeping before requesting new data for APIs that tend to take a few seconds (after a command is sent) to reflect and, as a result, return the actual new state of a device. |
Add Discovery Topic
With the discovery topic hardcoded to
homeassistant
, those that don't use the defaulthomeassistant
prefix for the discovery topic are currently unable to utilize MQTT auto-discovery. This PR introduces a newdiscovery_topic
key in the mqtt config (and DISCOVERY_TOPIC env variable for regular container users) which can be used to define the custom discovery topic that a user's HA is set to use.Note:
If a user doesn't define adiscovery_topic
, ps5-mqtt will by default usehomeassistant
. So, users updating will not have to worry about this being a breaking change and needing to define thediscovery_topic
- that will remain reserved for those with a custom discovery topic.Examples
The examples below were carried out using a build containing the code changes seen in this PR
1) If the
discovery_topic
is not set, ps5-mqtt will publish to the defaulthomeassistant
discovery topic2) If the
discovery_topic
is set by the user (it was set toRANDOM_DISCOVERY_TOPIC
in this example), ps5-mqtt will publish to this discovery topic instead ofhomeassistant
Throw descriptive error if device state stdout is empty
Based on my testing, the JSON parsing error occurs when the Playstation is unreachable (resulting in
stdout
being empty) -this will happen once when sending the Playstation into rest mode and continue to happen if the user completely turned off their Playstation / it is no longer reachable on their network. In order to provide some insight, a descriptive error message has been added to let users know what is going on.
1) If the user sends their Playstation into rest mode, the system will fail to get any data from the Playstation once. This results in the error getting logged, but the message reassures them that it only matters if the error continues to flood the log. See below of an example where the PS5 was sent into rest mode, the error was logged (due to stdout being temporarily empty), and then info started flowing again.
2 If the Playstation is completely powered off or unreachable,
stdout
will always be empty, so, the descriptive error message will continue to get logged. See below:Related Issues