Yes, obviously iTunes needs to be runningā¦ Try to start it up and then see if you can see the itunes-api server.
Ok, now, every time I start the mac it starts up itunes and itunes server.
This is my config:
- platform: itunes
name: iTunes
host: http://192.168.178.75
#ā¦ if i write only host: 192.168.178.75 she donāt work
port: 8181
the tunes, however, remains always offline. I do not see the play button
I have to add some other rtiga to see my playlists?
If itās working, you can go to http://192.168.178.75:8181/playlists and it will show you a list of all your playlists in JSON format. Then you know itunes-api is working and you have a problem on the homeassistant config side.
My config is here if you want to see how I did in on hass side.:
I wouldnāt try doing playlists first from hass, they are not easy. Just see if you can get play/next, etc working, then we will work on playlist buttons (I have them in my config).
Try doing just this, itās all I needed to get 8 airplay speakers and my iTunes library to show up with all features:
media_player:
- platform: itunes
host: 192.168.178.75
Yeah that doesnāt look good. Probably failed to connect to iTunesā¦ You will want to make sure it starts after iTunes startsā¦ Itās good to start it with script/server so you can see the log output and what happens immediately. Once you have it working with script/server, then you can try to have it autostart.
Forget about forever for now, I wasnāt able to get it to workā¦ Just run script/server and see what happens. Make sure iTunes is running.
Ok. Tell me at least which version operating system you are on
Iām on 10.11 (El Capitan). I hope it didnāt break in later versions as Iām about to upgrade.
I solved.
I had so many problems because I was trying an installation on lion, now Iāve updated to High sierra itās all working out great. However it was not so simple. I will explain my procedure hoping that it will serve someone.
First you need to install node for osx
after, execute the command in the terminal:
sudo / usr / local / bin / npm install forever -g
then copy the itunes api master folder into documents and from the terminal:
cd Documents / itunes-api-master
./script/server
./script/install
Wow I didnāt expect anyone would be on an older version than me ;-). Glad you got it going.
Now that Iāve configured itunes, could you explain how to create a playlist?
Well, you create the playlists in iTunes like you normally would. To access those playlists from HomeAssistant, I have configured mine with some buttons that you can press to choose the playlist you want in the lovelace UI.
You can read about it here:
I recommend you do it the way I showed my second post from that link rather than the first.
I think there also might way to do it by embedding an input select into the mini-media-player card but I havenāt gotten around to trying that method yetā¦
Getting proper on/off status is much harderā¦ Itās on my list of things to do but is never high enough priority to get to. You are welcome to try. With pushbuttons like I use in my example, itās much less noticeable, because when you press the button, the playlist starts and thatās it.
Hi, I was able to get a playlist played/stop. I also configured the shuffle.
Now I would like to understand how to get the status update? If I activate the shuffle function from itunes, I would like it to also activate in HA.
My configuration is:
-
platform: command_line
switches:
shuffle:
friendly_name: Shuffle Mode
command_on: ācurl -X PUT http://192.168.178.41:8181/shuffle -d mode=onā
command_off: "curl -X PUT http://192.168.178.41:8181/shuffle -d mode=off " -
platform: command_line
switches:
anastacia:
friendly_name: Anastacia
command_on: ācurl -X PUT http://192.168.178.41:8181/playlists/anastacia/playā
command_off: ācurl -X PUT http://192.168.178.41:8181/stopācommand_state: "curl -X GET http://192.168.178.41:8181/anastacia" value_template: '{{ value_json["playlist"] == "play" }}'
customize
switch.shuffle:
icon: mdi:shuffle
assumed_state: false
switch.anastacia:
icon: mdi:library-music
assumed_state: false
Thatās why this thread was startedā¦ Thereās no easy way that I can tell to make shuffle work properly with status,etc. They need to fix it in the componentā¦ You can go vote for the feature request:
Hey, let me ask you, do you have it starting automatically on boot with forever? I got a new machine running on 10.14, but I still get the same permission errors when running script/install as I got on my old machine and it wonāt start on boot. Does this work for you?
scusa per il ritardo
Per Yosemite usa questo comando
sudo / usr / local / bin / npm installa -g per sempre
Dopo aver inserito
cd Documents / itunes-api-master
CosƬ sarĆ :
cd Documents / itunes-api-master
sudo / usr / local / bin / npm installs -g per sempre
./script/bootstrap.
cd Documents / itunes-api-master
./script/install
In caso di permesso Deneid
script / server
sudo script / installazione sudo
Per verificare lāoperazione
LOCALIP: 8181
yes, he starting automatically on boot with forever
Alright, so I finally got around to making a shuffle that properly reports the state of the shuffle on the media player and turns it on/off when toggled. If you change the state from outside hass, it takes 5-10 seconds to sync, thatās just how long it takes itunes-api to do it. A better way to do this might be with a RESTful switch, but I got tired of banging my head against that wall and did it this way.
Add the following to configuration.yaml:
the commands that turn shuffle off and on:
rest_command:
shuffle_on:
url: "http://[YOUR_ITUNES-API_SERVER_IP]:8181/shuffle"
method: put
content_type: "application/x-www-form-urlencoded"
payload: "mode=songs"
shuffle_off:
url: "http://[YOUR_ITUNES-API_SERVER_IP]:8181/shuffle"
method: put
content_type: "application/x-www-form-urlencoded"
payload: "mode=off"
the input boolean you will use as a switch in your ui:
input_boolean:
itunes_shuffle:
name: "Shuffle"
icon: mdi:shuffle-variant
The automations which make sure it displays the correct status if someone changes it in iTunes or Remote rather than via homeassistant:
automation:
- id: turn_on_shuffle_from_input_boolean
alias: turn_on_shuffle_from_input_boolean
initial_state: 'true'
trigger:
platform: state
entity_id: input_boolean.itunes_shuffle
from: 'off'
to: 'on'
condition:
condition: template
value_template: '{{ state_attr("media_player.itunes", "shuffle") == false}}'
action:
service: rest_command.shuffle_on
- id: turn_off_shuffle_from_input_boolean
alias: turn_off_shuffle_from_input_boolean
initial_state: 'true'
trigger:
platform: state
entity_id: input_boolean.itunes_shuffle
from: 'on'
to: 'off'
condition:
condition: template
value_template: '{{ state_attr("media_player.itunes", "shuffle") == true}}'
action:
service: rest_command.shuffle_off
- id: sync_shuffle_input_boolean_to_external_on
alias: sync_shuffle_input_boolean_to_external_on
initial_state: 'true'
trigger:
- platform: state
entity_id: media_player.itunes
- platform: homeassistant
event: start
condition:
condition: and
conditions:
- condition: template
value_template: '{{ state_attr("media_player.itunes", "shuffle") == true}}'
- condition: state
entity_id: input_boolean.itunes_shuffle
state: 'off'
action:
service: input_boolean.turn_on
data:
entity_id: input_boolean.itunes_shuffle
- id: sync_shuffle_input_boolean_to_external_off
alias: sync_shuffle_input_boolean_to_external_off
initial_state: 'true'
trigger:
- platform: state
entity_id: media_player.itunes
- platform: homeassistant
event: start
condition:
condition: and
conditions:
- condition: template
value_template: '{{ state_attr("media_player.itunes", "shuffle") == false}}'
- condition: state
entity_id: input_boolean.itunes_shuffle
state: 'on'
action:
service: input_boolean.turn_off
data:
entity_id: input_boolean.itunes_shuffle
Hello my dearest friend, it is very kind of you to share this news. Iām really grateful to you. Iām not at home right now and canāt try your code. When I return in October, I will finally be able to enjoy this function. Thanks again!!!