Project

lex-sonos

0.0
No release in over 3 years
Used to connect Legion to Sonos speakers
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
 Dependencies

Runtime

 Project Readme

lex-sonos

Sonos speaker control for LegionIO. Control Sonos devices from within Legion task chains via the node-sonos-http-api bridge (or compatible local HTTP API).

Installation

gem install lex-sonos

Or add to your Gemfile:

gem 'lex-sonos'

Requirements

  • Ruby >= 3.4
  • LegionIO framework
  • Sonos speakers on local network
  • A local Sonos HTTP API bridge (e.g. node-sonos-http-api) running at http://localhost:5005 (configurable)

Usage

Standalone Client

require 'lex-sonos'

client = Legion::Extensions::Sonos::Client.new(url: 'http://localhost:5005')

# Player controls
client.play(room: 'Living Room')
client.pause(room: 'Living Room')
client.stop(room: 'Living Room')
client.next_track(room: 'Living Room')
client.previous_track(room: 'Living Room')
client.volume(room: 'Living Room', level: 50)
client.mute(room: 'Living Room')

# Zone information
client.list   # => { zones: [...] }
client.get(room: 'Living Room')  # => { state: { playbackState: 'PLAYING', ... } }

# Favorites
client.list   # => { favorites: [...] }
client.play(room: 'Living Room', name: 'My Radio Station')

Runners

Module Methods
Runners::Player play, pause, stop, next_track, previous_track, volume, mute
Runners::Zones list, get
Runners::Favorites list, play

Configuration

The default base URL is http://localhost:5005. Override it when constructing the client:

client = Legion::Extensions::Sonos::Client.new(url: 'http://192.168.1.100:5005')

License

MIT