GithubHelp home page GithubHelp logo

Comments (28)

tomaae avatar tomaae commented on May 29, 2024 1

I cant find anything obvious.
I have started refactoring and adding debugs to the controller class. It may take me a day or two, but afterwards we should be able to find the issue fast, if it still persists after changes.

from homeassistant-mikrotik_router.

tomaae avatar tomaae commented on May 29, 2024

What do you mean by Happens after that and on each reboot. ?
Like HA restart or hassio reboot? Or is that on mikrotik reboot?

from homeassistant-mikrotik_router.

tjorim avatar tjorim commented on May 29, 2024

HA restart, probably because it sets up the integration tasks.

from homeassistant-mikrotik_router.

tjorim avatar tjorim commented on May 29, 2024

Probably a related message in the logs:

Exception in update_controller when dispatching 'mikrotik_router-update-Mikrotik': ()
Traceback (most recent call last):
  File "/config/custom_components/mikrotik_router/switch.py", line 83, in update_controller
    update_items(inst, mikrotik_controller, async_add_entities, switches)
  File "/config/custom_components/mikrotik_router/switch.py", line 107, in update_items
    switches[item_id].async_schedule_update_ha_state()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 432, in async_schedule_update_ha_state
    self.hass.async_create_task(self.async_update_ha_state(force_refresh))
AttributeError: 'NoneType' object has no attribute 'async_create_task'

from homeassistant-mikrotik_router.

tomaae avatar tomaae commented on May 29, 2024

do you have any scripts without a name?

from homeassistant-mikrotik_router.

myownkaos avatar myownkaos commented on May 29, 2024

should i remove the mikrotik integration?

from homeassistant-mikrotik_router.

tomaae avatar tomaae commented on May 29, 2024

should i remove the mikrotik integration?

Removing different integration is not a solution, so no. But I dont think this is a conflict. Can be a missing script name which I just workarounded in master.
Do you have the same issue?

from homeassistant-mikrotik_router.

myownkaos avatar myownkaos commented on May 29, 2024

i added the integration no problem but no devices.

from homeassistant-mikrotik_router.

tomaae avatar tomaae commented on May 29, 2024

Is it the same traceback error? Do you have any scripts on your mikrotik device without a name?

from homeassistant-mikrotik_router.

myownkaos avatar myownkaos commented on May 29, 2024

no scripts at my router.

Error doing job: Task exception was never retrieved
Traceback (most recent call last):
File "/config/custom_components/mikrotik_router/mikrotik_controller.py", line 86, in force_update
await self.async_update()
File "/config/custom_components/mikrotik_router/mikrotik_controller.py", line 156, in async_update
await self.async_fwupdate_check()
File "/config/custom_components/mikrotik_router/mikrotik_controller.py", line 144, in async_fwupdate_check
self.get_firmare_update()
File "/config/custom_components/mikrotik_router/mikrotik_controller.py", line 436, in get_firmare_update
self.data['fw-update']['available'] = True if entry['status'] == "New version is available" else False
KeyError: 'status'

Model   951Ui-2HnD

from homeassistant-mikrotik_router.

tomaae avatar tomaae commented on May 29, 2024

thats a different issue. can you give me output from your router?
/system package update check-for-updates

If you can, open a new issue for it, so we wont mix things up

from homeassistant-mikrotik_router.

myownkaos avatar myownkaos commented on May 29, 2024

thats a different issue. can you give me output from your router?
/system package update check-for-updates

If you can, open a new issue for it, so we wont mix things up

started to work. all of a sudden.

from homeassistant-mikrotik_router.

tjorim avatar tjorim commented on May 29, 2024

do you have any scripts without a name?

No, both have a name:
image

Which group policies should the user have?
For the HA device tracker this suffices:
image

from homeassistant-mikrotik_router.

tomaae avatar tomaae commented on May 29, 2024

It also needs write access for switches.
I still did not figured out scripts rights for scripts

from homeassistant-mikrotik_router.

tomaae avatar tomaae commented on May 29, 2024

thats a different issue. can you give me output from your router?
/system package update check-for-updates
If you can, open a new issue for it, so we wont mix things up

started to work. all of a sudden.

found the reason. status is missing on first query after firmware upgrade. probably a routeros bug, but easy to fix from my side. will be in next release.

from homeassistant-mikrotik_router.

tomaae avatar tomaae commented on May 29, 2024

I cannot find any other possible cause.
Can you provide output of these 4 commands? Feel free to obscure any data. Just dont delete the entries, but replace them with something obvious(like XX).

/interface print terse
/ip arp print terse
/interface bridge host print terse
/ip firewall nat print terse

from homeassistant-mikrotik_router.

tjorim avatar tjorim commented on May 29, 2024

It also needs write access for switches.
I still did not figured out scripts rights for scripts

Gave it write access, no difference.

I cannot find any other possible cause.
Can you provide output of these 4 commands? Feel free to obscure any data. Just dont delete the entries, but replace them with something obvious(like XX).

/interface print terse
/ip arp print terse
/interface bridge host print terse
/ip firewall nat print terse

Is this aimed at me?

If so
  MMM      MMM       KKK                          TTTTTTTTTTT      KKK
  MMMM    MMMM       KKK                          TTTTTTTTTTT      KKK
  MMM MMMM MMM  III  KKK  KKK  RRRRRR     OOOOOO      TTT     III  KKK  KKK
  MMM  MM  MMM  III  KKKKK     RRR  RRR  OOO  OOO     TTT     III  KKKKK
  MMM      MMM  III  KKK KKK   RRRRRR    OOO  OOO     TTT     III  KKK KKK
  MMM      MMM  III  KKK  KKK  RRR  RRR   OOOOOO      TTT     III  KKK  KKK

  MikroTik RouterOS 6.44.6 (c) 1999-2019       http://www.mikrotik.com/

[?]             Gives the list of available commands
command [?]     Gives help on the command and list of arguments

[Tab]           Completes the command/word. If the input is ambiguous,
                a second [Tab] gives possible options

/               Move up to base level
..              Move up one level
/command        Use command at the base level
(8776 messages not shown)
sep/17/2019 21:24:16 system,error,critical login failure for user homeassistant fr
om 192.168.1.2 via api
sep/17/2019 21:24:16 system,error,critical login failure for user homeassistant fr
om 192.168.1.2 via api
sep/18/2019 09:01:27 system,error,critical router was rebooted without proper shut
down
oct/24/2019 11:21:54 system,error,critical router was rebooted without proper shut
down
nov/06/2019 02:00:02 system,error,critical router was rebooted without proper shut
down
nov/18/2019 07:36:31 system,error,critical router was rebooted without proper shut
down
nov/25/2019 07:30:25 system,error,critical router was rebooted without proper shut
down
dec/07/2019 16:37:24 system,info,critical Firmware upgraded successfully, please r
eboot for changes to take effect!
[user@MikroTik] > /interface print terse
 0  R  name=ether1 default-name=ether1 type=ether mtu=1500 actual-mtu=1500 l2mtu=1
598 max-l2mtu=9214 mac-address=AA:AA:AA:AA:AA:AA last-link-up-time=dec/07/2019 16:
35:47 link-downs=0 
 1  RS name=ether2 default-name=ether2 type=ether mtu=1500 actual-mtu=1500 l2mtu=1
598 max-l2mtu=9214 mac-address=BB:BB:BB:BB:BB:BB last-link-down-time=dec/09/2019 1
1:50:37 last-link-up-time=dec/09/2019 11:50:39 link-downs=4 
 2  RS name=ether3 default-name=ether3 type=ether mtu=1500 actual-mtu=1500 l2mtu=1
598 max-l2mtu=9214 mac-address=CC:CC:CC:CC:CC:CC last-link-up-time=dec/07/2019 16:
35:48 link-downs=0 
 3   S name=ether4 default-name=ether4 type=ether mtu=1500 actual-mtu=1500 l2mtu=1
598 max-l2mtu=9214 mac-address=DD:DD:DD:DD:DD:DD link-downs=0 
 4   S name=ether5 default-name=ether5 type=ether mtu=1500 actual-mtu=1500 l2mtu=1
598 max-l2mtu=9214 mac-address=EE:EE:EE:EE:EE:EE link-downs=0 
 5  RS name=wlan1 default-name=wlan1 type=wlan mtu=1500 actual-mtu=1500 l2mtu=1600
 max-l2mtu=2290 mac-address=F1:F1:F1:F1:F1:F1 last-link-up-time=dec/07/2019 16:35:
45 link-downs=0 
 6   S name=wlan2 default-name=wlan2 type=wlan mtu=1500 actual-mtu=1500 l2mtu=1600
 max-l2mtu=2290 mac-address=F2:F2:F2:F2:F2:F2 last-link-down-time=dec/09/2019 12:0
5:28 last-link-up-time=dec/09/2019 11:53:37 link-downs=9 
 7  R  comment=defconf name=bridge type=bridge mtu=auto actual-mtu=1500 l2mtu=1598
 mac-address=BB:BB:BB:BB:BB:BB last-link-up-time=dec/07/2019 16:35:33 link-downs=0
 
 8  X  name=ovpn-out1 type=ovpn-out mac-address=XX:XX:XX:XX:XX:XX link-downs=0 
 9  R  name=ovpn-out2 type=ovpn-out mtu=1500 actual-mtu=1500 mac-address=XX:XX:XX:
XX:XX:XX last-link-up-time=dec/07/2019 16:36:00 link-downs=0 

[user@MikroTik] > /ip arp print terse       
 0 DC address=192.168.9.1 mac-address=00:00:00:00:00:00 interface=ether1 published
=no 
 1 DC address=192.168.1.2 mac-address=11:11:11:11:11:11 interface=bridge publishe
d=no 
 2 DC address=192.168.1.58 mac-address=22:22:22:22:22:22 interface=bridge publish
ed=no 
 3 DC address=192.168.2.1 mac-address=33:33:33:33:33:33 interface=ovpn-out2 published
=no 
 4 DC address=192.168.1.45 mac-address=44:44:44:44:44:44 interface=bridge publish
ed=no 
 5 D  address=192.168.1.46 mac-address=55:55:55:55:55:55 interface=bridge publish
ed=no 
 6 D  address=192.168.1.49 mac-address=66:66:66:66:66:66 interface=bridge publish
ed=no 
 7 DC address=192.168.1.54 mac-address=77:77:77:77:77:77 interface=bridge publish
ed=no 
 8 DC address=192.168.1.224 mac-address=88:88:88:88:88:88 interface=bridge publis
hed=no 

[user@MikroTik] >> /interface bridge host print terse 
 0   D E mac-address=22:22:22:22:22:22 interface=ether3 bridge=bridge on-interface
=ether3 
 1   DL  mac-address=BB:BB:BB:BB:BB:BB interface=bridge bridge=bridge on-interface
=bridge 
 2   DL  mac-address=CC:CC:CC:CC:CC:CC interface=ether3 bridge=bridge on-interface
=ether3 
 3   DL  mac-address=F1:F1:F1:F1:F1:F1 interface=wlan1 bridge=bridge on-interface=
wlan1 
 4   D   mac-address=66:66:66:66:66:66 interface=wlan1 bridge=bridge on-interface=
wlan1 age=1m50s 
 5   D E mac-address=11:11:11:11:11:11 interface=ether2 bridge=bridge on-interface
=ether2 
 6   D   mac-address=99:99:99:99:99:99 interface=wlan1 bridge=bridge on-interface=
wlan1 age=1s 
 7   D   mac-address=88:88:88:88:88:88 interface=wlan1 bridge=bridge on-interface=
wlan1 age=2s 
 8   D   mac-address=77:77:77:77:77:77 interface=wlan1 bridge=bridge on-interface=
wlan1 age=10s 

[user@MikroTik] >> /ip firewall nat print terse 
 0 I  comment=Mark all trafic for ovpn chain=srcnat action=masquerade out-interfac
e=ovpn-out1 log=no log-prefix="" 
 1    comment=Mark all trafic for pptp chain=srcnat action=masquerade out-interfac
e=ovpn-out2 log=no log-prefix="" 
 2    comment=defconf: masquerade chain=srcnat action=masquerade out-interface-lis
t=WAN log=no log-prefix="" ipsec-policy=out,none 
 3    comment=Portfoward sub1.example.com chain=dstnat action=dst-nat to-addresses=19
2.168.12.2 to-ports=8090 protocol=tcp dst-address=192.168.2.2 dst-port=8090 log=no lo
g-prefix="" 
 4    comment=Portfoward sub2.example.com chain=dstnat action=dst-nat to-addresses=19
2.168.12.2 to-ports=3000 protocol=tcp dst-address=192.168.2.2 dst-port=3000 log=no lo
g-prefix="" 
 5    comment=Portfoward sub3.example.com chain=dstnat action=dst-nat to-addresses
=192.168.1.2 to-ports=25565 protocol=tcp dst-address=192.168.2.2 dst-port=8090 log=n
o log-prefix="" 
 6    comment=Portfoward sub4.example.com chain=dstnat action=dst-nat to-addresses=19
2.168.12.2 to-ports=8123 protocol=tcp dst-address=192.168.2.2 dst-port=8123 log=no lo
g-prefix="" 
 7    comment=Portfoward wireguard chain=dstnat action=dst-nat to-addresses=192.16
8.12.2 to-ports=51820 protocol=udp dst-address=192.168.2.2 dst-port=51820 log=no log-
prefix="" 
 8    comment=Portfoward sub5.example.com chain=dstnat action=dst-nat to-addresses=192
.168.12.2 to-ports=8212 protocol=tcp dst-address=192.168.2.2 dst-port=8212 log=no log
-prefix="" 
 9    comment=Portfoward example2.com chain=dstnat action=dst-nat to-addresse
s=192.168.1.2 to-ports=8213 protocol=tcp dst-address=192.168.2.2 dst-port=8213 log=n
o log-prefix="" 
10    comment=Portfoward sub6.example.com chain=dstnat action=dst-nat to-addresses=19
2.168.12.2 to-ports=1883 protocol=tcp dst-address=192.168.2.2 dst-port=1883 log=no lo
g-prefix="" 
11    comment=Portfoward sub7.example.com chain=dstnat action=dst-nat to-addresses=19
2.168.12.2 to-ports=7277 protocol=tcp dst-address=192.168.2.2 dst-port=7277 log=no lo
g-prefix="" 
12    comment=Portfoward sub8.example.com chain=dstnat action=dst-nat to-addresses=1
92.168.12.2 to-ports=9192 protocol=tcp dst-address=192.168.2.2 dst-port=9192 log=no l
og-prefix="" 
13    comment=Portfoward sub9.example.com chain=dstnat action=dst-nat to-addresses=19
2.168.12.2 to-ports=32400 protocol=tcp dst-address=192.168.2.2 dst-port=32400 log=no 
log-prefix="" 
14    comment=Portfoward sub10.example.com chain=dstnat action=dst-nat to-addresses=19
2.168.12.2 to-ports=8080 protocol=tcp dst-address=192.168.2.2 dst-port=8080 log=no lo
g-prefix="" 
15    comment=ssh chain=dstnat action=dst-nat to-addresses=192.168.1.2 to-ports=2
2 protocol=tcp dst-address=192.168.2.2 dst-port=22 log=no log-prefix="" 
16    comment=ftp chain=dstnat action=dst-nat to-addresses=192.168.1.2 to-ports=2
0 protocol=tcp dst-address=192.168.2.2 dst-port=20 log=no log-prefix="" 
17    comment=ftp chain=dstnat action=dst-nat to-addresses=192.168.1.2 to-ports=2
1 protocol=tcp dst-address=192.168.2.2 dst-port=21 log=no log-prefix="" 

[user@MikroTik] >> 

from homeassistant-mikrotik_router.

tomaae avatar tomaae commented on May 29, 2024

yes, thanks. I will go through it when I get home.
your problem is not related to access rights. I suspect there is something missing or reported in different way in api response, but I have to take a look at that in detail.
I just remember that I should have cAP somewhere. That is a wifi, so I will test it with that one too. Could be something related to wifi interface.

from homeassistant-mikrotik_router.

tomaae avatar tomaae commented on May 29, 2024

I have not finished with everything but you can give it a try, if you feel like it.
just select manually master version under HACS

to debug, set up your logger like this:

logger:
  default: info
  logs:
    custom_components.mikrotik_router: debug

but test first, that debug may be quite a json wall

from homeassistant-mikrotik_router.

tjorim avatar tjorim commented on May 29, 2024

I updated to master and adjusted the logger settings, however, there is no extra info in the logs.

from homeassistant-mikrotik_router.

tomaae avatar tomaae commented on May 29, 2024

can you give me current error?

from homeassistant-mikrotik_router.

tjorim avatar tjorim commented on May 29, 2024

I deleted the integration, rebooted and set it up again. The following error shows up:

Error while setting up platform mikrotik_router
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 150, in _async_setup_platform
    await asyncio.wait_for(asyncio.shield(task), SLOW_SETUP_MAX_WAIT)
  File "/usr/local/lib/python3.7/asyncio/tasks.py", line 442, in wait_for
    return fut.result()
  File "/config/custom_components/mikrotik_router/switch.py", line 83, in async_setup_entry
    update_controller()
  File "/config/custom_components/mikrotik_router/switch.py", line 77, in update_controller
    update_items(inst, mikrotik_controller, async_add_entities, switches)
  File "/config/custom_components/mikrotik_router/switch.py", line 103, in update_items
    switches[item_id].async_schedule_update_ha_state()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 432, in async_schedule_update_ha_state
    self.hass.async_create_task(self.async_update_ha_state(force_refresh))
AttributeError: 'NoneType' object has no attribute 'async_create_task'

from homeassistant-mikrotik_router.

tomaae avatar tomaae commented on May 29, 2024

I'm really confused by this. Since you for to line 103, it means you already have switch components added in HA and they are updating status.
Logging failing just does not seem possible. Maybe you are overwriting logging somewhere?

Btw, I have tested with wifi device. Problem is certainly not in that:
image
image

If you cannot get working, you could try to figure out which switch type is causing the issue.
You can find all types in switch.py on line 96:
image
Just try with one value at the time to figure out what is causing the issue. I suspect it could be ARP, since thats the most complicated and still not refactored.

from homeassistant-mikrotik_router.

tjorim avatar tjorim commented on May 29, 2024

Seems like NAT is the problem, this works:
image

from homeassistant-mikrotik_router.

tomaae avatar tomaae commented on May 29, 2024

Hmm, you dont have any NAT rule which would be out of ordinary.
Since debugs dont work for you, add a following above line 103 (switches[item_id].async_schedule_update_ha_state()) where it fails:
print("Updating {} switch: {}".format(sid, item_id))
So we know which rule it fails on.

from homeassistant-mikrotik_router.

tjorim avatar tjorim commented on May 29, 2024

I changed your print and all _LOGGER.debug in switch.py to _LOGGER.info

2019-12-21 15:23:13 INFO (MainThread) [homeassistant.components.switch] Setting up switch.mikrotik_router
2019-12-21 15:23:13 INFO (MainThread) [custom_components.mikrotik_router.switch] Updating nat switch: Mikrotik-nat-tcp:8090
2019-12-21 15:23:13 ERROR (MainThread) [homeassistant.components.switch] Error while setting up platform mikrotik_router
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 150, in _async_setup_platform
    await asyncio.wait_for(asyncio.shield(task), SLOW_SETUP_MAX_WAIT)
  File "/usr/local/lib/python3.7/asyncio/tasks.py", line 442, in wait_for
    return fut.result()
  File "/config/custom_components/mikrotik_router/switch.py", line 83, in async_setup_entry
    update_controller()
  File "/config/custom_components/mikrotik_router/switch.py", line 77, in update_controller
    update_items(inst, mikrotik_controller, async_add_entities, switches)
  File "/config/custom_components/mikrotik_router/switch.py", line 106, in update_items
    switches[item_id].async_schedule_update_ha_state()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 432, in async_schedule_update_ha_state
    self.hass.async_create_task(self.async_update_ha_state(force_refresh))
AttributeError: 'NoneType' object has no attribute 'async_create_task'

and

2019-12-21 15:23:42 INFO (MainThread) [custom_components.mikrotik_router.switch] Updating interface switch: Mikrotik-interface-ether1
2019-12-21 15:23:42 ERROR (MainThread) [homeassistant.util.logging] Exception in update_controller when dispatching 'mikrotik_router-update-Mikrotik': ()
Traceback (most recent call last):
  File "/config/custom_components/mikrotik_router/switch.py", line 77, in update_controller
    update_items(inst, mikrotik_controller, async_add_entities, switches)
  File "/config/custom_components/mikrotik_router/switch.py", line 106, in update_items
    switches[item_id].async_schedule_update_ha_state()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 432, in async_schedule_update_ha_state
    self.hass.async_create_task(self.async_update_ha_state(force_refresh))
AttributeError: 'NoneType' object has no attribute 'async_create_task'

Didn't realise the log is only in the file and not HA Developer Tools.

from homeassistant-mikrotik_router.

tjorim avatar tjorim commented on May 29, 2024

Fixed with @tomaae via Discord. It was a user error.
I had two NAT rules with the same destination port.

from homeassistant-mikrotik_router.

github-actions avatar github-actions commented on May 29, 2024

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

from homeassistant-mikrotik_router.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.