Lora App Server deactivate device?

Is it possible to deactivate a device within the LoRa App Server UI?

1 Like

Not through the UI (currently), but you can using the API:

1 Like

hi @brocaar

this API Call deactivates a device, this works for me so far.
but when a device goes back into the join status and starts joining again, it can join and is “active” again.

is there a way to “pause” the device - so after “pausing” the device, even join requests will be ignored?

thanks and regards,
Sil

does anyone know about this topic? is there a real “pause” function? not only delete activation?

Were you looking to disable the device on the application server?

You can use grpc to update the is_disabled parameter

With this disabled the application also ignore the Join Request

Thank you for your answer @zul

i tried this, but somehow it does not work:

if __name__ == "__main__":
  # Connect without using TLS.
  channel = grpc.insecure_channel(server)

  # Device-queue API client.
  client = api.DeviceServiceStub(channel)

  # Define the API key meta-data.
  auth_token = [("authorization", "Bearer %s" % api_token)]
  # Construct request.
  req = api.UpdateDeviceRequest ()
  req.device.dev_eui = "HERE IS THE DEV_EUI"
  req.device.is_disabled = True
  req.device.device_profile_id = "HERE-IS-THE-DEVICE-PROFILE-ID"
  req.device.name = "F2"
  req.device.application_id = 11

  resp = client.Update(req, metadata=auth_token)

  # Print the downlink frame-counter value.
  print(resp)

The response is emptry - so there is only printed a empty line.

When i then send a join request from the Device, it is still accepted. See the Image bellow:

Any idaes? Maybe one last thing - when i use the GetDeviceRequest to list this device, i see the following:

device {
  dev_eui: "DEV_EUI IS HERE"
  name: "F2"
  application_id: 11
  device_profile_id: "DEVICE_PROFILE IS HERE"
}
last_seen_at {
  seconds: 1635942528
  nanos: 286322000
}
device_status_battery: 78
device_status_margin: 7

The Device does not have a is_disabled True/False at the device section.

Any help is very appreciated. Thanks,
Sil

You can try getting the device, the disabling it like below:

...
        req = api.GetDeviceRequest()
        req.dev_eui = dev_eui
        resp = client.Get(req, metadata=auth_token)

        req = resp
        req.device.is_disabled = state
        resp = client.Update(req, metadata=auth_token)
...

thanks again, here the script:

  # Construct request.
  req = api.GetDeviceRequest ()
  req.dev_eui = dev_eui
  resp = client.Get(req, metadata=auth_token)
  print(resp)

  req = resp
  req.device.is_disabled = True
  resp1 = client.Update(req, metadata=auth_token)
  print(resp1)

output is the same as before (for resp1) - so just a empty line.
and the device still accepts join requests…

i am on a older chirpstack version - Application Server is 3.6.1 while Network Server is 3.6.0.
Could it be related to this?

(i know, i need to update…)

I think so, I see that it is a feature that is added on version 3.11.0

https://www.chirpstack.io/application-server/changelog/#v3110

Oh my god, I could have found this myself…
many thanks,
sil

You’re responsiveness on this forum is always appreciated @brocaar :pray:

I had seen this in the API before now, but I always understood it as removing any session (join) parameters (devAddr, fCnt, …).

Will this block rejoin requests also, or is an inevitable rejoin what you mean by “temporarily” in the changelog?

The DELETE ...../activation endpoint removes the device-session. If the device sends a new join-request, it will continue to work. Please note that you can disable individual devices too.

1 Like

Ok, I wasn’t clear on whether disable device and deactivate were two different features. Turns out they’re not.

Still a great feature to have. Thanks again for your responsiveness.

But they are?

A disabled device can re-join (OTAA), where a deactivated device can. Thus:

  • You deactive the device, then the NS stops handling data until the device re-joins (OTAA)
  • You disable the device, then the NS stops handling data, but also does not handle re-joins (OTAA)
2 Likes

Aha, I see now what was so obvious. Thanks brocaar and sorry for the late reply.

If I can elaborate on my error, in case I can spare anyone else my pain:
I was looking high and low for a “disable” api endpoint to disable a device, similar to the DELETE /api/device/{dev_eui}/activation method. When I didn’t find one, I jumped to my above conclusion. Of course what I was looking for was in PUT /api/devices/{device.dev_eui}.

Thank you very much for your reply, however is it possible to disable the device using APIs like in the browser mode.

Under Devices → Configuraion → There is check box to disable device but it did not have any effect with the above command


Is there any way possible to do it using REST API (Curl)

Thanks and Regards
N

You can find all examples how to use REST API in the /#api/ page

curl -X DELETE --header ‘Accept: application/json’ your_Chirpstack-URL:8080/api/devices/needed-dev-eui/activation’