core: Fortinet Integration has stopped working with FortiOS v7.4.3

The problem

Hello. After updating the version of FortiOS from version 7.2 to the latest version available today (7.4.3) has stopped working the integration of home assistant with this platform.

What version of Home Assistant Core has the issue?

core-2024.4.2

What was the last working version of Home Assistant Core?

core-2024.4.2

What type of installation are you running?

Home Assistant OS

Integration causing the issue

fortios

Link to integration documentation on our website

https://www.home-assistant.io/integrations/fortios/

Diagnostics information

It is not possible to download diagnostic information because the integration has not yet been migrated to GUI.

Example YAML snippet

device_tracker:
  - platform: fortios
    host: {FW IP}
    token: !secret fortios_token
    verify_ssl: false
    new_device_defaults:
      track_new_devices: false

Anything in the logs that might be useful for us?

2024-04-09 16:34:04.211 WARNING (SyncWorker_6) [fortiosapi] in formatresponse res.content does not exist, should not occur
2024-04-09 16:34:04.211 ERROR (SyncWorker_6) [homeassistant.components.fortios.device_tracker] Failed to login to FortiOS API: Not logged on a session, please login.
2024-04-09 16:34:04.213 ERROR (MainThread) [homeassistant.components.device_tracker] Error setting up platform legacy fortios

Additional information

Attached is a screenshot of the user’s permissions in Fortinet. Image 490

These permissions were sufficient when the integration was working. However try to generate a new API Key and give read permissions to the user in all options. But it did not work Image 491

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Comments: 38 (15 by maintainers)

Most upvoted comments

Thanks guys, very nice. I found a number of issues. One in fortiosapi, which I have now refactored to get rid of in the component. Next one issue in the component which is fixed. I also found an oddity in the API response from FortiOS, this is reported so let’s see how that goes. Lastely I noticed the base class “DeviceScanner” which I am inheriting in the component is know put in to legacy state, so I have to refactor the whole component to be async and use config_flow to be inline with hass guidelines. This will take some time, but in the end it will result in a much better component. Thanks for finding the issues. I’ll push the first minor changes to my fork at: https://github.com/kimfrellsen/core/tree/dev/homeassistant/components/fortios You are welcome to test it. Of couse it does not fix the oddity with the FOS API response. You can install it as a custom component. custom components takes precedence over regular components. I’ll keep you posted. Would be great with some testing when rewriting is finished. Have a great day. /Kim

@amorsen is it possible to give the command to change the : device-idle-timeout on fortios ? i didn’t find it 😒

config global (if you have vdoms enabled) config system global set device-idle-timeout 300

This is with 7.2.x. https://docs.fortinet.com/document/fortigate/7.6.1/cli-reference/339914554/config-system-global indicates that the command it the same in 7.6.x

It turns out there is a setting device-idle-timeout which by default is 300 seconds. Lowering that setting fixes the problem, but unfortunately it also leads to false offline detections when the device does not generate traffic for a while. Once again not a problem with the integration.

Hi,

The root course is FortiOS not updating the online status correctly. I can share the source code I pasted to pastbin with you, it solves the problem with excessive alerts in hass, but it does not solve the problem in fortios.

/Kim

On Tue, Jul 2, 2024 at 5:52 PM goncal @.***> wrote:

Hi, I’m running FortiOS v.7.4.4 and also experiencing the problem. If you need me to do any troubleshooting just let me know!

Shall I get the update you mentioned on April 30 (the pastebin URL no longer works), or am I OK using the code at https://github.com/kimfrellsen/core/tree/dev/homeassistant/components/fortios ? By the way, I guess that I just need to drop that code into the custom_components folder and restart HA, right? Best

— Reply to this email directly, view it on GitHub https://github.com/home-assistant/core/issues/115286#issuecomment-2203628655, or unsubscribe https://github.com/notifications/unsubscribe-auth/AD7LXY4OIY23KDI7OMDAQB3ZKLEC7AVCNFSM6AAAAABF6XXZFKVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDEMBTGYZDQNRVGU . You are receiving this because you were mentioned.Message ID: @.***>

@SirSheik

I have put an update here on pastebin: https://pastebin.com/c6JJpPPe

(yes I know pastbin is probably not the safest place, but it is there now).

If you have installed the fortios component as a custom component you can replace the code with the one shared on pastebin, I can also email it to you. it basically fixes a little issue and removes the use of fortiosapi. Naturally it does not fix the issue with the API response in FortiOS v.7.4.x

Hi SirSheik,

I have successfully refactored the integration to get remove dependencies to the python library FortiOSAPI and added support for vdoms.

I cannot push it as Home-Assistant (with a very valid reason) does not accept pull request for integrations which rely on yaml configuration, so I am also rewriting the my integration to support config_flow. When I have it working I’ll let you know, maybe you can help to test it.

/Kim

On Tue, Apr 23, 2024 at 4:37 PM SirSheik @.***> wrote:

Hi SirSheik, Thank for the help. Especially the filter issue.

I too think there is a bug in device detection on FOS 7.4.x. I’ll check bug fixes on 7.4.x and if needed open a bug request.

I have also looked at your initial issue “2024-04-09 16:34:04.211 WARNING (SyncWorker_6) [fortiosapi] in formatresponse res.content does not exist, should not occur 2024-04-09 16:34:04.211 ERROR (SyncWorker_6) [homeassistant.components.fortios.device_tracker] Failed to login to FortiOS API: Not logged on a session, please login. 2024-04-09 16:34:04.213 ERROR (MainThread) [homeassistant.components.device_tracker] Error setting up platform legacy fortios”

I can reproduce this using api calls through the external component FortiOSAPI. This python component is a bit outdated and no longer actively maintained. It is a python library dependency issue. So I’ll update the HASS integration to use python requests directly to FortiGate instead.

Time to update the integration to get rid of YAML and FortiOSAPI 😃 /Kim

Thank you Kim. If I can help in any way you let me know. If I get some time I will try to investigate a little more to see if I can help in solving the problem. Keep in touch in this topic for possible progress. Thanks for your time.

— Reply to this email directly, view it on GitHub https://github.com/home-assistant/core/issues/115286#issuecomment-2072504328, or unsubscribe https://github.com/notifications/unsubscribe-auth/AD7LXY7LW452P7VFXUXKH5LY6ZW3BAVCNFSM6AAAAABF6XXZFKVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDANZSGUYDIMZSHA . You are receiving this because you were mentioned.Message ID: @.***>

Hi SirSheik, Thank for the help. Especially the filter issue.

I too think there is a bug in device detection on FOS 7.4.x. I’ll check bug fixes on 7.4.x and if needed open a bug request.

I have also looked at your initial issue “2024-04-09 16:34:04.211 WARNING (SyncWorker_6) [fortiosapi] in formatresponse res.content does not exist, should not occur 2024-04-09 16:34:04.211 ERROR (SyncWorker_6) [homeassistant.components.fortios.device_tracker] Failed to login to FortiOS API: Not logged on a session, please login. 2024-04-09 16:34:04.213 ERROR (MainThread) [homeassistant.components.device_tracker] Error setting up platform legacy fortios”

I can reproduce this using api calls through the external component FortiOSAPI. This python component is a bit outdated and no longer actively maintained. It is a python library dependency issue. So I’ll update the HASS integration to use python requests directly to FortiGate instead.

Time to update the integration to get rid of YAML and FortiOSAPI 😃 /Kim

I can confirm i have the same issue when upgrading from FortiOS 7.2.7 to 7.4.3.

However it seems like the issue could be in FortiOS since almost none of my devices goes offline in the Fortigate. I will do some more digging.

In my case i don´t have any error messages in HA, the entities just never change state they are always home no matter what.