Giter Club home page Giter Club logo

airport-express-status's Introduction

Airport Express Status

Trivial Python Rest API server that does one thing: give it the hostname/ip of a airport express and it'll tell you if it's currently receiving an Airplay stream.

No external dependencies.

Why does this even exists

I needed a way to find out if my Airport Express was receiving Airplay so I could automatically turn on my receiver and switch to its toslink input.

The Airport Express do have a HTTP API but it speaks Plist, a binary format that's not readily readable for most software.

Hence this little piece of server that requests the status of the Airport Express, extracts and decode the Airplay status and reports it back in JSON.

Usage

Home Assistant OS

Add repository and install.

Docker

$ docker build . --build-arg BUILD_FROM=alpine --no-cache --tag airport-express-status
$ docker run -p 8000:8000 airport-express-status python3 ./api.py
$ curl localhost:8000/<airport express hostname or IP>
{"Status": true, "StatusCode": 200}

Home Assistant

Create a binary sensor.

binary_sensor:
  - platform: rest
    name: Airport Express Airplay Status
    resource: http://localhost:8000/airport.home.arpa # or http://airport-express-status:8000/airport.home.arpa  for home assistant OS
    scan_interval: 30
    value_template: "{{ value_json.Status }}"

Use it in an automation:

  - alias: ๐Ÿ”ˆ Switch on receiver if airplay is active
    trigger:
      platform: state
      entity_id: binary_sensor.airport_express_airplay_status
      to: 'on'
    action:
      - service: media_player.turn_on
        entity_id: media_player.yamaha_receiver
      - service: media_player.select_source
        entity_id: media_player.yamaha_receiver
        data:
          source: 'AV4'

airport-express-status's People

Contributors

orrpan avatar reefab avatar

Stargazers

 avatar

Forkers

phaseone

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.