package
0.8.0
Repository: https://github.com/smarthome-go/smarthome.git
Documentation: pkg.go.dev

# Functions

Adds a new item to the argument list of a given Homescript Returns the newly created ID of the argument.
Adds a new entry into the cache If the entry already exists, it is updated.
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.
Inserts a new data point into the power usage time record table.
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's camera permissions 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 or presence of the permission, => 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.
No description provided by the author
Executes a ping to the database in order to check if it is online A nil response means success whereas an error indicates a database failure.
Creates a new camera Checks, for example if the camera already exists should be completed beforehand If the camera already exists, some values are updated.
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 using the raw data provided.
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 power job for a corresponding schedule All data must be validated beforehand.
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 Used when deleting a user An invalid username will lead to no deletions.
Deletes all arguments referencing a given Homescript Used before deleting a Homescript from the database.
Deletes all Homescripts of a given user Uses the `DeleteHomescriptById` function.
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 all switch items from a given schedule Used when a schedule is deleted.
Deletes an automation item given its Id Does not validate the validity of the provided Id If an invalid id is specified, nothing will be deleted.
Deletes a camera and removes dependent camera-permission first Used in deleting all room cameras and deleting one camera.
Deletes a node given its url.
Deletes an arbitrary Homescript argument given its id.
Deletes a homescript by its Id, does not check if the user has access to the homescript.
No description provided by the author
Deletes a log record matching the provided id Also returns a boolean indicating whether an entry has been deleted or not.
Deletes a given notification, can return an error.
Deletes a power usage data point given its id.
No description provided by the author
Deletes all cameras in an arbitrary room Uses `DeleteCamera` in order to remove the camera's dependencies beforehand Used when deleting a room.
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 Deletes all switch jobs first Does not validate the validity of the provided Id.
Delete a given switch after all data which depends on this switch has been deleted.
Deletes an existent switch job from a given schedule All data has to be validated beforehand.
Deletes all tables in the active `smarthome` database This function is used in testing and could be used in the future to allow for a system reset.
Deletes an arbitrary user token.
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.
Deletes all logs which are currently stored in the database.
Deletes all cache entries which are older than 12 hours (cache invalidation time).
Deletes log events older than 30 days in order to free storage space This function will later be used by a scheduler for daily jobs.
Deletes power statistics which are older than x hours Also returns the amount of records which have been deleted by this query.
Returns a Automation struct which matches the given Id If the id does not match a struct, an empty struct and `false` (for found) is returned.
Returns a slice 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, whether it could be found and a potential error.
Returns common database statistics Is used in the debug function.
Returns a hardware node given its url.
Returns a list of hardware nodes.
No description provided by the author
Returns all logs currently in the database.
No description provided by the author
Returns a list of PowerStates Can return a database error.
Returns records from the power usage records Only returns records which are younger than x hours If the max-age is set to < 0, all records are returned.
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 (must be valid) An invalid user will yield an empty list.
Returns a user struct based on a username, does not check if the user exists, additional checks needed beforehand.
Returns the camera-permissions of an arbitrary user in the form of a slice of strings Each slice element references a camera's id to which the user has access to.
Returns the users information and their permissions.
Returns the data matching the id of an argument which is associated with a given user.
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.
Returns an arbitrary user token which matches the query Used when validating a token during authentication.
Returns the list of available authentication tokens a user has set up.
Returns all cache entries younger than 12 hours (cache invalidation time) => This means this function will return only valid cache-entries.
No description provided by the author
No description provided by the author
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 return an error if user already exists, but will change the password.
Inserts a new token into the table Validation is required beforehand.
Returns a boolean indicating whether a specified entry exists and if it is still valid.
Returns all HomescriptArgs of a given user as a slice.
Returns a complete list of rooms, includes its metadata like switches and cameras.
Returns a list of all schedule switches.
Returns the arguments of a given Homescript as a slice.
Returns a list containing all cameras Used when deleting all cameras in a room.
Returns a list a list containing all cameras, just without the Url and RoomId Can be used to hide the confidential URL and roomId whilst still listing all cameras.
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.
Returns a list of schedule switch jobs belonging to an arbitrary schedule.
Combines the logic from `ListUserCamerasQuery` with other permission logic which cannot be expressed through SQL Manages 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 cameras to which the user has access to Used in `ListUserCameras`.
Lists users which are currently in the Database.
Returns a list of all schedule switch jobs owned by a given user.
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 given its raw id Does not validate the provided metadata If an invalid id is specified, no data will be modified.
Modifies a cameras name annd URL Does not modify other metadata due to it being used immutably.
Changes the metadata of a given node Does not affect the online boolean For changing the online status, use `SetNodeOnline`.
Modifies the data of a given Homescript argument.
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.
Deletes all cache entries, regardless of their age.
No description provided by the author
Removes all camera permissions of a given user, used when deleting a user Providing an invalid user will lead to no deletions.
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 authentication tokens of an arbitrary user.
Deletes all occurrences of a given camera-id in the camera permissions => 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 An invalid user or an invalid camera id will lead to no deletions.
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.
Changes the state of the lock-down mode.
Updates the online / offline state of a given node (using its 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 connection.
Sets the last run timestamp of the given automation to now.
Changes the location of the server.
Changes the server's Open Weather Map API Key.
Sets the users primary colors.
Updates a user's password hash The provided data must be validated beforehand.
Returns a boolean indicating whether a user is in possession of a given camera permission Also accounts for the special case that a usaer does not have explicit permission to a camera, but is in possession of the `manageRooms` or `*` permission, which grants the user access.
Returns a boolean indicating whether the user has access to a given camera or not.
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
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
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.
Different types of permissions.
Different types of permissions.
Will execute Homescript code as a target.
Will execute a Homescript by its id as a target.
Will perform a series of power actions as a target.
Will not change, an automation will always execute based on this time.
Uses the time of local sunrise => Each run of a set automation will update the underlyingk time => Each run will update and regenerate a cron-expression.
Same as above, just uses the time of local sunset.
No description provided by the author

# Variables

Datatypes which a Homescript argument can use Type conversion is handled by the target Homescript These types act as a hint for the user and are required for the GUI to display an adequate input.
Uses `on` and `off` as substitutes for true and false.
Uses `yes` and `no` as substitutes for true and false.
Datatypes which a Homescript argument can use Type conversion is handled by the target Homescript These types act as a hint for the user and are required for the GUI to display an adequate input.
Displays a hour picker (0 <= h <= 24).
Displays a minute picker (0 <= m <= 60).
No description provided by the author
Datatypes which a Homescript argument can use Type conversion is handled by the target Homescript These types act as a hint for the user and are required for the GUI to display an adequate input.
Shows a list of switches from which the user can select one as a string.
Uses a normal input field matching the specified data type.

# 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
No description provided by the author
No description provided by the author
No description provided by the author
User notification.
This file defines which permissions exists and describes their attributes.
For an API-friendly version of this struct, visit the hardware module.
No description provided by the author
Contains the switch id and a matching boolean which indicates whether the switch is on or off Additionally, the power draw is also included (mainly used for taking periodic snapshots of the power statistics) Used when requesting global power states.
Is used for listing available cameras without specifying sensitive information.
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
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
No description provided by the author
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
No description provided by the author
No description provided by the author
Specifies which action will be performed as a target.
Represents the timing mode on which the automation operates.