YIO-Remote / integration.home-assistant

🔌 Home Assistant Integration for YIO
GNU General Public License v3.0
4 stars 6 forks source link

added device support for broadlink #28

Closed kaisten closed 4 years ago

kaisten commented 4 years ago

To make use of the Broadlink integration as a ir extender it is necessary to send the device key with the command to homeassistant. To use it add device property to your command. I am not really aware how you add that in the config.json, if you have a look and let me know I will improve my pr.

martonborzak commented 4 years ago

I can imagine it something like this in config.json:

"commands": [
            {
                "button_map": "POWER_TOGGLE",
                "code": "3;0x20DF40BF;32;0",
                "format": "hex",
                "device": "uniqueIDofDevice"
            },
            {
                "button_map": "CHANNEL_UP",
                "code": "3;0x20DF40BF;32;0",
                "format": "hex",
                "device": "uniqueIDofDevice"
            }
        ]

In this case it's always related to the command. Not sure if you'd like that. Maybe it is worth looking at rewriting the findRemoteCodes method, so it would also return the device next to the code.

kaisten commented 4 years ago

@martonborzak I am not sure if I completely understand your suggestion. Your proposed config looks like mine. The code property is send as "command" to homeassistant anyway. To make use of the broadlink remote Integration, homeassistant expect "command" and "device" as service data. Here is how my working remote config looks like:

{ "commands": [ { "button_map": "POWER_TOGGLE", "code": "power", "device": "tv" }, { "button_map": "VOLUME_UP", "code": "vol_up", "device": "tv" }, { "button_map": "VOLUME_DOWN", "code": "vol_down", "device": "tv" } ], "entity_id": "remote.broadlink", "friendly_name": "TV Broadlink", "integration": "your ha integreation id", "supported_features": [ "POWER_TOGGLE", "VOLUME_UP", "VOLUME_DOWN" ] }

martonborzak commented 4 years ago

@kaisten probably misunderstood, I was reacting on this you wrote: I am not really aware how you add that in the config.json

I am just wondering that instead of introducing findRemoteDevice we could improve findRemoteCodes and change its functionality to return the device as well.

kaisten commented 4 years ago

sorry my sentence is also misleading. What I meant if I should extend the config-schema.json as well with the device property in the command section of remote. The rework of the findRemoteCodes will confuse with the naming in terms of reading and understanding the code. It was a bit confusing that the code gets split and send as command in the service data. I would suggest to write a method which will return the specific command object and search in that for code and device property. This would improve understanding and prevent duplicate code. If you agree I would give it a shot.

martonborzak commented 4 years ago

Yes, config-schema.json should be also updated. Otherwise you'll see errors. Sure, let's try that, just please also have a look in the dock integration, because it is also using this. It has to work there as well. And thanks for the suggestions and improvements!