Closed d1nc174 closed 1 day ago
Yes, unfortunately that is correct. Because I have created a separate API, I wanted to protect the backend against direct calls. As I don't use the "Homepage" project myself, I wasn't aware of the implications. I would present you with a hot fix here, but would not revert the change in the code for the time being, unless more people get in touch.
Open this file and scroll to this line. https://github.com/leiweibau/Pi.Alert/blob/0f2d275ee7c0489443b89caacb9400b5055b9d0a/front/php/server/devices.php#L15
Change this
if ($_SESSION["login"] != 1) {
header('Location: ../../index.php');
exit;
}
to that
// if ($_SESSION["login"] != 1) {
// header('Location: ../../index.php');
// exit;
// }
wow, thank you very much for a fast response and a hot fix for my setup.. I'll try it right away.. Have a nice day!
I might also adjust the condition so that the backend is both a little more secure, but this particular request is still answered.
I tried it but it's still showing 0 for all devices. I restarted the lxc with PiAlert after changing this few lines. can you advise please.
Sorry, my fault. In addition to the change already mentioned, the function used here has been given an additional parameter as part of the satellite extension. This is of course generated and passed on within the web interface, but must be transmitted separately when called directly.
The link to be called now would be: "/php/server/devices.php?action=getDevicesTotals&scansource=local"
I could also install a fallback here. There is actually a fallback, but it is in the frontend.
ok.. I'll try to add this link to the widget and see if it works..
This should no longer be necessary after the next update. However, if you adjust it now, it can remain after the update, as it will not cause any issues.
I put the updated link in the widget.js but it still shows me 0es, but in the browser when i try this link it shows the correct numbers.. I also tried to use the netalertx widget and change the link there but it still shows 0es what am I doing wrong?
If you can, go back to the original status from 4 hours ago when you reported the issue. In the next 2-3 days I will release an update which should restore the functionality.
ok. thnx I'll do that.
Would love to see an official widget for homepage, too ;-)
I took 2-3 hours of my time today and had a look at the homepage.dev project. If a small change is made to the API with the next update, then everything should work with the code below. Then even with activated password protection.
widget:
type: customapi
url: https://<IP or Hostname>/pialert/api/?get=system-status&api-key=<Your API Key>
refreshInterval: 10000
mappings:
- field: All_Devices
label: All Devices
type: number
- field: Offline_Devices
label: Offline
type: number
- field: Online_Devices
label: Online
type: number
- field: New_Devices
label: New
type: number
... or with a little more effort
- Pi.Alert:
href: https://<IP or Hostname>/pialert/
descriptionn: Network Scanner
icon: https://<IP or Hostname>/pialert/img/favicons/flat_red_white.png
widget:
type: customapi
url: https://<IP or Hostname>/pialert/api/?get=system-status&api-key=<Your API Key>
refreshInterval: 10000
display:
mappings:
- field: All_Devices
label: All
type: number
- field: Offline_Devices
label: Offline
type: number
- field: Online_Devices
label: Online
type: number
- field: New_Devices
label: New
type: number
Really awesome! Thanks very mich indeed!
The API used returns these fields. If necessary, you can still make some adjustments here.
"Scanning":"<String>",
"Last_Scan":"<String>",
"All_Devices":<Integer>,
"Offline_Devices":<Integer>,
"Online_Devices":<Integer>,
"Archived_Devices":<Integer>,
"New_Devices":<Integer>,
"All_Devices_ICMP":<Integer>,
"Offline_Devices_ICMP":<Integer>,
"Online_Devices_ICMP":<Integer>,
"All_Services":<Integer>
Awsome indeed! And thank you for finding some time to solve this very niche thing for some of us who use Homepage in their home labs.. Keep the good work and have a nice day.
I will make a small extension to the API documentation later today, in which I will address this issue so that I can refer to the documentation in the future.
Hi, First i want to thank you for your good work. Your fork of Pi.Alert is working very well for my setup on an Proxmox LXC together with Pihole. I have also Homepage installed on my server with a widget for Pi.Alert which was working well until the last update of Pi.Alert. I know that its not working through your API but it's accessing the device list directly with..
"{url}/php/server/devices.php?action=getDevicesTotals"
but after the last update it returns only 0 for all devices. Can you please help me with this.. Thnx and have a nice day.