GithubHelp home page GithubHelp logo

b5r1oj0a9g / hassfeld Goto Github PK

View Code? Open in Web Editor NEW
7.0 1.0 4.0 122 KB

Module to integrate Teufel smart speakers (aka Raumfeld Multiroom) into https://www.home-assistant.io/.

License: GNU General Public License v3.0

Python 100.00%
home-assistant teufel raumfeld smart-speaker multiroom multiroom-audio

hassfeld's Introduction

hassfeld

Language grade Python

hassfeld is a module primarily aimed to integrated Teufel Smart Speaker (aka Raumfeld Multiroom) into https://www.home-assistant.io/. However, the design is not tailored to Home Assistant and can be used as a module to any Pyhton program to control the Teufel Smart Speaker. The module also provides corresponding asyncio methods.

Look how it is to use with asyncrhonous I/O:

import asyncio
import aiohttp
import hassfeld


async def main():
    host = "teufel-host.example.com"
    port = 47365
    session = aiohttp.ClientSession()
    raumfeld = hassfeld.RaumfeldHost(host, port, session=session)

    asyncio.create_task(raumfeld.async_update_all(session))
    await raumfeld.async_wait_initial_update()

    zone = ["Master Bedroom"]

    media_info = await raumfeld.async_get_media_info(zone)
    print(f"Media info: {media_info}")

    await session.close()


asyncio.run(main())

The use with blocking I/O was supported too but is currently broken:

import hassfeld
raumfeld_host = "teufel-host.example.com"
zone = [ "Living room", "Kitchen" ]
raumfeld = hassfeld.RaumfeldHost(raumfeld_host)
raumfeld.start_update_thread()
raumfeld.search_and_zone_play(zone, 'raumfeld:any contains "Like a Rolling Stone"')

Features

  • Management and snapshot of zones.
  • Search and play songs.

Install hassfeld by running:

python3 -m pip install hassfeld

Contribute

License

The project is licensed under the GNU General Public License v3 (GPLv3).

hassfeld's People

Contributors

b5r1oj0a9g avatar c-mellueh avatar drprofesq avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

hassfeld's Issues

Proposal: Control Teufel WAMP Settings through hassfeld

I'd like to propose extending the library so that settings can be changed and subscribed to through hassfeld. The Teufel main host exposes a WAMP interface (based on WebSocket) on port 55555, where settings can be changed and subscribed to, even if the setting is changed externally (e.g., from the infrared remote or from the app).

I think it would be nice to then expose a service in the Home Assistant integration where settings can be changed, e.g., in order to change the audio input for a specific scene.

I've written a Proof of Concept Script for Managing Teufel Settings through WAMP. It uses the autobahn Python library and asyncio. Here's an example output:

$ python3 main.py
Please enter the Teufel main host [10.0.0.21]: 
Please enter the Teufel WebSocket port [55555]: 

Available players:

    [UID "uuid:xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"] "Speaker Mobiler Lautsprecher" in room "Mobiler Lautsprecher"
    [UID "uuid:xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"] "Speaker Soundbar Wohnzimmer" in room "Soundbar Wohnzimmer"

Please choose a player UID [uuid:xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx]: uuid:xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx

Available settings:

    Setting "audio_input_source"
    Setting "sound_mode"
    Setting "display_max_brightness"
    Setting "led_brightness"
    Setting "auto_standby_delay"

Please choose a setting you want to subscribe to and/or change [audio_input_source]: audio_input_source
Please set a value for setting "audio_input_source": 3
Please set a value for setting "audio_input_source": 
    Received updated setting from the player. New value: 3
Please set a value for setting "audio_input_source": 2
Please set a value for setting "audio_input_source": 
    Received updated setting from the player. New value: 2

I can help with the implementation, but if you agree @B5r1oJ0A9G, I'd like to coordinate the changes with you.

async_upnp_client dependency not declared?

Hi,

I just tried to use the latest version of the teufel_raumfeld integration and found the following error in the logs:

Feb 28 17:56:51 ctrl hass[126208]: 2021-02-28 17:56:51 INFO (SyncWorker_0) [homeassistant.util.package] Attempting install of hassfeld==0.3.0-alpha
Feb 28 17:57:05 ctrl hass[126208]: 2021-02-28 17:57:05 ERROR (MainThread) [homeassistant.config_entries] Error occurred loading configuration flow for integration teufel_raumfeld: No module named 'async_upnp_client'

Manually doing a pip3 install async_upnp_client has resolved this problem.

I think async_upnp_client might be missing from the declared dependencies of this package, which currently only lists:

    install_requires=[
        "aiohttp",
        "requests",
        "upnpclient",
        "xmltodict",
    ]

Inconsistent naming of functions for Spotify SincleRoom mode.

Functions for zones (speakger groups) end with "_track" and functions for rooms without.

# grep -i "def async_\(room\|zone\)_\(next\|previous\)" hassfeld/__init__.py 
    async def async_zone_next_track(self, zone_room_lst):
    async def async_zone_previous_track(self, zone_room_lst):
    async def async_room_next(self, room):
    async def async_room_previous(self, room):

This breaks thier use in teufel_raumeld (B5r1oJ0A9G/teufel_raumfeld#49)

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.