the-louie / sectoralarm

MIT License
19 stars 10 forks source link

Sector Alarm has refactored the web page. Data is now available as Json objects #3

Closed paalkr closed 7 years ago

paalkr commented 7 years ago

Some days ago the Norwegian (and probably also the Swedish) web pages for Sector Alarm has been totally refactored. The bad news is that the current login code does not work anymore. The good news is that data can be retrieved as json, so no more need to parse html ;). The code can then probably be greatly simplified.

A request like https://minside.sectoralarm.no/Panel/GetPanelHistory/ will provide a nice json that should be pretty easy to process in python.

Example taken from my system, while logged on in a web browser

{
  "Status": "success",
  "Message": "ok",
  "LogDetails": [
    {
      "Time": "/Date(1497956292000)/",
      "EventType": "disarmed",
      "User": "3",
      "Channel": "",
      "LockName": "home.event.disarming"
    },
    {
      "Time": "/Date(1497938414000)/",
      "EventType": "armed",
      "User": "Panel",
      "Channel": "Betjeningspanel",
      "LockName": "home.event.arming"
    },
    {
      "Time": "/Date(1497698277000)/",
      "EventType": "disarmed",
      "User": "1",
      "Channel": "",
      "LockName": "home.event.disarming"
    },
    {
      "Time": "/Date(1497690532000)/",
      "EventType": "armed",
      "User": "Panel",
      "Channel": "Betjeningspanel",
      "LockName": "home.event.arming"
    },
    {
      "Time": "/Date(1497602048000)/",
      "EventType": "disarmed",
      "User": "2",
      "Channel": "",
      "LockName": "home.event.disarming"
    },
    {
      "Time": "/Date(1497595104000)/",
      "EventType": "armed",
      "User": "Panel",
      "Channel": "Betjeningspanel",
      "LockName": "home.event.arming"
    },
    {
      "Time": "/Date(1497377300000)/",
      "EventType": "disarmed",
      "User": "1",
      "Channel": "",
      "LockName": "home.event.disarming"
    },
    {
      "Time": "/Date(1497369127000)/",
      "EventType": "armed",
      "User": "Panel",
      "Channel": "Betjeningspanel",
      "LockName": "home.event.arming"
    },
    {
      "Time": "/Date(1497276461000)/",
      "EventType": "disarmed",
      "User": "1",
      "Channel": "",
      "LockName": "home.event.disarming"
    },
    {
      "Time": "/Date(1497248538000)/",
      "EventType": "armed",
      "User": "Panel",
      "Channel": "Betjeningspanel",
      "LockName": "home.event.arming"
    },
    {
      "Time": "/Date(1497203733000)/",
      "EventType": "disarmed",
      "User": "2",
      "Channel": "",
      "LockName": "home.event.disarming"
    },
    {
      "Time": "/Date(1497085424000)/",
      "EventType": "armed",
      "User": "Panel",
      "Channel": "Betjeningspanel",
      "LockName": "home.event.arming"
    },
    {
      "Time": "/Date(1496991125000)/",
      "EventType": "disarmed",
      "User": "1",
      "Channel": "",
      "LockName": "home.event.disarming"
    },
    {
      "Time": "/Date(1496988150000)/",
      "EventType": "armed",
      "User": "Panel",
      "Channel": "Betjeningspanel",
      "LockName": "home.event.arming"
    },
    {
      "Time": "/Date(1496832636000)/",
      "EventType": "disarmed",
      "User": "Ukjent bruker",
      "Channel": "App/Web",
      "LockName": "home.event.disarming"
    },
    {
      "Time": "/Date(1496832555000)/",
      "EventType": "armed",
      "User": "Ukjent bruker",
      "Channel": "App/Web",
      "LockName": "home.event.arming"
    },
    {
      "Time": "/Date(1496319159000)/",
      "EventType": "disarmed",
      "User": "3",
      "Channel": "",
      "LockName": "home.event.disarming"
    },
    {
      "Time": "/Date(1496296846000)/",
      "EventType": "armed",
      "User": "Panel",
      "Channel": "Betjeningspanel",
      "LockName": "home.event.arming"
    },
    {
      "Time": "/Date(1496229995000)/",
      "EventType": "disarmed",
      "User": "3",
      "Channel": "",
      "LockName": "home.event.disarming"
    },
    {
      "Time": "/Date(1496210549000)/",
      "EventType": "armed",
      "User": "Panel",
      "Channel": "Betjeningspanel",
      "LockName": "home.event.arming"
    },
    {
      "Time": "/Date(1495980289000)/",
      "EventType": "disarmed",
      "User": "2",
      "Channel": "",
      "LockName": "home.event.disarming"
    },
    {
      "Time": "/Date(1495703890000)/",
      "EventType": "armed",
      "User": "Panel",
      "Channel": "Betjeningspanel",
      "LockName": "home.event.arming"
    },
    {
      "Time": "/Date(1495387768000)/",
      "EventType": "disarmed",
      "User": "2",
      "Channel": "",
      "LockName": "home.event.disarming"
    },
    {
      "Time": "/Date(1495380457000)/",
      "EventType": "armed",
      "User": "Panel",
      "Channel": "Betjeningspanel",
      "LockName": "home.event.arming"
    },
    {
      "Time": "/Date(1495298154000)/",
      "EventType": "disarmed",
      "User": "2",
      "Channel": "",
      "LockName": "home.event.disarming"
    },
    {
      "Time": "/Date(1495270547000)/",
      "EventType": "armed",
      "User": "Panel",
      "Channel": "Betjeningspanel",
      "LockName": "home.event.arming"
    },
    {
      "Time": "/Date(1495109779000)/",
      "EventType": "disarmed",
      "User": "1",
      "Channel": "",
      "LockName": "home.event.disarming"
    },
    {
      "Time": "/Date(1495099343000)/",
      "EventType": "armed",
      "User": "Panel",
      "Channel": "Betjeningspanel",
      "LockName": "home.event.arming"
    },
    {
      "Time": "/Date(1495099312000)/",
      "EventType": "disarmed",
      "User": "1",
      "Channel": "",
      "LockName": "home.event.disarming"
    },
    {
      "Time": "/Date(1495019783000)/",
      "EventType": "disarmed",
      "User": "3",
      "Channel": "",
      "LockName": "home.event.disarming"
    },
    {
      "Time": "/Date(1495003916000)/",
      "EventType": "armed",
      "User": "Panel",
      "Channel": "Betjeningspanel",
      "LockName": "home.event.arming"
    },
    {
      "Time": "/Date(1494851141000)/",
      "EventType": "disarmed",
      "User": "3",
      "Channel": "",
      "LockName": "home.event.disarming"
    },
    {
      "Time": "/Date(1494829693000)/",
      "EventType": "armed",
      "User": "Panel",
      "Channel": "Betjeningspanel",
      "LockName": "home.event.arming"
    },
    {
      "Time": "/Date(1494245671000)/",
      "EventType": "disarmed",
      "User": "3",
      "Channel": "",
      "LockName": "home.event.disarming"
    },
    {
      "Time": "/Date(1494226095000)/",
      "EventType": "armed",
      "User": "Panel",
      "Channel": "Betjeningspanel",
      "LockName": "home.event.arming"
    },
    {
      "Time": "/Date(1494226048000)/",
      "EventType": "disarmed",
      "User": "2",
      "Channel": "",
      "LockName": "home.event.disarming"
    },
    {
      "Time": "/Date(1494225965000)/",
      "EventType": "armed",
      "User": "Panel",
      "Channel": "Betjeningspanel",
      "LockName": "home.event.arming"
    },
    {
      "Time": "/Date(1493814356000)/",
      "EventType": "disarmed",
      "User": "2",
      "Channel": "",
      "LockName": "home.event.disarming"
    },
    {
      "Time": "/Date(1493790565000)/",
      "EventType": "armed",
      "User": "Panel",
      "Channel": "Betjeningspanel",
      "LockName": "home.event.arming"
    },
    {
      "Time": "/Date(1493722861000)/",
      "EventType": "disarmed",
      "User": "1",
      "Channel": "",
      "LockName": "home.event.disarming"
    },
    {
      "Time": "/Date(1493704236000)/",
      "EventType": "armed",
      "User": "Panel",
      "Channel": "Betjeningspanel",
      "LockName": "home.event.arming"
    },
    {
      "Time": "/Date(1493566654000)/",
      "EventType": "disarmed",
      "User": "2",
      "Channel": "",
      "LockName": "home.event.disarming"
    },
    {
      "Time": "/Date(1493530722000)/",
      "EventType": "armed",
      "User": "Panel",
      "Channel": "Betjeningspanel",
      "LockName": "home.event.arming"
    },
    {
      "Time": "/Date(1493530614000)/",
      "EventType": "disarmed",
      "User": "2",
      "Channel": "",
      "LockName": "home.event.disarming"
    },
    {
      "Time": "/Date(1493530206000)/",
      "EventType": "armed",
      "User": "Panel",
      "Channel": "Betjeningspanel",
      "LockName": "home.event.arming"
    },
    {
      "Time": "/Date(1493530141000)/",
      "EventType": "disarmed",
      "User": "1",
      "Channel": "",
      "LockName": "home.event.disarming"
    },
    {
      "Time": "/Date(1493036354000)/",
      "EventType": "disarmed",
      "User": "3",
      "Channel": "",
      "LockName": "home.event.disarming"
    },
    {
      "Time": "/Date(1493015573000)/",
      "EventType": "armed",
      "User": "Panel",
      "Channel": "Betjeningspanel",
      "LockName": "home.event.arming"
    },
    {
      "Time": "/Date(1492961641000)/",
      "EventType": "disarmed",
      "User": "2",
      "Channel": "",
      "LockName": "home.event.disarming"
    },
    {
      "Time": "/Date(1492938798000)/",
      "EventType": "armed",
      "User": "Panel",
      "Channel": "Betjeningspanel",
      "LockName": "home.event.arming"
    }
  ]
}

A POST request to https://minside.sectoralarm.no/Panel/GetOverview/ with PanelId= will give you another Json with the current status (the same history json object 0), but also a ton of other nice information objects regarding your system. Most interestingly stuff like smartplugs, temperature sensors and lock are mentioned in the list. Obviously Sector Alarm are planning to go all into the Smart Home business.


{
   "Panel":{
      "PanelId":"xxxxxxxx",
      "ArmedStatus":"disarmed",
      "StatusAnnex":"unknown",
      "PanelDisplayName":"Hjemme",
      "PartialAvalible":true,
      "AnnexAvalible":false,
      "PanelQuickArm":true,
      "PanelCodeLength":xxxxxxx,
      "IsOnline":false,
      "LockLanguage":1,
      "SupportsApp":true,
      "SupportsInterviewServices":true,
      "SupportsPanelUsers":true,
      "SupportsTemporaryPanelUsers":false,
      "PanelTime":"\/Date(1497956292000)\/",
      "InstallationStatus":3,
      "BookedStartDate":"\/Date(-62135596800000)\/",
      "BookedEndDate":"\/Date(-62135596800000)\/",
      "IVDisplayStatus":false,
      "DisplayWizard":false
   },
   "Locks":[

   ],
   "Smartplugs":[

   ],
   "Temperatures":[

   ]
}

Just as a reference, https://minside.sectoralarm.no/Settings/GetText?lang=nb , will give you the complete translation json object (for whom it might interest ;) ) And in Swedish https://minside.sectoralarm.no/Settings/GetText?lang=sv

the-louie commented 7 years ago

Thanks @paalkr! I'll look into this as soon as I can.

the-louie commented 7 years ago

Just pushed 0.6.0 to master that should work with the new API, please try it out @paalkr

paalkr commented 7 years ago

Thanks @the-louie , I will try out the new version later tonight.

paalkr commented 7 years ago

Hi. This works as far as I can tell. Thanks for taking time to update the code :)

the-louie commented 7 years ago

No problem, I just need to start to use it for real my self so I can spot these problems before you do :)