starkillerOG / reolink_aio

Reolink NVR/camera API PyPI package
MIT License
79 stars 16 forks source link

Calling email_enabled(channel), push_enabled(channel) throws KeyError: 'scheduleEnable' #41

Closed littledot closed 1 year ago

littledot commented 1 year ago

Describe the bug A clear and concise description of what the bug is.

Calling email_enabled(channel) on a RLN8-410 v3.0.0159_21122405 throws:

Traceback (most recent call last):
    ...
    return self._email_settings[channel]["Email"]["scheduleEnable"] == 1
KeyError: 'scheduleEnable'

This is because email_enabled(channel) queries the wrong field. Here's a partial dump of my hosts._email_settings

{
  "1": {
    "Email": {
      "addr1": "***@gmail.com",
      "addr2": "",
      "addr3": "",
      "attachmentType": 2,
      "diskErrorAlert": 0,
      "diskFullAlert": 0,
      "enable": 1,
      "interval": "5 Minutes",
      "nickName": "***",
      "password": "***********",
      "schedule": {
        "channel": 1,
        "table": {
          "AI_PEOPLE": "111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111",
          "AI_VEHICLE": "000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
          "MD": "000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
          "VL": "000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"
        }
      },
      "smtpPort": 587,
      "smtpServer": "smtp.office365.com",
      "ssl": 1,
      "supportTextType": 1,
      "supportVideo": 1,
      "textType": 1,
      "userName": "***@outlook.com"
    }
  },

https://github.com/starkillerOG/reolink_aio/blob/main/reolink_aio/api.py#L566C6-L567C81

The API is trying to query self._email_settings[channel]["Email"]["scheduleEnable"] == 1, when it should be self._email_settings[channel]["Email"]["enable"] == 1

push_enabled(channel) also suffers from the same issue.

To Reproduce Steps to reproduce the behavior. Pleaee provide the error from the log if possible.

Expected behavior A clear and concise description of what you expected to happen.

Screenshots If applicable, add screenshots to help explain your problem.

Environment: Please provide useful information about your environment, like:

Additional context Add any other context about the problem here.

starkillerOG commented 1 year ago

@littledot what hardware version of the RLN8-410 do you have, it seems like you are running a really old firmware version. Please update to V3.3... by downloading it from the Reolink download center: https://reolink.com/download-center/

Moreover, when you run: email_enabled() (withouth the channel) you will get the global setting you are reffering to and that is available also in old firmwares. Wen running email_enabled(channel) you will get the channel specific setting which is only available in the latest firmware. To receive emails from channel_x, both the global setting and the setting for channel_x need to be enabled.

Same thing for the set_email, set_email() controlls global setting, set_email(channel) the channel specific setting.

Are you using HomeAssistant?

littledot commented 1 year ago

I'm using this package directly with python3 w/o HomeAssistant. It looks like my firmware is indeed outdated at V3.0, I've updated to V3.3 and the issue is resolved.

Thanks for the response.

starkillerOG commented 1 year ago

@littledot good to hear the firmware update indeed resolved the problem. Sorry for the basically non existing documentation of this library, at some point I do want to write docs, but just did not have time to do it yet.

If you appreciate this library and want to support its development, please consider sponsering or purchase Reolink products through this affiliate link.