Help with “Device Internet Access” template switches please?!,… I’m stumped! Cannot get them working. Anything would be appreciated.
The ASUSRouter was installed via HACS. Configured via Integrations.
The ASUS router devices and entities show up. The default switches (LED, Wifi, Reboot, etc ) are controllable via the default lovelace dashboard. I had to enable several of the entities that I was planning on controlling.
The problem: The dashboard switches are always ON, regardless of the actual block status on the router. When I move them to the OFF position,… they revert back to ON within a few seconds.
As a test, I blocked one of the devices directly on the router. The state of the switch does not change on the dashboard.
I’ve also tested the “asusrouter.device_internet_access” service via the Automations menu. (Similar to the method here: [Custom component] AsusRouter integration - #220 by TekDad). Using this method, Home Assistant is able to block and unblock the internet access of the same entities. So I think the service and connection between Home Assistant are working correctly.
So I think it’s an issue with the template switch configuration? I’m at a total loss.
I know, that from time to time you would like to get an answer to your question or a bug fixed as soon as possible (in terms of hours or a couple of days). I can understand that, but not every time can this be fulfilled.
All the bug reports and other messages are read by me. And all the bugs (that can be fixed) will be fixed. For those, which can not be fixed, another solution will be found (hello, Merlin builds ignoring LED status on reboot).
Please, only consider that AsusRouter is my free-time project in addition to a full-time job. So the amount of time I can spend on it can fluctuate from a couple of hours per day to only an hour per week.
In any case, AsusRouter will improve and progress.
Thinking of buying a new Asus router to use with AsusRouter integration? Check the compatibility list in our Docs. If you will use any of the Amazon Associate links, I might get a small (1-3%) bonus from Amazon (usage of the associate links does not change the price of the items for you)
You need to change in your actions element.state == "block" to element.type == "block" (use type instead of state)
Also, instead of using
entity_id: device_tracker.nintendo_switch
please use
entities:
- device_tracker.nintendo_switch
So your code should be
switch:
- platform: template
switches:
internet_nintendo_switch:
unique_id: internet_nintendo_switch
value_template: >
{% set ns = namespace(
mac = "xx:xx:xx:xx:xx:xx"|upper,
list = state_attr("switch.rt_ac86u_parental_control","list"),
internet = true
) %}
{# Find whether #}
{% for element in ns.list %}
{% if element.mac == ns.mac and element.type == "block" %}
{% set ns.internet = false %}
{% endif %}
{% endfor %}
{{ ns.internet }}
turn_on:
service: asusrouter.device_internet_access
data:
entities:
- device_tracker.nintendo_switch
state: disable
turn_off:
service: asusrouter.device_internet_access
data:
entities:
- device_tracker.nintendo_switch
state: block
internet_amazon_firetv_basement_wifi:
unique_id: internet_amazon_firetv_basement_wifi
value_template: >
{% set ns = namespace(
mac = "xx:xx:xx:xx:xx:xx"|upper,
list = state_attr("switch.rt_ac86u_parental_control","list"),
internet = true
) %}
{# Find whether #}
{% for element in ns.list %}
{% if element.mac == ns.mac and element.type == "block" %}
{% set ns.internet = false %}
{% endif %}
{% endfor %}
{{ ns.internet }}
turn_on:
service: asusrouter.device_internet_access
data:
entities:
- device_tracker.amazon_firetv_basement_wifi
state: disable
turn_off:
service: asusrouter.device_internet_access
data:
entities:
- device_tracker.amazon_firetv_basement_wifi
state: block
Unfortunately, the examples you have used are already a bit outdated. I am hoping to finally be able to add the correct examples of YAML usage into the AsusRouter documentation, but it takes quite some time.
Feel free to ask if you have any other questions or issues
Wow @Vaskivskyi. Thanks for adjusting my code. Works! I would not have seen those two spots. I had noticed the change to allow multiple entries, but didn’t understand how it impacted your original code example. Appreciate it!
If I reboot my router some entities become unavailable and is not restored until I do a reboot of HA. Is that a known ‘bug’? I haven’t investigated it properly. Just thought I’d ask here first.
Created Letscrypt SSL and disabled captcha with ssl login. Now I can connect via local IP with SSL and integration is running in HA now… Lets see if the errors are gone and solved.
I just wanted to come here and say thank you for this integration (yes I’ve voted for it), you were able to get me to have this on my dashboard which was my end goal (this is also using Extender and Mushroom):
Couldn’t reproduce entities staying unavailable after router reboot. Perhaps the issue only occurs when wan is disconnected or perhaps it’s fixed in one of the later versions. I’ll keep an eye out.
If the entities do not recover without reload of the integration (or HA reboot), that would be a bug. Please, keep track of the entities and let me know your findings. Also, in such cases, there should probably be some errors in the log - that might help as well.
Since updating to HA 2023.3.2 the integration is listed as “! Not Loaded” and I am receiving the following errors in the logs. I’ve tried shutting HA down fully and restarting, but that did not solve the issue. Any ideas?
Logger: homeassistant.setup
Source: setup.py:205
First occurred: 5:04:31 PM (1 occurrences)
Last logged: 5:04:31 PM
Setup failed for custom integration asusrouter: Requirements for asusrouter not found: [‘asusrouter==0.19.3’].
Logger: homeassistant.util.package
Source: util/package.py:107
First occurred: 4:57:31 PM (3 occurrences)
Last logged: 4:57:45 PM
Unable to install package asusrouter==0.19.3: ERROR: Cannot install asusrouter==0.19.3 because these package versions have conflicting dependencies. ERROR: ResolutionImpossible: for help visit Dependency Resolution - pip documentation v24.1.dev0 [notice] A new release of pip is available: 23.0 → 23.0.1 [notice] To update, run: pip install --upgrade pip
? , i assume you just applied 2023.3.2, … SO what ever you did last night wont be affected by a rollback,
PS: Go to /settings/system/backups/ … click on latest core , restore … done
PS2: and im pretty sure whatever you did yesterday or today after applying core_2023.3.2, did not affect core, and therefore another reason for not avoiding a rollback … sometimes a rollback/reinstall of a patch is also very affectfull ( if f.ex the errors is caused by faults during installation/patching, network/checksum errors etc.
PS3: Sorry can’t help it, but just wanted to remind you about the current version for AsusRouter