GithubHelp home page GithubHelp logo

bacwolf / netradio Goto Github PK

View Code? Open in Web Editor NEW

This project forked from giachello/netradio

0.0 1.0 0.0 144 KB

Netradio adds Web Streaming Radio support to Home Assistant. You can configure any number of web streams and they will show up as Media Sources that you can then use to playback in media players that support such sources, like Google Chromecast.

Python 44.69% JavaScript 55.31%

netradio's Introduction

NetRadio component for Home Assistant

This is a new Media_source for the Home Assistant home automation framework, that allows you to define a set of web radio stations (e.g., http://streams.greenhost.nl:8080/jazz) and then play them from a service call or by using a custom Lovelace card.

To install the Media Source component:

  1. Create a netradio folder inside the config/custom_components folder
  2. Copy \_\_init__.py, const.py, manifest.json, media_source.py, services.yaml to config/custom_components/netradio
  3. Add a configuration in your configuration.yaml file like this.
  • URL is the link to the audio stream.
  • Name is the user friendly name.
  • Icon is a link to a thumbnail image that will be shown in the browser and on the Lovelace card.
netradio:
  radios: 
    - url: 'http://streams.greenhost.nl:8080/jazz'
      name: Concertzender Jazz
    - url: 'http://icestreaming.rai.it/5.mp3'
      name: RAI Radio Classica
      icon: 'https://cdn-profiles.tunein.com/s17167/images/logoq.png?t=153677'
    - url: 'http://stream.srg-ssr.ch/m/rsc_de/mp3_128'
      name: Radio Swiss Classic
    - url: 'http://wshu.streamguys.org/wshu-classical-mp3'
      name: WSHU
    - url: 'https://streams-pfs.kqed.org/kqedradio-pfs?listenerid=cd0bc9c32b46bbe87b06480cabac29f7'
      name: KQED
    - url: 'http://kzsu-streams.stanford.edu/kzsu-1-256.mp3'
      name: KZSU

You can find a lot of network radios in directories like this one: https://www.radio-browser.info/

For added privacy, you can download the icons into a icons directory inside <config>/www and then link those icons as shown below.

netradio:
  radios: 
    - url: 'http://streams.greenhost.nl:8080/jazz'
      name: Concertzender Jazz
      icon: 'http://hassio.local:8123/local/icons/cz.png'
    - url: 'http://icestreaming.rai.it/5.mp3'
      name: RAI Radio Classica
      icon: 'http://hassio.local:8123/local/icons/rai.png'

To install the Custom Lovelace card (optional):

Card Screenshot

  1. Copy netradio-card.js to <config>/www directory
  2. Add netradio-card.js to your Lovelace resources (you need to activate advanced mode first), by going to Configuration->Lovelace Dashboards ->Resources->Add resource
  3. add "/local/netradio-card.js" as a Javascript Module
  4. Add the card in your Lovelace UI by using the following configuration example (replace your media player name):
type: 'custom:netradio-card'
entities:
  - media_player.bang_olufsen

How to use

You can play the radios from the Custom Lovelace Card, the Media Browser panel, or by calling a service:

Media browser

Media Browser Screenshot

Service calls

There are three service calls

netradio.start_radio

Starts playing a given radio station, with parameters:

entity_id - the media player to play the radio
radio_index - the number of the radio you want to play, starting from 0, in the list above.

Service Call Screenshot

netradio.next_radio

Switches to the next radio in the list. Goes back to the first radio when you switch past the last one in the list.

{"entity_id": "media_player.bang_olufsen"}

netradio.prev_radio

Switches to the previous radio in the list.

{"entity_id": "media_player.bang_olufsen"}

Fixing Slow Start Time with Chromecast

If you use Chromecast as a media player for your radios, you may experience that some streams take a long time to start playing (up to 30 seconds or more). This is a bug in Chromecast that Google didn't fix despite bug reports. However there is a workaround: after starting the radio with the netradio.start_radio service, wait 2 or 3 seconds and then call the media_player.media_play service, as shown below. That will kick the Chromecast to actually start playing immediately.

image

netradio's People

Contributors

giachello avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.