MMMMobileAlerts icon indicating copy to clipboard operation
MMMMobileAlerts copied to clipboard

Reading data from the cloud... not successful

Open NoPlayBack opened this issue 2 years ago • 3 comments

Hi there,

i was trying to make use from your documentation here: https://github.com/sarnau/MMMMobileAlerts/blob/master/MobileAlertsGatewayApplicationAPI.markdown as far as i understand there is the possibility to fetch sensor data from all available sensors with this interface? Did try to use that code within Python, and did run into some issues:

"request += '&timestamp=%s' % datetime.datetime.utcnow().strftime("%s") # current UTC timestamp" seems as if %s formating code is not valid any more? Did use "request += '&timestamp=%s' % datetime.datetime.utcnow().timestamp()" instead.

Not sure where to place my sensor ids... should they be listed in sensors = [] ???

Also not sure how to work with UUID, where can i find more information about this?

Trying to run that code but the result was "errorcode 1051, The request parameters are invalid"

Is this (creating an issue) the correct way to ask questions or is there a community somewhere which i can contact to get some help here?

NoPlayBack avatar May 21 '23 15:05 NoPlayBack

I also have a problem reading the data, always getting a timeout. Does the server still support these queries?

payload is:
devicetoken=empty&vendorid=BE60BB85-EAC9-4C5B-8885-1A54A9D51E29&phoneid=Unknown&version=1.21&build=248&executable=Mobile Alerts&bundle=de.synertronixx.remotemonitor&lang=en&timezoneoffset=60&timeampm=true&usecelsius=true&usemm=true&speedunit=0&timestamp=1728737523&requesttoken=ba5e956d4832515f0b26c97f08539185&deviceids=0836C6E3AF5E

Traceback (most recent call last):
  File "/home/pi/./getMobileAlertsData.py", line 56, in <module>
    conn.request("POST", "/api/v1/dashboard", payload, headers)
  File "/usr/lib/python3.11/http/client.py", line 1282, in request
    self._send_request(method, url, body, headers, encode_chunked)
  File "/usr/lib/python3.11/http/client.py", line 1328, in _send_request
    self.endheaders(body, encode_chunked=encode_chunked)
  File "/usr/lib/python3.11/http/client.py", line 1277, in endheaders
    self._send_output(message_body, encode_chunked=encode_chunked)
  File "/usr/lib/python3.11/http/client.py", line 1037, in _send_output
    self.send(msg)
  File "/usr/lib/python3.11/http/client.py", line 975, in send
    self.connect()
  File "/usr/lib/python3.11/http/client.py", line 1447, in connect
    super().connect()
  File "/usr/lib/python3.11/http/client.py", line 941, in connect
    self.sock = self._create_connection(
                ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/socket.py", line 851, in create_connection
    raise exceptions[0]
  File "/usr/lib/python3.11/socket.py", line 836, in create_connection
    sock.connect(sa)
TimeoutError: [Errno 110] Connection timed out

monojk avatar Oct 12 '24 15:10 monojk

I finally made it to get the data, and i am using python and requests to receive data from all sensors i have. Using this: r = requests.post('https://www.data199.com/api/pv1/device/lastmeasurement', data={"deviceids": id_list, "phoneid": '123456789123'}, timeout=60).json() The id_list is a string with all sensor-ids separated by a comma, like this: '031234567897,041234567897,035454545454,049876546589,'

NoPlayBack avatar Oct 13 '24 08:10 NoPlayBack

I use that also for normal sensors. But with the rain sensor, the data is the accumulated rain since the start of using that device.

I want to get the current rain data which is a delta of the last measurements. That data is there https://measurements.mobile-alerts.eu/ available in the browser (firefox or chrome) with security off because the https certificate of that server expired last Friday. And with python code I can't access the webpage.

Any idea how to access the http webpage measurements.mobile-alerts.eu instead of https with python?

With conn = http.client.HTTPSConnection(url) I get

  File "/usr/lib/python3.11/ssl.py", line 1379, in do_handshake
    self._sslobj.do_handshake()
ssl.SSLCertVerificationError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: certificate has expired (_ssl.c:992)

With conn = http.client.HTTPConnection(url) I get

301 Moved Permanently

monojk avatar Oct 13 '24 08:10 monojk