tomaae / homeassistant-mikrotik_router

Mikrotik router integration for Home Assistant
Apache License 2.0
301 stars 50 forks source link

[Question] RouterOS update reports unknown #254

Closed emilianogetino closed 1 year ago

emilianogetino commented 1 year ago

is this normal?

image

It indicates last unknown version, if I modify the integration configuration it comes out correct, or if I restart the router, but after a few minutes it is the same. It is annoying because it indicates a notification in settings and you have to go in to see if it is a false notice, or if it is something that requires attention. Greetings, thank you.

tomaae commented 1 year ago

check your HA log for any errors

emilianogetino commented 1 year ago

I have only seen this, although I think it has nothing to do with this problem

2022-10-20 11:04:01.509 ERROR (SyncWorker_0) [custom_components.mikrotik_router.mikrotik_controller] Mikrotik 172.26.1.1 duplicate Filter rule accept,any:any (ID *B), entity will be unavailable.

I have added this line to the config.yaml to see if something else happens logs: homeassistant.components.mikrotik: debug

If I see anything else I'll let you know.

Thank you

emilianogetino commented 1 year ago

in the history it is seen how the status changes from updated to unavailable from time to time image in the next change to unavailable I will look at the log, I just restarted to enter the debug and the log is clean

emilianogetino commented 1 year ago

I have looked at the log at the times that the state changes and there is nothing registered, nor does anything appear with debug in the entire log.

Thank you.

tomaae commented 1 year ago

ok, capture it with debug enabled. I will have a look

emilianogetino commented 1 year ago

Nothing appears in the log as debug, nor errors related to the mikrotik. The problem is that when Latest version is unknown

sensor update.router_routeros_update has the status ON and it appears in settings that there is an update pending.

tomaae commented 1 year ago

you have to enable debug. it wont show otherwise https://github.com/tomaae/homeassistant-mikrotik_router#enabling-debug

emilianogetino commented 1 year ago

Hello good morning, sorry for the delay in response, but I've been sick and disconnected for a while. After installing the debug I noticed some errors of this type:

⚠2022-10-29 17:29:06.030 DEBUG (SyncWorker_0) [custom_components.mikrotik_router.mikrotikapi] API query: /system/package/update 2022-10-29 17:29:06.034 DEBUG (SyncWorker_0) [custom_components.mikrotik_router.apiparser] Processing source [{'channel': 'stable', 'installed-version': '6.49.7', 'status': 'ERROR: connection timed out'}] 2022-10-29 17:29:06.034 DEBUG (SyncWorker_0) [custom_components.mikrotik_router.apiparser] Processing entry {'channel': 'stable', 'installed-version': '6.49.7', 'status': 'ERROR: connection timed out'}

However that is not a problem, the communication fails from time to time, as in other processes. the problem is that when the communication fails the update.router_routeros_update entity has its attribute latest_version: unknown which is correct, what is not correct is that the status of this entity is on, and it should be off, since the available version is unknown and therefore it should not indicate that there is a pending update. image this happens frequently, the internet connection where I live leaves much to be desired, it is through 4g and it fails a lot image and constantly there are avios of update available image From my point of view the solution is easy, when the latest available version is unknown, the status of this entity is off, which on the other hand is logical, so there would be no false update notices. Greetings, thank you.

tomaae commented 1 year ago

Update entity does not have on/off state like binary entity. It is triggered when installed version and latest version is different.

emilianogetino commented 1 year ago

when they are different but the new version is unknown it should be off and not activated. That behavior is that it seems wrong to me, the NAS synology sensor for example does not have that problem, when the available version is unknown it does not indicate an update.

tempsnip

tempsnip2

tomaae commented 1 year ago

State is determined by comparing versions. If you dont believe me, here it how it is implemented in HA:

    @property
    @final
    def state(self) -> str | None:
        """Return the entity state."""
        if (installed_version := self.installed_version) is None or (
            latest_version := self.latest_version
        ) is None:
            return None

        if latest_version == self.__skipped_version:
            return STATE_OFF
        if latest_version == installed_version:
            return STATE_OFF

        try:
            newer = AwesomeVersion(latest_version) > installed_version
            return STATE_ON if newer else STATE_OFF
        except AwesomeVersionCompareException:
            # Can't compare versions, already tried exact match
            return STATE_ON

If has final decorator, so its behaviour cannot be overriden.

Only option would be to make sensor unavailable on check failure, but I'm not sure how it would behave and if I like that kind of implementation.

emilianogetino commented 1 year ago

Hello again, first of all thank you for your time and patience, I admit that I am too new and it is difficult for me to explain the problems and even more to fix them, hahahaha. Thanks in advance. I have been looking these days to see if I saw something clear and no, I do not see it, I am increasingly confused. The state of the sensor when it fails is unknown, how does that code treat this? It contemplates that it be none, but it is not none, it is unknown.

Another thing that I do not understand is why the problem is caused by the update.router_routeros_update sensor, however the update.router_routerboard_firmware_update sensor does not give any problem, both are from the same integration. No other update sensor from any other integration gives that problem, and I have many installed, only that sensor from this integration gives a problem. I have put the debug to this integration again and when this sensor fails, the error that is registered is this:

2022-11-18 19:51:15.772 DEBUG (SyncWorker_4) [custom_components.mikrotik_router.apiparser] Processing source [{'channel': 'stable', 'installed-version': '6.49.7', 'status': 'ERROR: connection timed out'}] 2022-11-18 19:51:15.773 DEBUG (SyncWorker_4) [custom_components.mikrotik_router.apiparser] Processing entry {'channel': 'stable', 'installed-version': '6.49.7', 'status': 'ERROR: connection timed out'}

After putting the debug I have seen that there is another problem, that I don't know if it is related to this, but that it is making several automations that I am using with the device trackers not work for me. all the devicetrackers of this integration change from unknown status to their home or not home status every 15 seconds.

image

When this happens the log records this error every 15 seconds: 2022-11-18 19:51:10.748 WARNING (SyncWorker_4) [custom_components.mikrotik_router.mikrotikapi] Mikrotik Reconnected to 172.26.1.1

It gives me the impression it connects to the router for 15 seconds and disconnects from the router for another 15 seconds, why could it be? Any ideas?

I have already uninstalled the mikrotik router integration and reinstalled it, everything remains the same. I have also put the home assistant raspberry directly connected to the router, before there was a couple of switches between them, but everything remains the same. I don't know what else to try.

Thanks for your time, best regards.

sermayoral commented 1 year ago

Hi guys!! From two days ago i have the same behaviour. I receive a notification that i have an update that it doesn't exist:

🏡 Update available: Mikrotik RouterOS -> unknown

It happens once a day, at night (3 - 6 am). I think it happens when the ISP (Internet company) restarts your Internet connection.

@tomaae. Maybe the sensor should check that the version available is not 'unknown' before indicates a version is available, don't you think?

emilianogetino commented 1 year ago

Solved: all the devicetrackers of this integration change from unknown status to their home or not home status every 15 seconds. image

The problem has been solved by unchecking the hostpot box, which I don't understand what it has to do with it, but since I unchecked it, it hasn't given that problem again. I did this because an error appeared in the log that I could not access the ho directory tspot, which is normal because this router does not have any hotspot installed. The update problem is still unsolved.

tomaae commented 1 year ago

which is normal because this router does not have any hotspot installed. The update problem is still unsolved.

Can you give me the error message?

emilianogetino commented 1 year ago

If I activate the hotspot box in the integration settings, it gives this error image Then it gives this error every 15 seconds image

tomaae commented 1 year ago

Ok, thats related only to old RouterOS versions. What kind of error do you get now in debug?

github-actions[bot] commented 1 year ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.

emilianogetino commented 1 year ago

El RouterOS está actualizado a la ultima version, los errores siguen siendo los mismos. The problem is still the inappropriate behavior of the update.router_routeros_update entity, which does not happen with the update.router_routerboard_firmware_update entity of this same integration, nor does it happen with any other update entity of the other integrations, if they do not know what the version is to install do not indicate available update. image Thank you

tomaae commented 1 year ago

The question here is why it is not getting the information. Getting silent failures is just a no-go. Firmware entity is not dependent on external information, so that cannot be compared.

github-actions[bot] commented 1 year ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.

emilianogetino commented 1 year ago

La pregunta aquí es por qué no está recibiendo la información. Obtener fallas silenciosas es simplemente un no-go. La entidad del firmware no depende de información externa, por lo que no se puede comparar.

Is there any way to test the connection from my house with the web where it recovers the version to check if there is some kind of connection problem?

tomaae commented 1 year ago

I never looked into that, but you could check for version manually via mikrotik. it should be possible to find ip using that.

github-actions[bot] commented 1 year ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.

github-actions[bot] commented 1 year ago

This issue was closed because it has been stalled for 5 days with no activity.