Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for switches as lights #119

Open
kepi opened this issue Nov 19, 2023 · 3 comments
Open

Support for switches as lights #119

kepi opened this issue Nov 19, 2023 · 3 comments

Comments

@kepi
Copy link
Contributor

kepi commented Nov 19, 2023

Hi,

I discovered your project yesterday when I tried to replace some of custom scripts I'm using on my Unipi. After some digging, it seems it is much much better then I hoped for, thanks for it!

I'm currently using modbus integration in HA, but unipi-control seems much faster (more responsive), so I would like to ditch all my modbus configs and switch over to it. But I realized that all RO's are discovered as switches and there is no option in Features to handle RO as light instead of switch.

TBH, I'm not 100 % sure at this moment why I need light switches as lights :) but I remember I had troubles with this in HA before and it had been worth it to change modbus switches to lights.

I'm opening this issue more as a discussion - are you open to have this feature in unipi-control? If yes, I can try to prepare PR, but I would appreciate any tips for where to begin and how you would like to have this configured. My thought was add something like device_integration next to device_class.

@mh-superbox
Copy link
Collaborator

This is a feature that I also wanted to add. I just haven't needed it yet ;-) I'm still not quite sure what the big difference is between a switch and light, except that I have a different icon in Home Assistant. You can't use all the extra features of Light (hue, ..) anyway.

This feature should not be too difficult to implement. The name device_integration is appropriate in my opinion.

First of all, a config option is required:

device_class: str = field(default_factory=str)

Then a property method:

def device_class(self) -> Optional[str]:

In the publish method of switches.py, we only add features that also have the appropriate device_integration:

async def publish(self) -> None:

After that a lights.py is needed, with a class like HassLightsMqttPlugin()

await HassSwitchesMqttPlugin(self.neuron, mqtt_client).init_tasks(tasks)

@kepi
Copy link
Contributor Author

kepi commented Nov 20, 2023

I'm still trying to remember and I think that main problem is that I'm not able to do turn on all lights without this.

No promises, but I'll try to take a look into this.

@mh-superbox
Copy link
Collaborator

I'm busy with another project at the moment but I can look at this issue as soon as I have time again.

If you have time, the issue #122 would be better for you, I can't do it alone because I don't have the right hardware.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants