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)
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:
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.
I know you didn’t ask but here’s my output from that link:
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:
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.
@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…
@jgverweij -2 means wrong user/password, when it gives you -3 are you using also a non admin account?
Thanks! Interesting, -3 according to the docs is access deny.
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.
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.