core: Unexpected exception using new set up from the UI for Foscam camera

The problem

In core-2021.2.0 the Foscam integration is now available via the Home Assistant UI. Before I had is set up in configuration.yaml. This is now removed.

Trying to set up via the GUI returns an error however.

Note: I’m also using this camera with the Synology DSM integration at the same time. Don’t know whether this is important.

What is version of Home Assistant Core has the issue?

core-2021.2.0

What was the last working version of Home Assistant Core?

No response

What type of installation are you running?

Home Assistant Container

Integration causing the issue

foscam

Link to integration documentation on our website

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

Example YAML snippet

# Put your YAML below this line
### Foscam
 - platform: foscam
   name: Foscam
   ip: 192.168.0.11
   rtsp_port: 88
   username: !secret foscam_usr
   password: !secret foscam_pwd

Anything in the logs that might be useful for us?

# Put your logs below this line
2021-02-03 21:26:11 ERROR (MainThread) [homeassistant.components.foscam] Unexpected exception
Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/components/foscam/config_flow.py", line 76, in async_step_user
return await self._validate_and_create(user_input)
File "/usr/src/homeassistant/homeassistant/components/foscam/config_flow.py", line 63, in _validate_and_create
await self.async_set_unique_id(response["mac"])
KeyError: 'mac'

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Comments: 23 (9 by maintainers)

Most upvoted comments

Thanks everyone for checking. I’ve changed the code to avoid requiring a user with admin rights.

Once is merged and released you will be able to either add the cameras manually or letting home assistant import them from your old configuration.yaml.

@dannytsang I’m afraid that’s not possible. Sorry.

The old way of configuration is deprecated and automatically imported using the new config flow.

I’ll do everything I can so HA can ship the fix in the next bug fix release.

@skgsergio Thanks for this. I suspect its related to the way I have setup the accounts. When I use an admin account it gives me:

<CGI_Result>
    <result>0</result>
    <productName>R2+V3</productName>
    <serialNo>0000000000000001</serialNo>
    <devName>R2</devName>
    <mac>00626E8245E3</mac>
    <year>2021</year>
    <mon>2</mon>
    <day>3</day>
    <hour>22</hour>
    <min>38</min>
    <sec>11</sec>
    <timeZone>0</timeZone>
    <firmwareVer>2.71.1.79_p2</firmwareVer>
    <hardwareVer>1.11.1.13</hardwareVer>
    <pkgTime>2020-04-22_09%3A27%3A39</pkgTime>
</CGI_Result>

The account I use in Home Assistant is set to “Operator”. Using an admin level account I was able to successfully add the camera using the integration UI which wasn’t a requirement before.

@jgverweij would be great if you can paste the output of opening in your browser:

http://CAMERA_IP:CAMERA_PORT/cgi-bin/CGIProxy.fcgi?cmd=getDevInfo&usr=CAMERA_USERNAME&pwd=CAMERA_PASSWORD

The port is tipically 88.

I know you didn’t ask but here’s my output from that link:

<CGI_Result>
    <result>-3</result>
</CGI_Result>

The fix was released in 2021.2.2. Can you confirm you have it working now? @jgverweij @dannytsang @Bettinaglio

@skgsergio The same problem indeed, without admin rights returns -3. With the correct userinfo with admin rights:

<CGI_Result>
    <result> 0 </result>
    <productName> ICS2010 </productName>
    <serialNo> 0000000000000001 </serialNo>
    <devName> Foscam </devName>
    <mac> 00626ED8C98A </mac>
    <year> 2021 </year>
    <mon> 2 </mon>
    <dag> 4 </dag>
    <hour> 8 </hour>
    <min> 0 </min>
    <sec> 25 </sec>
    <timeZone> -3600 </timeZone>
    <firmwareVer> 2.102.2.26 </firmwareVer>
    <hardwareVer> 1.14.2.4 </hardwareVer>
    <pkgTime> 2020-11-07_14% 3A36% 3A26 </pkgTime>
</CGI_Result>

Same problem here (did not change previous configuration which worked fine until 2021.1.5 yet but both Foscam’s (FI…Models) are not available under 2021.2.0).

Installed models: FI9803P V4 FI9800P V3 Firmware: 1.12.5.4 1.12.5.4 Application FW: 2.84.2.35 2.84.2.35 Plug-In: 5.2.1.2 5.2.1.2

Both cameras work fine in the Browser where they have different port assigned. (88 and 8085)

First Camera: <CGI_Result> <result>0</result> <productName>FI9803P+V4</productName> <serialNo>0000000000000001</serialNo> <devName>Cancello-Cam</devName> <mac>00626E8B7E27</mac> <year>2021</year> <mon>2</mon> <day>4</day> <hour>7</hour> <min>30</min> <sec>22</sec> <timeZone>-3600</timeZone> <firmwareVer>2.84.2.35</firmwareVer> <hardwareVer>1.12.5.4</hardwareVer> <pkgTime>2018-09-17_09%3A31%3A33</pkgTime> </CGI_Result> Second Camera: <CGI_Result> <result>0</result> <productName>FI9800P+V3</productName> <serialNo>0000000000000001</serialNo> <devName>LagoCam</devName> <mac>00626EA2C57A</mac> <year>2021</year> <mon>2</mon> <day>4</day> <hour>8</hour> <min>28</min> <sec>53</sec> <timeZone>-7200</timeZone> <firmwareVer>2.84.2.35</firmwareVer> <hardwareVer>1.12.5.4</hardwareVer> <pkgTime>2018-09-17_09%3A31%3A33</pkgTime> </CGI_Result>

Went back to 2021.1.5 Full BackUp and everything works well again. Maybe we should seriously considering in the future to leave the old configuration parallel until we are completely sure there is no issue left out there. Thanks for your work and an early solution on that issue.

The account I use in Home Assistant is set to “Operator”. Using an admin level account I was able to successfully add the camera using the integration UI which wasn’t a requirement before.

@dannytsang Thanks a lot! You discovered the issue, I’ll play around with an operator account in my cameras and try to get some kind of unique ID using the restricted account.

As the last resource I could use the IP Address which is not as good but will do the job…

Same result: <CGI_Result> <result>-3</result> </CGI_Result> With other user it becomes -2

@jgverweij -2 means wrong user/password, when it gives you -3 are you using also a non admin account?

I know you didn’t ask but here’s my output from that link:

<CGI_Result>
    <result>-3</result>
</CGI_Result>

Thanks! Interesting, -3 according to the docs is access deny.

IMG_20210203_232509.jpg

First of all there is a bug in the code on my side since is not handling that error.

On the other hand is like that command doesn’t exist in your camera, which… is bad. I will check this and try to look for an alternative for this cameras.

Tested with models: R2, R4, R2M

OK, so looks like is related to non FI models.

Please can you gather this info for me? -> https://github.com/home-assistant/core/issues/45921#issuecomment-772859233

Maybe they change the key in R and C models or they just don’t expose it. Let’s see if the key name is different or if we can just use the serial number.