EnergieID / smappy

Python client for Smappee
MIT License
21 stars 8 forks source link

New smappee software changes local commandControl interface #26

Open FunkyM opened 6 years ago

FunkyM commented 6 years ago

As the title says the current LocalSmappee does no longer work due to changes in the commandControl interface. The current calls return a HTTP Status 500.

I implemented the following to make it work:

    def get_statistics_report(self):
        """
        Returns
        -------
        dict
        """
        r = self._basic_get(url='statisticsPublicReport')
        return r.json()

    def on_command_control(self, val_id):
        """
        Parameters
        ----------
        val_id : str

        Returns
        -------
        requests.Response
        """
        data = "control,{\"controllableNodeId\":\"" + val_id + "\",\"action\":\"ON\"}"
        return self._basic_post(url='commandControlPublic', data=data)

    def off_command_control(self, val_id):
        """
        Parameters
        ----------
        val_id : str

        Returns
        -------
        requests.Response
        """
        data = "control,{\"controllableNodeId\":\"" + val_id + "\",\"action\":\"OFF\"}"
        return self._basic_post(url='commandControlPublic', data=data)

Calling "get_statistics_report" which is an oddly named call to get information about smappee returns:

[
  {
    "key": "WIFI & networking"
  },
  {
    "value": "59/70 ",
    "key": "Link quality"
  },
  {
    "value": "-51 dBm dbm (>-35 excellent) (<-35 >-65 good) (<-65 poor)",
    "key": "Signal strength"
  },
  {
    "value": "SOMESSID",
    "key": "SSID"
  },
  {
    "value": "/192.168.1.20",
    "key": "Bound IP address"
  },
  {
    "key": "Monitor application"
  },
  {
    "value": "XXXXXX\n",
    "key": "Nr of features received from acquisition engine"
  },
  {
    "value": "29/03/2018 09:46:10\n",
    "key": "Last software update"
  },
  {
    "value": "1.0.0S buildNr #1185\n",
    "key": "Application software version and build nr"
  },
  {
    "value": "4.29\n",
    "key": "Acquisition Software version"
  },
  {
    "value": "three phase 120d (star or delta)\n",
    "key": "EMeter working config"
  },
  {
    "value": "SmappeeT\n",
    "key": "EMeter type"
  },
  {
    "value": "XXXXXXXXXX\n",
    "key": "Serial ID"
  },
  {
    "value": "8",
    "key": "OS build nr"
  },
  {
    "value": "N/A",
    "key": "Gas/Water sensors"
  },
  {
    "value": "Central European Time",
    "key": "Timezone"
  },
  {
    "value": "04/04/2018 20:51:40",
    "key": "Time&Date"
  }
]

Some of the data was masked by me with 'X'.

I assume the solution would be to check for the smappee software version during logon and depending on it use the legacy or new interface.

JrtPec commented 6 years ago

Do Smappees auto-update? I mean: can we assume that all devices are affected by this change, so we don't have to support 2 interfaces?

If not: do we know what software version to check for?

martintamke commented 6 years ago

Hello Jan, Smappee has some kind of Auto-update mechanism. My Smapee (1,5 years old) has updated itself. The statistic Info shows "27/03/2018 19:07:03" as date for Last software update. The values for "Application software version and build nr " are " 1.0.0S buildNr #1185" The local Smappee works perfect in my system.

The info, which Martin S. posted above , shows "29/03/2018 09:46:10" as date of last update. However application software version and build nr. are the same "1.0.0S buildNr #1185\n"

My assumption is, that Smappe notes,when it is looking for an update (Last software update) rather the point in time, when it is actually performing an update? A bit mysterious, that the buildNr are the same, but the required local Smappee code is different.

JrtPec commented 6 years ago

So if I understand it correctly, you both have a Smappee with the same software version and build number, yet the current code works for @martintamke and not for @FunkyM? Aren't we missing something here?