OPNsense
  • Home
  • Help
  • Search
  • Login
  • Register

  • OPNsense Forum »
  • English Forums »
  • General Discussion »
  • need help with wol api
« previous next »
  • Print
Pages: [1]

Author Topic: need help with wol api  (Read 3760 times)

pear

  • Newbie
  • *
  • Posts: 1
  • Karma: 0
    • View Profile
need help with wol api
« on: February 03, 2019, 02:45:52 pm »
hello

please can someone help me with WOL API?
i am able to wake all already defined computers at once with "wakeall" but i have no idea how to wake just one computer from list or with manually defined interface and mac
Code: [Select]
curl -XPOST -d '' -k -u "$key":"$secret" "https://$opnsenseIP:port/api/wol/wol/wakeall"
with getHost i can see from output that correct interface is selected with defined mac and description
Code: [Select]
curl -XPOST -d '' -k -u "$key":"$secret" "https://$opnsenseIP:port/api/wol/wol/getHost/$uuid"getHost output:
....."lan":{"value":"correct interface name","selected":1}....."mac":"correct mac","descr":"my description"}}

many thanks
Logged

maweber

  • Newbie
  • *
  • Posts: 19
  • Karma: 0
    • View Profile
Re: need help with wol api
« Reply #1 on: December 31, 2019, 12:41:44 am »
see
https://github.com/opnsense/plugins/blob/9e45c51384e276a785ac09502e10f7faf20739c9/net/wol/src/opnsense/mvc/app/views/OPNsense/Wol/index.volt#L63

try the "set" command and probably pass uuid either in GET or the JSON body.

didn't test, i'm on a different mission.

m
Logged

maweber

  • Newbie
  • *
  • Posts: 19
  • Karma: 0
    • View Profile
Re: need help with wol api
« Reply #2 on: December 31, 2019, 03:40:54 am »
Code: [Select]
#Will trigger an existing uuid:
POST /wol/wol/set {uuid: 6def5e9b-ebb5-409d-ab52-912c06be7dc2}

#Will trigger a manual/undefined wake:
POST /wol/wol/set {wake: {interface: "opt22", mac: "b4:2e:99:30:da:dd"}}

#Will add a new host to the list:
POST /wol/wol/addHost {host: {interface: "opt22", mac: "b4:2e:99:30:da:dd", descr: "My Hamster"}}

The stuff in brackets is the body of the post, a json encoded object (not array).
So except the basic auth, and the endpoint (ie. "/wol/wol/set"), all variables seem to be going into the body.

It is easy to sniff into the structure via browser dev tools. Some things are more structured than the DOCS show.
« Last Edit: December 31, 2019, 03:43:52 am by maweber »
Logged

derhelge

  • Newbie
  • *
  • Posts: 14
  • Karma: 1
    • View Profile
Re: need help with wol api
« Reply #3 on: September 26, 2023, 05:01:09 pm »
It's been a while since this thread but in case anyone stumbles across it: https://gist.github.com/derhelge/1ce6d31f106beea37dfcb36591ac63a7 There is a small Powershell script. We use it to be able to continue using WOL via SCCM / configmgr.
Logged

  • Print
Pages: [1]
« previous next »
  • OPNsense Forum »
  • English Forums »
  • General Discussion »
  • need help with wol api
 

OPNsense is an OSS project © Deciso B.V. 2015 - 2024 All rights reserved
  • SMF 2.0.19 | SMF © 2021, Simple Machines
    Privacy Policy
    | XHTML | RSS | WAP2