Discord webhooks now implemented + sneak peek of my smarthome system
On the left screen you can see the Discord message notification about the message sent by my smarthome system. On the right you can see me configuring an event that runs every minute and calls the “/discord/sendMessageViaWebhook” endpoint, which, as the name implies, uses a webhook to write a message into a Discord channel (the webhook itself can be configured under “social media > discord”).
Pretty cool, as this is a little bit faster and also more reliable than push notifications (those need your browser running in the background, which isn’t always the case). The downside is that I can’t put click events into the notification.
Anyways, I might as well say a few words about the smarthome itself. As already mentioned in the past, it’s just a website running on a LAMP stack, with some fancy event management system and a few PHP daemons running in the background. You can see the website in the screenshot. Here are some technical this-and-thats:
The frontend is written with React. I’ve already written a post about this that goes into a bit more detail.
Per default websockets are used as a way to communicate between frontend and server. If websockets don’t work, the frontend falls back to AJAX calls.
Below the connection status are the functionalities of the system:
Administrative: Some Admin settings, as in, what endpoints do exist, what links show up where, access logs and DNS record updates (which are also automated via events, by the way)
Network: Shows a list of the wireless devices in my network. This obviously needs the coorperation of my router, which fortunately isn’t a problem as I have OpenWRT on mine.
Smarthome: Well, I’m calling this a smarthome system, and as such, it needs smarthome functions.
-> Blocks: Blocks are abstract ways for my hardware (for example laser barriers, see previous post) to store data in my system. Events can be triggered based on blocks
-> Devices: Just a registry of devices, which can be used as a way to control hardware directly sometimes in the future (blocks itself don’t know which device reads or writes to them, they’re just dumb containers of data). Not in use yet, as I don’t have any hardware in need of real time controls
-> Events: As seen in the screenshot, I can do a bunch of settings regarding events. What endpoint is called, with which parameters? How do I want to restrict the time at which the event is triggered, or how often? And most importantly, on what other events and blocks does the event depend on?
-> Surveillance: A way to organize and, if necessary, proxy cameras. I’m currently working on a way to easily setup interactive maps of blocks (think for example heatmaps or a map of doors / windows and their states), that’ll be included here.
Social media: Those are just accounts that can post something in case of an event, if wanted. For example, one of my first Arduino projects was building a device that tweets whenever the door next to it was opened. The same could be built with an event that triggers based on the input of one of my reed switches.
-> Discord: Adding and configuring webhooks.
-> Reddit: Adding and configuring reddit accounts.
-> Twitter: You get the concept.
-> Users: The normal user only sees his settings here. Admins have the option to create users, to organize them in groups and to configure their access to functionalities.