RUT956 - Where is Post/Get now?

Hi

I updated to FW RUT9M_R_00.07.14.3

I had a service that read the pin=adc0. I got a unexpected value. So I want to check check it.

But, my litle python code don’t work anymore:

AuxBatteryVoltage = http.request(‘GET’, ‘http://192.168.1.1/cgi-bin/io_value?username=XXXXX&password=YYYYYY&pin=adc0’)

Before (RUT9M_R_00.07.13.2), under “Services->Input/Outpu → Post/Get” it was available to setup POST/GET settings. But it is not there anymore.

How can I get i back?

Regards Terje

Hello,

Starting from firmware RUT9M_R_00.07.14.0, the POST/GET services were completely withdrawn. You can find more details on this change here:

As an alternative, to read the analog input value (adc0), you can now utilize the device’s API requests. Full documentation on available API endpoints and request examples can be found here:

https://developers.teltonika-networks.com/reference/rut956/7.14.3/v1.6.3/input-output

If you have any additional questions or need assistance, feel free to reach out.

Best regards,

Hi

I am now able to read the value of adc0 using /io/adc0/status.

But, I also need to close / open “relay0”. I don’t find any end point for doing so. (I thought that /io/{id}/actions/change_state can do it, but after reading the doc I realised it can not). Please advise.

Regards Terje

Hello Terje,

To control relay0 (open or close it) through API, you should use the following endpoint:

/api/io/relay0/actions/change_state

This should be called using the POST method, and the request body needs to include the "state" parameter with a value of either "open" or "closed".

Example JSON body:

Click to expand
{
  "state": "closed"
}

or

{
  "state": "open"
}

If you run into any issues implementing this or have additional questions, feel free to reach out.

Best regards,

Hi

It worked. Here is my code, just to make it easier for the next one with the same or simular problem:

self.base_url = “http://192.168.1.1/api

    def OpenRelay(self) -> bool:
        headers = {"Authorization": f"Bearer {self.token}"}
        url = f"{self.base_url}/io/relay0/actions/change_state"
        try:
            response = requests.post(url, headers=headers, json={"data": {"state": "open"}})
            response.raise_for_status()

            if response.status_code == 200:
                response_data = response.json()
                print(f"response_data: {response_data}")
                return response_data
            else:
                print(f"Unexpected status code: {response.status_code}")
                return False
        except requests.exceptions.RequestException as e:
            print(f"Error: {e}")
            return False

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.