JoDehli / PyLoxone

Python Loxone binding
Apache License 2.0
162 stars 40 forks source link

[Suggestion]: Populate devices for service calls #242

Closed gigatexel closed 1 month ago

gigatexel commented 3 months ago

Describe the bug

I noticed in the source code that as a starting point the LoxAPP3.json is parsed.

Wouldn't it be a great idea to use the parsed UUID's to populate a drop-down in the event_websocket_command service all? This would make calling this service a lot easier, since you don't need to copy the .json, beautify it, search the UUID's and paste the correct value in the service call?

If there would be reasons why this is complicated, one can also use the device's name as I have shown in my own Blueprint: https://community.home-assistant.io/t/sending-data-from-home-assistant-to-loxone/625396

Firmware of your Miniserver

*

HomeAssistant install method

*

Version of HomeAssistant

*

Version of Pyloxone

*

Update pyloxone

*

Log

Settings for the log can be found on the main page under the section Log Configuration

JoDehli commented 2 months ago

@gigatexel thanks for you idea. Maybe I can take a look in the near future. At the moment I do not have enough time. I hope it gets better.

gigatexel commented 2 months ago

I figured out that it shouldn't be that hell of a job :-)

event_websocket_command:
  description: Send websocket commands to the loxone server. More infos and commands https://www.loxone.com/dede/kb/api/
  fields:
    uuid:
      name: Device
      description: Device which you want to send a command
      example: Light 1
      selector:
        device:
          integration: loxone
    value:
      name: Command
      description: Command which you want to send
      example: pulse
      selector:
        text:

Thing is, I can change/create the appropriate const values, but I dont know what this needs to become to get the UUID from the deviceID.

    async def handle_websocket_command(call):
        """Handle websocket command services."""
        value = call.data.get(ATTR_VALUE, DEFAULT)
        device_uuid = ?
        await miniserver.api.send_websocket_command(device_uuid, value)
gigatexel commented 1 month ago

Implemented