I am trying to make a command line sensor from the output of this: https://github.com/iharosi/ps5-wake
My best guess is that because after running the command it will say
Scanning...
(with cycling periods) before it displays the result, and that they may somehow be preventing it from getting the data
I always get “command failed” (or “Empty reply found when expecting JSON data”) and have tried countless variations/locations, value_templates etc… the sensor just comes up as Unknown in Dev/Tools/States
The result of the command is usually:
Device found: PS5-952 [PS5/MY_PS5_MACID]: Home Screen
or
Device found: PS5-952 [PS5/MY_PS5_MACID]: Standby
or
No Device found.
also, there is an option for JSON output but that is preceded by the “Device found: PS5-952 [PS5/MY_PS5_MACID]: Standby”, then the curly braces and json… So I’m not sure if that is why that doesn’t work either…
Device found: PS5-952 [PS5/MY_PS5_MACID]: Home Screen
{"code":200,"host_id":"My_ps5_mac_id","host_name":"PS5-952","host_type":"PS5","running_app_name":null,"running_app_titleid":null,"version":null,"host_request_port":997,"timestamp":1608069706,"fingerprint":"b404f4238632909ee6657b1685830a5"}
My next best guess is that I may have to make some sort of Python Script to get the data…
but here is my last configs for the sensor/test sensor… They may not be in a proper state at the moment because I have tried 600 variations of template/value_template/json etc… I am just hoping I am missing some super simple way to get the data/wait for the output before trying to get the data etc…
- platform: command_line
name: "PlayStation 5"
command: "/srv/homeassistant/bin/ps5-wake -vP -H 192.168.1.214"
value_template: {{ value }}
# value_template: >-
# {%- if value == "No Device found." -%}
# Off
# {%- elif value == "Device found: PS5-952 [PS5/MY_PS5_MACID]: Home Screen" -%}
# On
# {%- elif value == "Device found: PS5-952 [PS5/MY_PS5_MACID]: Standby" -%}
# Standby
# {% else %}
# WTF-POOP
# {%- endif -%}
scan_interval: 20
command_timeout: 30
- platform: command_line
name: "PlayStation 5 Test"
command: "/srv/homeassistant/bin/ps5-wake -vP -H 192.168.1.214 -j"
json_attributes:
- code
- host_id
- host_name
- host_type
- running_app_name
- running_app_titleid
- version
- host_request_port
- timestamp
- fingerprint
value_template: {{ value_json.code }}
command_timeout: 30
scan_interval: 20