ynot123 / LMS_Controls

Control your Logitech / Squeezeserver players from Home Assistant and Google Home
62 stars 15 forks source link

Implicit Intents and HA GUI for linking players #2

Closed ynot123 closed 6 years ago

ynot123 commented 6 years ago

User ekkesa suggested a few new features which will be implemented in the near future:

Hey Google, ask LMS Controls to play album Breakfast in America by Supertramp in the kitchen with shuffle on

Once completed, I will update the original posts in the HA and squeezebox forums and of course the code here.

Cheers, Ynot.

ekkesa commented 6 years ago

This looks awesome! I see you updated the code - I will replace the old stuff tomorrow evening with the new code and test drive it... I will let you know!

ynot123 commented 6 years ago

Just realized I forgot to create a DF for syncing / unsyncing players. Will try to take care of that later next week. Thinking:

The player "kitchen" in the example above would be the master and uses the DF entity @lms_player and a new DF entity @lms_sync_player would be created containing the 5 sync able players.

Also a chunk of new code will be required in LMS_script.yaml to handle the requests. It should be pretty straight forward as the leg work is already done in the automation of the GUI.

I will let you know when that gets done. You can simply import the specific items (4 intents and 1 entity) into DF and update lms_script.yaml to accomplish this.

Ynot

ekkesa commented 6 years ago

Hi,

I updated the stuff and it works great - found one bug, but I believe it is lovelace related - The dropdown to choose the action e.g. play playlist sometimes come up blank.

I made a few notes, while installing but left the little piece of paper at my office I will capture it Monday morning. Nothing major that I found, and for interest sake it took about 35 min to set up from scratch.

Looking forward to the syncing of devices - on th DF side perhaps also something like add kitchen to media room, remove kitchen from mediaroom. Not sure if it will interfere with other commands using the "add" and "remove"

ekkesa commented 6 years ago

I see these in my logs - not sure if its related to the changes yet.

components/sensor/template.py (WARNING) "Could not render template Master Speaker, the state is unknown"

ynot123 commented 6 years ago

Thanks, the DF for linking will likely be "sync or link" so as not to interfere with other functions.

Haven't experienced any Lovelace issues as far as I am aware (and I use it all the time) but will look for it. It should always return to ____ when the command gets issued. Make sure you don't have any blank elements listed in the options section of your input_select.lms_command in the configuration.yaml file.

Finally, I don't get the error listed above so perhaps its something in your setup. You would need to do more troubleshooting to figure out when it happens exactly. If its related to the LMS Controls app and I can duplicate it, likely can fix it too. Let me know.

Thanks for your feedback and have a good weekend. Ynot

ekkesa commented 6 years ago

I just updated HA - I see lovelace changed the tap-action from "turn-on" to "toggle"

ynot123 commented 6 years ago

That is correct. Same for repeat. Lovelace simply toggles the input_boolean from on to off (or vice versa) and the script looks at the input_boolean status to set the shuffle or repeat modes. I've had it that way for sometime now.

ynot123 commented 6 years ago

Upgraded my HA installation last night and now see what you mean about tap action. Had to change them all to toggle to make it work. Will update that in the next little release.

Just testing the DF for sync / unsync (link / unlink) and should release it in the next day or two hopefully. It will consists of new DF, small update to the LMS script and the update to lovelace UI.

Shouldn't take more than 10 minutes to update hopefully.

I will await your notes as well in case there is something additional to add.

ekkesa commented 6 years ago

Hi, Here i the notes I took while setting it up:

  1. In DF, the on entity, lms_player, the yogastudio & family room is mixed/merged
  2. What will the process be if you want to go beyond the 5 speakers to sync?
  3. In the notes it states to use friendly names, e.g "Living Room Speaker" - This failed, i had to use living_room_speaker, which is the second part of media_player.living_room_speaker
  4. Type in this line of the readme.md : lms_playerX_sync input_boolean(s) need to be modified to contain the friendly names of the plyers you wish to have as sync destinations (upto 5 are allowed, more will need minor code modifications)
  5. Had to fiddle with some of the DF intents to accept "in the living room", for some reason it appended it to the radio station name.
  6. Total setup time was about 35min. Thanks for all your effort - This is really an awesome integration! Cheers
ynot123 commented 6 years ago

Thanks for the notes. I will updated the items as outlined below.

  1. In my case, the yogastudio and the family room are the same and used interchangeably.
  2. If you want to go beyond 5, need additional input booleans in configuration.yaml, add the additional triggers in the automation.yaml and script_lms_controls.yaml files to deal with the extras. Finally, update groups.yaml and ui-lovelace.yaml to display them in HA. I had thought five (5) was enough :). I actually have eight (8) devices some squeezeplayers, some UPNP, some SONOS and some CAST. .
  3. You're quite right, it's not friendly name it's the entity name (same as in the DF entity and the input_select.lms_player). I will update that in the README.md file(s).
  4. I've had a bit of trouble with some DF skills as well. The best answer I found is to open the DF console session, choose training, find the request that failed and train it (asing the proper request and ensure the variable was caught) and approve. This will make it work next time.

Glad to hear you're using it, makes the work worth while. Enjoy and thanks for the help and suggestions. If you're good I will close this item now.

Ynot.

ekkesa commented 6 years ago

Thx! I use it extensively - My HASS started out just to control a few led lights where my wife didn't want switches visible and it quickly escalated into a beast of another colour with main focus on AV stuff... Started off on openhab, and had something similiar to this, much more crude though. So glad I spotted this in a forum somewhere - believe it was slimdevices forum.

I'll try and beef up the sync device amount without breaking it, currently on 5 media_players, but soon it will be closer to 8 or 9 depending if I pimp the garage.

Again - Thx for all the effort!

ekkesa commented 6 years ago

I hacked in a radio station cheat into the UI. Just thought I'll share it if you want to incorporate it. It is easily customisable.

I added an input_select with the radio station names, and added a script which launches on its change.

INPUT SELECT

radio_station:
  name: 'Select Radio Station:'
  icon: mdi:radio
  initial: _____________________
  options:
    - _____________________
    - Jacaranda
    - Highveld 94.7
    - Impact
    - 702
    - RSG
    - Groot FM
    - Classic FM
    - Radio 538
    - Veronica
    - Sky Radio
    - SLAM! Hardstyle
    - Sleep Radio
    - Ambient Sleeping Pill
    - Radio Art - Sleep
    - Calm Radio - Sleep
    - Dinamo.FM Sleep

ADDED this line to the lovelace UI on the player

- input_select.radio_station

This is the script:

lms_cmd_play_radio2:
  alias:  "LMS command to play radio station"
  sequence:
    - service: media_player.volume_set
      data_template:
        entity_id: "media_player.{{states.input_select.lms_player.state}}"
        volume_level: '0.50'
    -  service: media_player.play_media
       data_template:
         entity_id: "media_player.{{states.input_select.lms_player.state}}"
         media_content_id: >
          {% if is_state("input_select.radio_station", "Jacaranda") %} http://opml.radiotime.com/Tune.ashx?id=s6410&formats=aac,ogg,mp3,wmpro,wma,wmvoice&partnerId=16&serial=2d444aedc36f4d5f2d3e7d45d67d7683
          {% elif is_state("input_select.radio_station", "Highveld 94.7") %} http://opml.radiotime.com/Tune.ashx?id=s6400&formats=aac,ogg,mp3,wmpro,wma,wmvoice&partnerId=16&serial=2d444aedc36f4d5f2d3e7d45d67d7683
          {% elif is_state("input_select.radio_station", "Impact") %} http://opml.radiotime.com/Tune.ashx?id=s6412&formats=aac,ogg,mp3,wmpro,wma,wmvoice&partnerId=16&serial=2d444aedc36f4d5f2d3e7d45d67d7683
          {% elif is_state("input_select.radio_station", "702") %} http://opml.radiotime.com/Tune.ashx?id=s25727&formats=aac,ogg,mp3,wmpro,wma,wmvoice&partnerId=16&serial=2d444aedc36f4d5f2d3e7d45d67d7683
          {% elif is_state("input_select.radio_station", "RSG") %} http://opml.radiotime.com/Tune.ashx?id=s143888&formats=aac,ogg,mp3,wmpro,wma,wmvoice&partnerId=16&serial=2d444aedc36f4d5f2d3e7d45d67d7683
          {% elif is_state("input_select.radio_station", "Groot FM") %} http://opml.radiotime.com/Tune.ashx?id=s8386&formats=aac,ogg,mp3,wmpro,wma,wmvoice&partnerId=16&serial=2d444aedc36f4d5f2d3e7d45d67d7683
          {% elif is_state("input_select.radio_station", "Classic FM") %} http://opml.radiotime.com/Tune.ashx?id=s24967&formats=aac,ogg,mp3,wmpro,wma,wmvoice&partnerId=16&serial=2d444aedc36f4d5f2d3e7d45d67d7683
          {% elif is_state("input_select.radio_station", "Radio 538") %} http://vip-icecast.538.lw.triple-it.nl:80/RADIO538_MP3
          {% elif is_state("input_select.radio_station", "Veronica") %} http://8543.live.streamtheworld.com/VERONICACMP3
          {% elif is_state("input_select.radio_station", "Sky Radio") %} http://8623.live.streamtheworld.com:80/SKYRADIOAAC_SC
          {% elif is_state("input_select.radio_station", "SLAM! Hardstyle") %} http://vip-icecast.538.lw.triple-it.nl/WEB17_MP3
          {% elif is_state("input_select.radio_station", "Sleep Radio") %} http://37.59.28.208:8722/stream
          {% elif is_state("input_select.radio_station", "Ambient Sleeping Pill") %} http://perseus.shoutca.st:8447/h
          {% elif is_state("input_select.radio_station", "Radio Art - Sleep") %} http://live.radioart.com/fSleep.mp3
          {% elif is_state("input_select.radio_station", "Calm Radio - Sleep") %} http://streams.calmradio.com/api/39/128/stream
          {% elif is_state("input_select.radio_station", "Dinamo.FM Sleep") %} http://channels.dinamo.fm/sleep-aac
          {% endif %}
         media_content_type: 'audio/mp4'