package
0.0.26-beta-rc.4
Repository: https://github.com/mikmuellerdev/smarthome.git
Documentation: pkg.go.dev
# Functions
Add a logged internal event based on `name, description, and level`.
Adds a new notification to a user's `inbox`, can return an error if the database fails.
Helper function to create a User which is given a set of basic permissions Will return an error if the database fails TODO: Remove business logic from here, move to core/user.
Adds a given cameraId to an arbitrary user The existence of the camera and the user should be validated beforehand.
Adds a permission to a user, if database fails, then an error is returned Does not check for username so additional checks should be completed beforehand.
Adds a given switchId to a given user The existence of the switch should be validated beforehand If this permission already resides inside the table, it is ignored and modified=false, error=nil is returned TODO: Remove useless check if user already has permission.
Executes a ping to the database in order to check if it is online.
Creates a new camera Checks, for example if the camera already exists should be completed beforehand.
Adds a new hardware node to the database, if the node already exists (same url), its name will be updated.
Creates a new automation item, does not check the validity of the user or the homescript Id.
Creates a new homescript entry.
Creates a new reminder in the database.
Creates a new schedule which represents a job of the scheduler.
Creates a new room given an arbitrary, non-existing id.
Creates a new switch Will return an error if the database fails.
Deletes all automations from a given user.
Deletes all Homescripts of a given user.
If the user requests to empty their notification area, all hist notifications will be deleted.
Deletes all reminders of a given user.
Deletes all schedules from a given user.
Deletes an automation item given its Id Does not validate the validity of the provided Id.
Deletes a camera, removes dependencies, such as camera-permission first Used in deleting all room cameras and deleting one camera.
Deletes a node given its url.
Deletes a homescript by its Id, does not check if the user has access to the homescript.
Deletes a given notification, can return an error.
No description provided by the author
Deletes all cameras in an arbitrary room Uses `DeleteCamera` in order to remove dependencies beforehand.
Deletes a room and all entities that depend on the room.
Deletes all switches from an arbitrary room Before deleting the switch, dependencies like switch-permissions are deleted.
Deletes a schedule item given its Id Does not validate the validity of the provided Id.
Delete a given switch after all data which depends on this switch has been deleted.
No description provided by the author
Deletes a User based on a given Username, can return an error if the database fails The function does not validate the existence of this username itself, so additional checks should be done beforehand The avatar is removed in `core/user/user`.
Delete a single reminder, for example if its task is finished.
TODO: remove and intigrate into get user homescript Checks if a Homescript with an id exists in the database.
Checks the validity of a given permission string.
No description provided by the author
Deletes log events older than 30 days in order to save storage space This function will later be used by a scheduler for daily jobs.
Returns a Automation struct which matches the given Id If the id does not match a struct, a `false`` is returned.
Returns a list with automations of all users Used for activating persistent automations when the server starts.
Returns the path of the avatar image of a given user, does not check if the user exists, additional checks needed beforehand.
Returns the metadata of a given camera, wheter it could be found and a potential error.
No description provided by the author
Returns a hardware node given its url.
Returns a list of hardware nodes.
No description provided by the author
Returns a list of PowerStates Can return a database error.
Given its id and owner, the function returns a reminder, if it was found and an error.
Returns an arbitrary room given its id, whether it exists an a possible error.
Returns a schedule struct which matches the given id If the id does not match a struct, a `false`` is returned.
Returns a list of schedules of all users, used for activating schedules at the start of the server.
Retrieves the servers configuration.
Returns an arbitrary switch given its id.
Returns a list containing automations of a given user Does not check the validity of the user.
Returns a user struct based on a username, does not check if the user exists, additional checks needed beforehand.
Returns the users information and their permissions.
Returns a Homescript given its id Returns Homescript, has been found, error TODO: replace with query row.
Used for displaying the notification count for a given user Used in the frontend before the actual permissions are fetched.
Used when requesting the user's permissions in the frontend Returns a list containing the permissions of a given user.
Returns the password of a given user.
Returns a list of permissions assigned to a given user, if it exists.
Returns a slice of reminders which were set up by a given user.
Returns a list containing schedules of a given user.
Returns a list of strings which resemble switch permissions.
No description provided by the author
No description provided by the author
Creates a new user based on a the supplied `User` struct Won't panic if user already exists, but will change password.
Returns a complete list of rooms, includes its metadata like switches and cameras.
Returns a list containing all cameras Used when deleting all cameras in a room.
Lists all Homescript files in the database.
Returns a list of homescripts owned by a given user.
Returns a complete list of rooms to which a user has access to, includes its metadata like switches and cameras.
Returns a list of room data.
Returns a list of all available switches with their attributes.
Combines the logic from `ListUserCamerasQuery()` With an exception: if the user has the permission to modify rooms, all cameras are granted.
Like `ListCameras()` but takes a user string as a filter Only returns camerass to wich the user has access to Used in `ListUserCameras()`.
Lists users which are currently in the Database Returns an empty list with an error when failing.
No description provided by the author
Like `ListSwitches()` but takes a user string as a filter Only returns switches which are contained in the switch-permission table with the given user.
Modifies the metadata of a given automation item Does not validate the provided metadata.
No description provided by the author
Changes the metadata of a given node Does not affect the online boolean For changing the online status, use `SetNodeOnline`.
Modifies the metadata of a given homescript Does not check the validity of the homescript's id.
Modifies a given reminder to possess the new metadata.
Updates the room's name and description.
Modifies the metadata of a given schedule Does not validate the provided metadata.
Modifies the metadata of a given switch.
Removes all camera permissions of a given user, used when deleting a user.
Removes all permissions of a given user, used when deleting a user in order to prevent foreign key failure Does not validate username, additional checks required, returns an error if the database fails.
Removes all switch permissions of a given user, used when deleting a user Does not validate the existence of said user.
Deletes all occurences of a given camera, used if a camera is deleted.
Deletes all occurrences of a given switch, used if a certain switch is deleted.
Removes a camera permission of an arbitrary user.
Attempts to remove a provided permission from a provided user Fails if permission does not exist or if the database fails Warns and returns `false` for the `modified` boolean the user does not have the permission.
TODO: Remove useless check if user already has permission TODO: check naming consistency of `ADD / CREATE` and `DELETE / REMOVE` Removes a switch permission from a user, but does not delete if from the switch permission list.
Change the state of the automation system.
Updates the online / offline state of a given node (url).
Used when marking a power state of a switch Does not check the validity of the switch Id The returned boolean indicates if the power state had changed.
Modifies the reminders status its owner has been informed about urgency.
Updates the servers configuration.
Sets the path of the avatar for a given user, does not check if the user exists, additional checks needed beforehand.
Set whether the user uses the dark theme or the light theme.
Set whether the scheduler is enabled for the current user.
Closes the database.
Changes the location of the server.
Sets the users primary colors.
Returns a boolean indicating whether a user has a camera permission.
Used in userHasCameraPermission.
Checks if a provided user is in possession of a provided permission, can return an error, if the database fails.
Returns a boolean if a user has a switch permission.
Used in userHasSwitchPermission.
# Constants
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
Different types of permissions.
Different types of permissions.
Different types of permissions.
Different types of permissions.
Different types of permissions.
Different types of permissions.
Different types of permissions.
Different types of permissions.
Different types of permissions.
Different types of permissions.
Different types of permissions.
Dangerous.
Will not change, automation will always execute based on this time.
Uses the local time for sunrise, each run of a set automation will update the actual time and regenerate a cron expression.
Same as above, just for sunset.
No description provided by the author
# Variables
No description provided by the author
# Structs
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
Identified by a username, has a password and an avatar path.
Hardware node.
No description provided by the author
No description provided by the author
internal logging-related.
User notification.
This file defines which permissions exists and describes their attributes.
Contains the switch id and a matching boolean Used when requesting global power states.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
Identified by a Switch Id, has a name and belongs to a room.
No description provided by the author
No description provided by the author
# Type aliases
No description provided by the author
No description provided by the author
No description provided by the author