Switch for Playstation 4

Hey Guys,

I have been trying to set this up and am pretty close to doing so but I’m stuck (at probably the easiest part) and just cant wrap my head around it.

My question is about the 2 input_select files. First question is do they need to be completely separate? When I tried setting it up as described it errors out on me. Here is my setup:

Configuration

input_select: !include input_select.yaml

Input_Select

- !include config/choose_game.yaml
- !include config/choose_id.yaml

When I set it up like above I get the following in my log.

Home-Assistant.log

17-03-07 14:02:04 ERROR (MainThread) [homeassistant.bootstrap] Invalid config for [input_select]: expected a dictionary for dictionary value @ data['input_select']. Got [OrderedDict([('input_select', OrderedDict([('choose_game', OrderedDict([('name', 'Play Game'), ('options', ['Choose Game']), ('initial', 'Choose Game')]))]))]), OrderedDict([('input_select', OrderedDict([('choose_id', OrderedDict([('name', 'Play ID'), ('options', ['empty']), ('initial', 'empty')]))]))])]. (See /home/homeassistant/.homeassistant/configuration.yaml, line 62). Please check the docs at https://home-assistant.io/components/input_select/
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          17-03-07 14:02:04 ERROR (MainThread) [homeassistant.components] Testing configuration at /home/homeassistant/.homeassistant

I went off the same structure I had set up with my automations i.e. !include. This is obviously not correct and need to know how to set up the two input_select.yaml files with my configuration.

Thanks

@djkmod83 I think the easiest way is to create a folder inside the config folder. For example Inputselects.
So then you have the folder config/inputselects/
Then you place the choose_game.yaml and choose_id.yaml in that inputselects folder.

and in your configuration you change
input_select: !include input_select.yaml
into:
input_select: !include_dir_merge_named config/inputselects/

This will take any .yaml from the inputselects folder and consider it an input_select. So if you need more input_selects in the future you can just add another yaml file to it.

Ha, I knew it would be easy. Worked like a charm

Thanks Mister!

1 Like

If I run the ps4-waker command from my pi user it will work. If I use it from home assistant Ill get an error. I added:

# User privilege specification
root    ALL=(ALL:ALL) ALL
homeassistant    ALL=(ALL:ALL) ALL

Stil not working for me, any idea?

Got it fixed by moving the credentials file into the HASS env. Thanks to the posters above.

I am having an issue running the add-current-game script from within HA. Here is what I have in the scripts file:

alias: 'Add Current Game'
sequence:
  - service: shell_command.add_current_game

I installed HA via the AiO script:
The file is executable
I have added user homeassistant to /etc/sudoers group as described above
I am able to run sudo /scriptpath from the console and it works (as pi user)

I would like to be able to click the activate button from within HA to add the current game. Could anyone provide some insight? Share working scripts/automations?

Thanks

Sorry,

Here is my shell_command:

add_current_game: "sudo /home/pi/Documents/Scripts/add-current-game.sh"

I have tried with both single and double quotes as well as no quotes. Have also tried with and without sudo

Oke we need to achieve that the script will run from the console (as the hass user) Then it also will work when it is assigned to a button in HA.

For now, a reason why it isn’t working i can think of is that the ownership of the add_current_game file is pi and HA can’t execute it as it is running as the hass or home-assistant user. (i run the shell command like this add_current_game: "/home/pi/Documents/myownscripts/ps4/add-current-game" )

So in your case maybe changing ownership helps. Like this:
sudo chown hass /home/pi/Documents/Scripts/add-current-game.sh
or (depending on the username where HA is running)
sudo chown homeassistant /home/pi/Documents/Scripts/add-current-game.sh

I forgot to mention that I did try this before, both in the location above and moving it inside the homeassistant folder to /shell_scripts. I have switched to the homeassistant account by running sudo su -s /bin/bash homeassistant.

This is what i get when trying it with and without sudo and with and without the “.sh” at the end:

We trust you have received the usual lecture from the local System
Administrator. It usually boils down to these three things:

    #1) Respect the privacy of others.
    #2) Think before you type.
    #3) With great power comes great responsibility.

[sudo] password for homeassistant:

Now, I am no expert when it comes to linux and dont want to go making changes to the homeassistant account unless i know im doing it right. I suppose this is why it is not working? I have no idea what the homeassistant password is. Is there a way i can change it without breaking anything?

Hi i think i know why it isn’t working. I forgot a step… after editing the sudoers file.
It’s explained in this post.

So it comes down to doing this:

cd /etc/sudoers.d
sudo nano 010_homeassistant-nopasswd

In this file copy the following line
homeassistant ALL=(ALL) NOPASSWD: ALL

and close it with ctrl + X, then Y then press Enter.

Its working like a charm to turn on/off the playstation but the status is always on off? any idea what it could be?

1 Like

What are you using for the command state?

command_state: 'nc -z -w 5 192.168.1.21 9295'

Yes exactly :slight_smile: command_state: ‘nc -z -w 5 192.168.1.4 9295’

and you did also install it netcat?

sudo apt-get install netcat

Yes, but it didnt change

hmm i can’t of anything right now. you have set your ps4 to use a static ip adress right?

I did aswel, going to recheck everything :slight_smile: thanks for the help

okay maybe you can post what the output is if you run the command from the console if ps4 is on and off. maybe that will give some insight.

edit: when i use it it has no output.

Have you tried executing the command with full path to netcat like this?
/bin/nc -z -w 5 192.168.1.4 9295

No I didnt but I will try the full path to see if it’s working :slight_smile: