-
-
Notifications
You must be signed in to change notification settings - Fork 29.2k
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
Add Traffic Rule switches to UniFi Network #104671
Conversation
Hey there @Kane610, mind taking a look at this pull request as it has been labeled with an integration ( Code owner commandsCode owners of
|
@Kane610 this seems to work except that toggling the rule via the UniFi interface doesn't update the switch in Home Assistant. I suspect it's because the switches don't really poll. I'm not sure if everything else so far uses web sockets, but I think I gotta figure that out before marking this ready to review. |
It looks like pretty much everything else is able to subscribe to websocket events, but I'm not seeing any logged for Traffic Rules. Possibly for any V2 entities? |
There are no web socket events for V2 APIs, at least not on the subscribed endpoint. |
Got it. So I'll need to implement some kind of polling mechanism for the V2 items. |
Where I’m at right now is finding a way to conditionally mix in the That’s probably more terrible than it’s worth though. So my plan for now is to create the switch subclass, add a new field to the Description class that can be used as the class factory, then instruct the controller to prefer the subclass indicated by the Description. Starting with this before meta classes or monkey patching seems wise. |
I think you can do it much easier; as all apihandlers signal updates to subscribers isn't it easier to set up some sort of timed poller that just calls the traffic_rules.update every two minutes? |
Any updates on this? |
Sorry. Just had a newborn and haven’t had much time to take a look at implementing the feedback. Got caught up in the weeks before with nursery automation and networking was bumped down on my priority queue. Once things stabilize a bit, I can try to take another look. |
Congratulations! Take your time |
Hello @ViViDboarder! Thanks for starting on this. :) Just as a FYI I tried this patch, and get the following error when Unifi integration starts.
I just patched the switch.py in HA Core, deleted the integration, and added it back in. My hardware is UDM Pro with Unifi Network 8.1.113. I am also really looking forward to be able to enable / disable policy based routes from Home Assistant. That would solve a few problems for me. :) |
I've been rewriting and renaming stuff in the integration so that's the reason it fails. I think you can get far by just replacing 'controller' with 'hub' |
There hasn't been any activity on this pull request recently. This pull request has been automatically marked as stale because of that and will be closed if no further activity occurs within 7 days. |
I would really like to see this addition come to fruition. I think many people could benefit from it. I am a novice, how can I help the project? |
You're welcome to try! It is just to start looking at it and the comments on this issue if there is something you can resolve |
If anyone else was following this waiting for it to be merged, I forked the code and put up my own PR after addressing some issues. Hopefully we'll get some progress on this! I have 3 kids myself (and 1 on the way) so I know how time constraining they can be. ViViDboarder did a great job on getting this working. |
Thank you for making progress on this, I've been following for a while. Hopefully it gets some traction. |
Closing because #118821 was merged |
Proposed change
Add switch entities for UniFi Traffic Rules
Type of change
Additional information
Checklist
ruff format homeassistant tests
)If user exposed functionality or configuration variables are added/changed:
If the code communicates with devices, web services, or third-party tools:
Updated and included derived files by running:
python3 -m script.hassfest
.requirements_all.txt
.Updated by running
python3 -m script.gen_requirements_all
..coveragerc
.To help with the load of incoming pull requests: