Git Product home page Git Product logo

sonos-adapter's Introduction

sonos-adapter

Sonos speaker adapter for WebThings gateway.

Bridges the Sonos API to the gateway so it can interact with Sonos speakers.

Usage

Normally you will just want to install this from the add-ons list provided by the gateway.

Credits

This add-on was originally created by Martin Giger (@freaktechnik).

sonos-adapter's People

Contributors

dependabot[bot] avatar freaktechnik avatar mrstegeman avatar tim-hellhake avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

sonos-adapter's Issues

Setting URL

I can't set the URL from Rules or Macros it appears to be an action not a variable?

How to use this?

Could you explain how this adapter works?

Should I add a thing in the gateway to see my speaker?

Crash while pairing

2020-01-19 22:29:16.146 ERROR  : sonos: dgram.js:638
2020-01-19 22:29:16.147 ERROR  : sonos:     throw new errors.Error('ERR_SOCKET_DGRAM_NOT_RUNNING');
2020-01-19 22:29:16.148 ERROR  : sonos:     ^
2020-01-19 22:29:16.149 ERROR  : sonos:
2020-01-19 22:29:16.149 ERROR  : sonos: Error [ERR_SOCKET_DGRAM_NOT_RUNNING]: Not running
2020-01-19 22:29:16.150 ERROR  : sonos:     at Socket._healthCheck (dgram.js:638:11)
2020-01-19 22:29:16.151 ERROR  : sonos:     at Socket.close (dgram.js:516:8)
2020-01-19 22:29:16.152 ERROR  : sonos:     at DeviceDiscovery.destroy (/home/pi/.mozilla-iot/addons/sonos-adapter/node_modules/sonos/lib/deviceDiscovery.js:82:15)
2020-01-19 22:29:16.152 ERROR  : sonos:     at SonosAdapter.cancelPairing (/home/pi/.mozilla-iot/addons/sonos-adapter/adapter.js:86:30)
2020-01-19 22:29:16.153 ERROR  : sonos:     at AddonManagerProxy.onMsg (/home/pi/mozilla-iot/gateway/node_modules/gateway-addon/lib/addon-manager-proxy.js:316:17)
2020-01-19 22:29:16.154 ERROR  : sonos:     at IpcSocket.onData (/home/pi/mozilla-iot/gateway/node_modules/gateway-addon/lib/ipc.js:171:10)
2020-01-19 22:29:16.154 ERROR  : sonos:     at emitOne (events.js:116:13)
2020-01-19 22:29:16.155 ERROR  : sonos:     at Socket.emit (events.js:211:7)
2020-01-19 22:29:16.156 ERROR  : sonos:     at addChunk (_stream_readable.js:263:12)
2020-01-19 22:29:16.156 ERROR  : sonos:     at readableAddChunk (_stream_readable.js:250:11)
2020-01-19 22:29:16.161 INFO   : Plugin: sonos-adapter died, code = 1 restarting after 0

Shouldn't use IP address to identify speaker

I think that showing the IP address as a property is fine, but it shouldn't be the way to identify the speaker. If the IP address changes, then I need to remove and re-add the speaker.

I think that it should use the serial number or Mac Address of the speaker as the unique identifier.

add IP address to Sonos config if can't be found?

Although I didn't change anything on my local network, for some reason the Sonos speaker went "offline" from yesterday to today. I tried power cycling all sorts of things, including the speaker. I disabled/enabled the Sonos add-on. The speaker IS connected to my Wi-Fi router, and I can control it from my smartphone, and I can play streamed Internet radio through it, using my smartphone as controller. I tried removing it from the gateway Things page, since I have needed to do that anytime my Google Home receives a new IP address. However, my WebThings Gateway doesn't find the Sonos at all anymore during a scan. The log shows:

2019-08-27 11:17:11.595 ERROR  : sonos: ReferenceError: URL is not defined
2019-08-27 11:17:11.597 ERROR  : sonos:     at zonesArray.forEach (/home/pi/.mozilla-iot/addons/sonos-adapter/node_modules/sonos/lib/sonos.js:369:19)
2019-08-27 11:17:11.599 ERROR  : sonos:     at Array.forEach (<anonymous>)
2019-08-27 11:17:11.600 ERROR  : sonos:     at Sonos.getAllGroups (/home/pi/.mozilla-iot/addons/sonos-adapter/node_modules/sonos/lib/sonos.js:360:14)
2019-08-27 11:17:11.602 ERROR  : sonos:     at <anonymous>
2019-08-27 11:17:11.604 ERROR  : sonos:     at process._tickCallback (internal/process/next_tick.js:189:7)```

tie "playing" property to an on/off property to toggle music from main icon

Instead of having to open the icon detail to play music, it would be nice if the Sonos Thing Description (TD) were defined as an on/off switch:
https://iot.mozilla.org/schemas/#OnOffSwitch

Further enhancement idea is to include the ToggleAction, which would stop playing or start playing based on toggling the current "playing" state.

On the Mozilla schema side, I think we need to add a media player schema and capability definition, that incorporates the properties, actions, and events of this add-on and several others that represent similar capability devices.

Sonos adapter seems to have stopped working

Whenever the sonos adapter starts, I now get these errors:

2019-04-04 10:32:37.421 INFO   : sonos: Loading add-on for sonos-adapter from /home/dhylands/moziot/.mozilla-iot/addons/sonos-adapter
2019-04-04 10:32:38.267 ERROR  : sonos: TypeError: Cannot read property 'ZoneGroup' of undefined
2019-04-04 10:32:38.268 ERROR  : sonos:     at GetZoneGroupState.then (/home/dhylands/moziot/.mozilla-iot/addons/sonos-adapter/node_modules/sonos/lib/services/ZoneGroupTopology.js:46:76)
2019-04-04 10:32:38.268 ERROR  : sonos:     at <anonymous>
2019-04-04 10:32:38.268 ERROR  : sonos:     at process._tickCallback (internal/process/next_tick.js:189:7)
2019-04-04 10:32:38.501 ERROR  : sonos: TypeError: Cannot read property 'ZoneGroup' of undefined
2019-04-04 10:32:38.501 ERROR  : sonos:     at GetZoneGroupState.then (/home/dhylands/moziot/.mozilla-iot/addons/sonos-adapter/node_modules/sonos/lib/services/ZoneGroupTopology.js:46:76)
2019-04-04 10:32:38.502 ERROR  : sonos:     at <anonymous>
2019-04-04 10:32:38.502 ERROR  : sonos:     at process._tickCallback (internal/process/next_tick.js:189:7)
2019-04-04 10:32:38.643 ERROR  : sonos: TypeError: Cannot read property 'ZoneGroup' of undefined
2019-04-04 10:32:38.644 ERROR  : sonos:     at GetZoneGroupState.then (/home/dhylands/moziot/.mozilla-iot/addons/sonos-adapter/node_modules/sonos/lib/services/ZoneGroupTopology.js:46:76)
2019-04-04 10:32:38.644 ERROR  : sonos:     at <anonymous>
2019-04-04 10:32:38.645 ERROR  : sonos:     at process._tickCallback (internal/process/next_tick.js:189:7)

I have 3 speakers, which is why I think it shows up 3 times.

can't see volume level in detailed Sonos player view

Not sure this is an add-on issue or a WebThings UI issue. But whether I zoom in/out in my browser, I can't see the volume level of the Sonos player because the "Group/Ungroup" label is always on top, and blocking it. Possible short-term workarounds:

  • change label "Group/Ungroup" to "Un/group" so it doesn't wrap. (or remove that property for now? I'm not sure what it does...)
  • change the order of the labels so that Volume is not next to "Group/Ungroup" (something that won't block its view)

Longer-term UI option:

  • change labels to be transparent, rather than white on blue background (then could likely see the volume value even if overlapping with the label)

Screen Shot 2020-12-06 at 9 25 27 PM

Device description is broken on Gateway 1.0.0

2020-11-30 09:05:59.445 ERROR  : Invalid message received: {
  "messageType": 8192,
  "data": {
    "adapterId": "SonosAdapter",
    "device": {
      "id": "78-28-CA-FA-56-C0:G",
      "title": "Kitchen",
      "@context": "https://webthings.io/schemas",
      "@type": [],
      "description": "",
      "properties": {
        "volume": {
          "name": "volume",
          "value": 15,
          "visible": true,
          "title": "Volume",
          "type": "integer",
          "@type": "LevelProperty",
          "unit": "percent",
          "links": []
        },
        "playing": {
          "name": "playing",
          "value": false,
          "visible": true,
          "title": "Playing",
          "type": "boolean",
          "@type": "BooleanProperty",
          "links": []
        },
        "shuffle": {
          "name": "shuffle",
          "value": false,
          "visible": true,
          "title": "Shuffle",
          "type": "boolean",
          "@type": "BooleanProperty",
          "links": []
        },
        "repeat": {
          "name": "repeat",
          "value": "None",
          "visible": true,
          "title": "Repeat",
          "type": "string",
          "@type": "EnumProperty",
          "enum": [
            "None",
            "One",
            "All"
          ],
          "links": []
        },
        "crossfade": {
          "name": "crossfade",
          "value": true,
          "visible": true,
          "title": "Crossfade",
          "type": "boolean",
          "@type": "BooleanProperty",
          "links": []
        },
        "track": {
          "name": "track",
          "visible": true,
          "title": "Track",
          "type": "string",
          "@type": "StringProperty",
          "readOnly": true,
          "links": []
        },
        "album": {
          "name": "album",
          "visible": true,
          "title": "Album",
          "type": "string",
          "@type": "StringProperty",
          "readOnly": true,
          "links": []
        },
        "artist": {
          "name": "artist",
          "visible": true,
          "title": "Artist",
          "type": "string",
          "@type": "StringProperty",
          "readOnly": true,
          "links": []
        },
        "progress": {
          "name": "progress",
          "value": 0,
          "visible": true,
          "title": "Progress",
          "type": "number",
          "@type": "LevelProperty",
          "links": []
        },
        "albumArt": {
          "name": "albumArt",
          "visible": true,
          "title": "Album art",
          "@type": "ImageProperty",
          "readOnly": true,
          "links": [
            {
              "mediaType": "image/png",
              "href": "/media/sonos/78-28-CA-FA-56-C0:G/album.png",
              "rel": "alternate"
            }
          ]
        },
        "muted": {
          "name": "muted",
          "value": false,
          "visible": true,
          "title": "Muted",
          "type": "boolean",
          "@type": "BooleanProperty",
          "links": []
        }
      },
      "actions": {
        "next": {
          "title": "Next",
          "description": "Skip current track and start playing next track in the queue"
        },
        "prev": {
          "title": "Previous",
          "description": "Play previous track in the queue"
        },
        "stop": {
          "title": "Stop",
          "description": "Stop current playback"
        },
        "playUri": {
          "title": "Play URI",
          "description": "Play the music from the given URI",
          "input": {
            "type": "object",
            "properties": {
              "uri": {
                "type": "string"
              }
            }
          }
        },
        "group": {
          "title": "Group/Ungroup",
          "description": "Group Sonos players",
          "input": {
            "type": "object",
            "required": [
              "Bel’s Room",
              "Loft"
            ],
            "properties": {
              "Bel’s Room": {
                "type": "boolean",
                "default": false
              },
              "Loft": {
                "type": "boolean",
                "default": false
              }
            }
          }
        }
      },
      "events": {},
      "links": [],
      "pin": {
        "required": false
      },
      "credentialsRequired": false
    },
    "pluginId": "sonos-adapter"
  }
}
2020-11-30 09:05:59.445 ERROR  : Validation error: [
  {
    "keyword": "required",
    "dataPath": ".data.device.properties['albumArt']",
    "schemaPath": "#/required",
    "params": {
      "missingProperty": "type"
    },
    "message": "should have required property 'type'"
  }
]

The property play/pause is confusing to me.

I think that the property should just be called playing. Since the property is a boolean, I think it should just be called "Playing", since a value of true means playing, and a value of false means paused.

Or perhaps it should use an enum instead, with playing and paused as the 2 values of the enum.

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.