Bath digital safety management and control system based on Internet of Things terminal

By constructing behavioral vector sequences through IoT terminals and performing hierarchical clustering to obtain typical patterns, the adaptability and timeliness issues of existing bathroom security monitoring systems are solved, enabling adaptive security monitoring and timely intervention for different user groups.

CN122087485APending Publication Date: 2026-05-26SHENZHEN ZHONGXIN TRUST DIGITAL TECHNOLOGY CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-02-27
Publication Date
2026-05-26

Smart Images

  • Figure CN122087485A_ABST
    Figure CN122087485A_ABST
Patent Text Reader

Abstract

The invention discloses a bathing digital safety management and control system based on an Internet of Things terminal, and the system comprises an event flow obtaining module which is used for obtaining a historical bathing event flow, a sequence construction module which is used for constructing N behavior vector sequences, a sequence cluster clustering module which is used for obtaining K behavior sequence clusters, and a typical sequence obtaining module which is used for obtaining a typical sequence. The typical behavior vector sequence acquisition module is used for acquiring a typical behavior vector sequence, the current sequence acquisition module is used for acquiring a latest behavior vector sequence, the matching degree calculation module is used for calculating the safety matching degree of a current user, and the safety intervention module is used for performing safety intervention; according to the invention, a reasonable behavior can be prevented from being misjudged as a risk; besides, the matching process is carried out based on the first Q behavior events which have occurred currently, the completion of bathing is not needed, intervention can be triggered when the user enters the initial stage of the abnormal state (for example, continuous idling occurs in the second stage), and the response timeliness is remarkably improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of bathing safety management, specifically a digital bathing safety management system based on Internet of Things (IoT) terminals. Background Technology

[0002] Currently, bathroom security monitoring largely relies on a single sensor triggering fixed threshold rules. For example, a water flow sensor detects the duration of water supply; if it exceeds a preset time (such as 30 minutes), it is considered abnormal and the water supply is shut off; or an infrared sensor detects a person's stationary state, and if this continues for a certain period of time, an alarm is issued.

[0003] However, such methods have significant drawbacks: First, fixed thresholds cannot adapt to the behavioral differences among different user groups—elderly people often involve multiple short pauses or water testing during bathing, which can easily be misjudged as abnormal; teenagers who quickly shower may also trigger false alarms if they briefly leave (e.g., to retrieve a towel) due to uninterrupted water flow. Second, focusing only on a single dimension (such as total duration or static state) ignores the combined temporal relationship between water supply status and human activity during bathing, making it difficult to distinguish between semantically distinct scenarios such as "normal water testing and idling" and "prolonged idling due to forgetting to turn off the water." Third, existing solutions typically require waiting until the bathing process is completely finished before making a judgment, failing to intervene in time during the process, resulting in a delayed response and difficulty in dealing with emergencies such as sudden fainting. Therefore, this invention provides a digital safety management system for bathing based on an IoT terminal. Summary of the Invention

[0004] To address the shortcomings of existing technologies, this invention provides a digital safety management and control system for bathing based on Internet of Things (IoT) terminals. This system solves the technical problems mentioned in the background by introducing historical modeling and safety matching of water supply status.

[0005] To achieve the above objectives, the present invention provides the following technical solution: A digital safety management system for bathing facilities based on Internet of Things (IoT) terminals includes: The event stream acquisition module is used to acquire the historical bathing event streams of N bathing users; The sequence construction module is used to construct N behavior vector sequences based on the historical bathing event streams of N bathing users; The sequence clustering module is used to perform hierarchical clustering on N behavioral vector sequences to obtain K behavioral sequence clusters; The typical sequence acquisition module is used to acquire the typical behavior vector sequence of the cluster center of each of the K behavior sequence clusters; The current sequence acquisition module is used to obtain the latest behavior vector sequence of the current user; The matching degree calculation module is used to calculate the current user's security matching degree based on the latest behavior vector sequence; The security intervention module is used to intervene in security situations if the security matching degree is lower than a threshold.

[0006] In some specific embodiments, N behavioral vector sequences are constructed based on the historical bathing event streams of N bathing users, including: S2-1. Select the historical bathing event stream of a target user from the historical bathing event streams of N bathing users; S2-2. Based on the joint determination of water flow status and target user activity status, M behavioral events are segmented from the target user's historical bathing event stream; The behavioral events are mutually exclusive, continuous state segments covering the entire bathing process, including: No water supply event: A continuous period of time during which the water flow sensor detects that the water supply is off; Active water use events: The water flow sensor is detected as being turned on, and the infrared pyroelectric sensor detects continuous periods of human activity. Idle water usage incident: The water flow sensor detected that it was on, but the infrared pyroelectric sensor did not detect a continuous period of human activity. Each behavioral event includes: event category label, start timestamp, end timestamp, and event duration.

[0007] S2-3. Assign event stage numbers to each of the M behavioral events based on their start and end timestamps. S2-4. Characterize the event stage number, event category label, start timestamp, end timestamp, and event duration, and concatenate them in order to form a behavior event vector; S2-5. Traverse the M behavior events and repeatedly concatenate the behavior event vectors until you get M behavior event vectors. S2-6. Arrange the M behavioral event vectors in ascending order according to their event stage numbers to construct the behavioral vector sequence of the target user; S2-7. Iterate through N bathing users and repeatedly construct the target user's behavior vector sequence until N behavior vector sequences are obtained.

[0008] In some specific embodiments, an event phase number is assigned to each of the M behavioral events based on its start and end timestamps: S2-3-1, Anchor the start and end timestamps of each behavioral event; S2-3-2. Determine the intermediate timestamp based on the start timestamp and the end timestamp; S2-3-3, Calculate the relative distance of events within the total event duration for intermediate timestamps; S2-3-4. Traverse the M behavioral events and repeatedly calculate the relative distances of the events until the relative distances of the M events are obtained. S2-3-5. Sort the relative distances of the M events in ascending order to obtain the relative distance sequence; S2-3-6 assigns monotonically increasing event stage numbers to the relative distances of M events in the relative distance sequence, and associates the event stage numbers with the corresponding behavioral events.

[0009] In some specific embodiments, hierarchical clustering is performed on N behavior vector sequences to obtain K behavior sequence clusters, including: S3-1. Take the N behavior vector sequences as N initial clusters, and initialize the N initial clusters as the current cluster set; S3-2. In the current cluster set, identify any two clusters that have the minimum sequence distance and merge the cluster pair into a new cluster. S3-3. Remove the cluster pair from the current cluster set and add the new cluster, then update the current cluster set; S3-4. Repeat the update of the current cluster set until the current cluster set contains only a single cluster; S3-5. During each merging operation, record the merged cluster pairs and their corresponding sequence distances, and construct a hierarchical clustering tree representing the evolutionary relationship of bathing behavior patterns based on the merging order. S3-6. Based on the hierarchical clustering tree, extract K behavioral sequence clusters at the corresponding level.

[0010] In some specific embodiments, identifying cluster pairs with the minimum sequence distance between any two clusters includes: S3-2-1. Retrieve all clusters in the current cluster set; S3-2-2. For any two different clusters C1 and C2, calculate the pairwise sequence distance between all behavior vector sequences in cluster C1 and all behavior vector sequences in cluster C2. S3-2-3. Perform pairwise sequence distance calculations on all cluster pairs to obtain all sequence distances under the current cluster set; S3-2-4. Select the minimum sequence distance from all the sequence distances; S3-2-5. Anchor the cluster pair corresponding to the minimum sequence distance as the two clusters to be merged.

[0011] In some specific embodiments, a hierarchical clustering tree representing the evolutionary relationship of bathing behavior patterns is constructed based on the merging order, including: S3-5-1. Label the N initial clusters as the N leaf nodes of the hierarchical clustering tree; S3-5-2. In the t-th merge operation, t=1,2,…,N−1, mark the newly generated cluster as an internal node. S3-5-3, Take the sequence distance used for the t-th merging as the node height of the internal node; S3-5-4. Based on the order of merging and the cluster inclusion relationship, connect the leaf nodes and internal nodes from bottom to top to form a complete hierarchical clustering tree structure.

[0012] In some specific embodiments, based on the hierarchical clustering tree, K behavioral sequence clusters at corresponding levels are extracted, including: S3-6-1. Extract the node height of each internal node in the hierarchical clustering tree and arrange them in the merging order to generate a merging distance sequence; S3-6-2. Calculate the distance increment between the heights of adjacent nodes in the merged distance sequence to obtain the distance increment sequence; S3-6-3, Set the distance jump threshold T; S3-6-4. If, along the ascending direction of the distance increment sequence, there exists a distance increment in the Hth merge that is greater than the distance jump threshold, then clustering is stopped after the Hth merge is completed. S3-6-5. Define the K clusters remaining after the Hth clustering iteration as the behavior sequence clusters; where K=NH.

[0013] In some specific embodiments, obtaining the latest behavior vector sequence of the current user includes: S5-1. Obtain the first Q behavioral events of the current user and assign event stage numbers to the first Q behavioral events; S5-2. Construct the first Q behavioral events into Q behavioral vectors, and sort them according to the event stage number to form the latest behavioral vector sequence.

[0014] In some specific embodiments, the current user's security match degree is calculated based on the latest behavior vector sequence, including: S6-1. Calculate the sequence distance between the latest behavior vector sequence and the K typical behavior vector sequences; S6-2. Select the typical behavior vector sequence corresponding to the minimum sequence distance as the optimal matching sequence; S6-3. Real-time update of the latest behavior vector corresponding to the latest behavior event in the latest behavior vector sequence; S6-4. Calculate the safe matching degree between the latest behavior vector and the corresponding behavior vector in the optimal matching sequence.

[0015] This invention provides a digital safety management and control system for bathing facilities based on Internet of Things (IoT) terminals, which has the following beneficial effects: This invention acquires timestamp event streams from door magnets, water flow sensors, and infrared pyroelectric sensors to construct vector sequences based on behavioral events. Hierarchical clustering is then used to summarize K typical behavioral patterns from historical user data. During real-time monitoring, the system performs stage-aligned matching between the current user's latest behavioral vector sequence and the typical sequences, dynamically calculating the safety matching degree. Because the typical behavioral sequences originate from clusters of real user groups, the system can automatically adapt to the habitual characteristics of different groups such as the elderly and teenagers, avoiding misjudging reasonable behavior as risk. Furthermore, the matching process is based on the first Q behavioral events that have occurred, eliminating the need to wait for the bath to end. Intervention can be triggered as early as the user enters an abnormal state (such as continuous idling in the second stage), significantly improving response timeliness. Attached Figure Description

[0016] Figure 1 This is a structural block diagram of a digital safety management and control system for bathing facilities based on an Internet of Things (IoT) terminal, according to the present invention. Figure 2 This is a schematic diagram of the processing flow of a digital safety management and control system for bathing based on an Internet of Things terminal according to the present invention; Detailed Implementation

[0017] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.

[0018] Example 1: Please refer to Figures 1 to 2 This invention provides a digital safety management system for bathing facilities based on Internet of Things (IoT) terminals, comprising the following modules: The event stream acquisition module is used to acquire the historical bathing event streams of N bathing users; The historical bathing event stream originates from IoT terminals deployed in the bathroom, including: Door magnetic sensors are used to detect the open / closed status of bathroom doors to enable or disable the entire process of historical bathing events. A water flow sensor is used to detect the start and stop of water supply and to define the start and end boundaries of the water supply phase. Infrared pyroelectric sensor, used to detect the presence and movement of human body, and to distinguish between active water use and idle water use. Each time an event is detected, the aforementioned sensor records its corresponding timestamp. The sequence construction module is used to construct N behavior vector sequences based on the historical bathing event streams of N bathing users; The sequence clustering module is used to perform hierarchical clustering on N behavioral vector sequences to obtain K behavioral sequence clusters; The typical sequence acquisition module is used to acquire the typical behavior vector sequence of the cluster center of each of the K behavior sequence clusters; The typical behavior vector sequence represents the common bathing behavior pattern of the user group within the cluster, which can be represented by selecting the behavior vector sequence with the smallest average distance from other sequences within the cluster.

[0019] The current sequence acquisition module is used to obtain the latest behavior vector sequence of the current user; The matching degree calculation module is used to calculate the current user's security matching degree based on the latest behavior vector sequence; The security intervention module is used to intervene in security situations if the security matching degree is lower than a threshold.

[0020] Specifically, the safety intervention refers to an automated control action triggered based on preset risk response rules; it uses data-driven mapping rules to convert the deviation between the safety matching degree and the threshold into graded response instructions; it may include: automatically shutting off the water supply valve, activating voice reminders, sending alarm information to the associated guardian's terminal, or linking the bathroom door lock to perform emergency unlocking.

[0021] This invention constructs a sequence of behavioral vectors based on historical bathing event flows and automatically summarizes the behavioral patterns of several typical user groups using hierarchical clustering, thereby providing a personalized safety baseline for real-time monitoring. During operation, the system matches the current user's dynamic behavior with these typical patterns, and triggers tiered safety intervention when a significant deviation is detected.

[0022] Compared to traditional bathing safety solutions based on fixed thresholds (such as "an alarm will sound if water flows continuously for 30 minutes"), this invention can adapt to the behavioral habits of different user groups—for example, it will not issue false alarms for elderly people who often pause briefly, and it will respond promptly to abnormal lingering when teenagers who usually bathe quickly show signs of lingering.

[0023] The technical solution of this embodiment 2 differs from that of embodiment 1 in that it discloses the specific application steps of each module in embodiment 1.

[0024] Specifically, in this embodiment, the application steps of the sequence construction module include: S2-1. Select the historical bathing event stream of a target user from the historical bathing event streams of N bathing users; S2-2. Based on the joint determination of water flow status and target user activity status, M behavioral events are segmented from the target user's historical bathing event stream; The behavioral events are mutually exclusive, continuous state segments covering the entire bathing process, including: No water supply event: A continuous period of time during which the water flow sensor detects that the water supply is off; Active water use events: The water flow sensor is detected as being turned on, and the infrared pyroelectric sensor detects continuous periods of human activity. Idle water usage incident: The water flow sensor detected that it was on, but the infrared pyroelectric sensor did not detect a continuous period of human activity. Each behavioral event includes: event category label, start timestamp, end timestamp, and event duration.

[0025] In this embodiment, the segmentation of the behavioral events is automatically executed through preset state switching rules to construct a bathing user behavior pattern database. The rules include: when the water flow signal changes from off to on and the infrared signal remains active, it is marked as the start of an active water use event; when the water flow is on but the infrared signal remains silent for more than a preset silence threshold, it is marked as an idle water use event. S2-3. Assign event stage numbers to each of the M behavioral events based on their start and end timestamps. S2-4. Characterize the event stage number, event category label, start timestamp, end timestamp, and event duration, and concatenate them in order to form a behavior event vector; S2-5. Traverse the M behavior events and repeatedly concatenate the behavior event vectors until you get M behavior event vectors. S2-6. Arrange the M behavioral event vectors in ascending order according to their event stage numbers to construct the behavioral vector sequence of the target user; S2-7. Iterate through N bathing users and repeatedly construct the target user's behavior vector sequence until N behavior vector sequences are obtained.

[0026] In this embodiment, the behavior vector sequence fully preserves the temporal coupling relationship between the water supply status and the human activity status during the bathing process, enabling clustering to distinguish different behavior patterns such as "short-term idle time caused by the elderly testing the water" and "long-term idle time caused by teenagers forgetting to turn off the water". Since all features are derived from non-invasive sensors, the construction process does not require users to actively label or provide identity information, and the historical behavior database can be automatically accumulated in the background, providing a data foundation for real-time safe matching.

[0027] Furthermore, steps S2-3 specifically include: S2-3-1, Anchor the start and end timestamps of each behavioral event; S2-3-2. Determine the intermediate timestamp based on the start timestamp and the end timestamp; S2-3-3, Calculate the relative distance of events within the total event duration for intermediate timestamps; S2-3-4. Traverse the M behavioral events and repeatedly calculate the relative distances of the events until the relative distances of the M events are obtained. S2-3-5. Sort the relative distances of the M events in ascending order to obtain the relative distance sequence; S2-3-6 assigns monotonically increasing event stage numbers to the relative distances of M events in the relative distance sequence, and associates the event stage numbers with the corresponding behavioral events.

[0028] In this embodiment, by using the relative position of the intermediate timestamp as the sorting basis, the event stage number can reflect the temporal center position of each behavioral event in the entire bathing process, rather than relying solely on the start time. When dealing with partially overlapping or ambiguous behavioral events, it ensures that the constructed behavioral vector sequence more accurately aligns with the key behavioral stages (such as trial bath, main bath, and final bath) of similar users during the clustering process, thereby enhancing the representativeness of typical behavioral patterns.

[0029] Specifically, in this embodiment, the application steps of the sequence clustering module include: S3-1. Take the N behavior vector sequences as N initial clusters, and initialize the N initial clusters as the current cluster set; S3-2. In the current cluster set, identify any two clusters that have the minimum sequence distance and merge the cluster pair into a new cluster. S3-3. Remove the cluster pair from the current cluster set and add the new cluster, then update the current cluster set; S3-4. Repeat the update of the current cluster set until the current cluster set contains only a single cluster; S3-5. During each merging operation, record the merged cluster pairs and their corresponding sequence distances, and construct a hierarchical clustering tree representing the evolutionary relationship of bathing behavior patterns based on the merging order. S3-6. Based on the hierarchical clustering tree, extract K behavioral sequence clusters at the corresponding level.

[0030] In this embodiment, by treating each user's behavior vector sequence as an independent initial cluster and constructing a hierarchical clustering tree by merging them layer by layer based on sequence distance, the system can automatically reveal the inherent grouping structure of bathing behavior in an unsupervised manner. This process does not require preset user categories or labels and can identify groups with similar water usage rhythms and phase distributions from historical data (such as teenagers who are accustomed to short and quick showers, and the elderly who have multiple water tests and pauses). The generated hierarchical clustering tree not only preserves the division of behavior patterns at different granularities, but also provides a visual basis for the selection of the K value - by analyzing the jump points of sequence distance during the merging process, the optimal number of clusters can be objectively determined, avoiding over-clustering or under-clustering caused by subjective settings; the final K behavior sequence clusters are used as typical templates.

[0031] Furthermore, step S3-2 specifically includes: S3-2-1. Retrieve all clusters in the current cluster set; S3-2-2. For any two different clusters C1 and C2, calculate the pairwise sequence distance between all behavior vector sequences in cluster C1 and all behavior vector sequences in cluster C2. The formula for calculating the sequence distance is: ; in, and Let M represent the behavior vector sequences of the i-th and j-th clusters, respectively, and M represent the total number of behavior event stages. and Let represent the behavior vectors of the two behavior vector sequences at stage t. This indicates the calculation of the Euclidean distance between two line vectors.

[0032] S3-2-3. Perform pairwise sequence distance calculations on all cluster pairs to obtain all sequence distances under the current cluster set; S3-2-4. Select the minimum sequence distance from all the sequence distances; S3-2-5. Anchor the cluster pair corresponding to the minimum sequence distance as the two clusters to be merged.

[0033] In this embodiment, the average connection strategy is used to calculate the sequence distance between any two clusters—that is, to compare all behavior vector sequences within two clusters pairwise and take the average distance, which effectively improves the stability of inter-cluster similarity assessment. This method is particularly suitable for individual differences commonly found in bathing behavior data (such as a user occasionally extending the shower time), avoiding erroneous merging due to individual abnormal sequences. At the same time, the calculation of sequence distance comprehensively considers the consistency of behavioral event categories, phase alignment relationships, and duration deviations, so that safety-related features such as "significantly longer idle water usage time" or "missing active phases" can be fully reflected in the distance metric.

[0034] Furthermore, steps S3-5 specifically include: S3-5-1. Label the N initial clusters as the N leaf nodes of the hierarchical clustering tree; S3-5-2. In the t-th merge operation, t=1,2,…,N−1, mark the newly generated cluster as an internal node. S3-5-3, Take the sequence distance used for the t-th merging as the node height of the internal node; S3-5-4. Based on the order of merging and the cluster inclusion relationship, connect the leaf nodes and internal nodes from bottom to top to form a complete hierarchical clustering tree structure.

[0035] In this embodiment, by mapping each merging operation to an internal node of a hierarchical clustering tree and using the corresponding sequence distance as the node height, the system can completely preserve the aggregation and evolution path of bathing behavior patterns from individuals to groups in a tree structure. This hierarchical clustering tree not only intuitively reflects the similarity levels between different user behavior sequences (e.g., all sequences containing "long-term idle water use" are merged at a lower height), but also provides an interpretable decision basis for subsequently determining the optimal number of clusters K. By observing the jump positions of node heights, natural behavior grouping boundaries can be identified, avoiding pattern confusion or overgeneralization caused by artificially setting the number of clusters. At the same time, the tree structure itself supports multi-granularity backtracking, allowing safety control strategies to flexibly select coarse-grained (e.g., only distinguishing between high-risk / low-risk) or fine-grained (e.g., subdividing into elderly, teenagers, and adults) behavior templates for matching based on risk sensitivity.

[0036] Furthermore, steps S3-6 specifically include: S3-6-1. Extract the node height of each internal node in the hierarchical clustering tree and arrange them in the merging order to generate a merging distance sequence; S3-6-2. Calculate the distance increment between the heights of adjacent nodes in the merged distance sequence to obtain the distance increment sequence; S3-6-3, Set the distance jump threshold T; S3-6-4. If, along the ascending direction of the distance increment sequence, there exists a distance increment in the Hth merge that is greater than the distance jump threshold, then clustering is stopped after the Hth merge is completed. S3-6-5. Define the K clusters remaining after the Hth clustering iteration as the behavior sequence clusters; where K=NH.

[0037] In this embodiment, each leaf node of the hierarchical clustering tree corresponds to a user's historical behavior vector sequence, and each internal node corresponds to a cluster merging operation. Its node height is equal to the sequence distance on which the merging is based. When two behavior patterns are more similar (e.g., both are "single active water use without idle time"), the node height at which the merging occurs is lower, and its position in the tree is closer to the bottom. Conversely, sequences with large differences (e.g., "frequent idle time" and "continuous active time") are merged only at higher nodes. Through this structure, when the system subsequently determines K behavior sequence clusters, it can directly truncate the tree structure based on the sudden increase in node height, thereby separating distinct user groups. For example, abnormal patterns containing long-term idle water use and normal bathing patterns can be divided into different clusters, providing clear and stable behavioral template boundaries for real-time safe matching.

[0038] Specifically, in this embodiment, the acquisition steps of the current sequence acquisition module include: S5-1. Obtain the first Q behavioral events of the current user and assign event stage numbers to the first Q behavioral events; S5-2. Construct the first Q behavioral events into Q behavioral vectors, and sort them according to the event stage number to form the latest behavioral vector sequence.

[0039] In this embodiment, the current user's bathing process is parsed in real time as a continuous stream of behavioral events. The system dynamically extracts the latest Q behavioral events (e.g., Q=3, corresponding to "opening the door → active water use → idle water use") and assigns stage numbers according to their actual occurrence order. The latest behavioral vector sequence constructed in this way retains the stage progress status of the current bathing session, allowing the system to make early risk judgments without waiting for the bathing to end. For example, if the user enters idle water use in the second stage and continues for more than a preset time, the system can immediately compare it with a typical sequence and trigger intervention in advance, avoiding response delays caused by waiting for the complete sequence.

[0040] Specifically, in this embodiment, the calculation steps of the matching degree calculation module include: S6-1. Calculate the sequence distance between the latest behavior vector sequence and the K typical behavior vector sequences; It should be noted that the latest behavior vector sequence and the typical behavior vector sequence have different lengths. Therefore, it is necessary to extract a prefix subsequence from the typical behavior vector sequence that has the same event stage number range as the latest behavior vector sequence; and then calculate the sequence distance between the latest behavior vector sequence and the prefix subsequence.

[0041] Specifically, the vector position (event stage number) is anchored by a continuous integer interval from the starting stage (1) to the current latest stage (Q).

[0042] S6-2. Select the typical behavior vector sequence corresponding to the minimum sequence distance as the optimal matching sequence; S6-3. Real-time update of the latest behavior vector corresponding to the latest behavior event in the latest behavior vector sequence; S6-4. Calculate the safe matching degree between the latest behavior vector and the corresponding behavior vector in the optimal matching sequence; Specifically, the safety fit can be quantified using the reciprocal of the normalized Euclidean distance; this safety fit measures the degree of deviation between the current user's behavioral state at the latest stage and the typical pattern of their group. In this embodiment, since the current user's bathing process is in progress, the length of their latest behavior vector sequence is usually shorter than the complete typical behavior vector sequence. The system uses an event stage sequence number alignment mechanism to extract a prefix subsequence of the same length as the current sequence from K typical sequences (i.e., from stage 1 to the latest stage Q), ensuring that the comparison occurs at the same behavior stage position. Based on this, the sequence distance is calculated, and the typical sequence with the smallest distance is selected as the behavior pattern category to which the current user belongs. Subsequently, the system focuses on the behavior vector of the latest stage (stage Q) and compares it with the vector of the corresponding stage in the optimal matching sequence. If the current stage is "idling water use" while the same stage in the typical pattern is "active water use", or the idling time is much longer than the historical average of the group, the safety matching degree is significantly reduced. This matching degree can be quantified using the reciprocal of the normalized Euclidean distance, thereby achieving sensitive capture of stage-based behavior deviations. Through the dual matching of global pattern matching and local stage verification, the system can promptly identify abnormal behavior (such as a teenage user suddenly remaining still for a long time) during the bathing process without waiting for the entire process to end, effectively improving the accuracy of intervention.

[0043] The above embodiments can be implemented, in whole or in part, by software, hardware, firmware, or any other combination thereof. When implemented using software, the above embodiments can be implemented, in whole or in part, as a computer program product. The computer program product includes one or more computer instructions or computer programs. When the computer instructions or computer program are loaded or executed on a computer, all or part of the processes or functions described in the embodiments of this application are generated. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions can be stored in a computer-readable storage medium or transmitted from one computer-readable storage medium to another. For example, the computer instructions can be transmitted from one website, computer, server, or data center to another website, computer, server, or data center via wired (e.g., infrared, wireless, microwave, etc.) means.

[0044] The above description is merely a specific embodiment of this application, but the scope of protection of this application is not limited thereto. Any changes or substitutions that can be easily conceived by those skilled in the art within the scope of the technology disclosed in this application should be included within the scope of protection of this application.

Claims

1. A digital safety management and control system for bathing facilities based on Internet of Things (IoT) terminals, characterized in that: include: The event stream acquisition module is used to acquire the historical bathing event streams of N bathing users; The sequence construction module is used to construct N behavior vector sequences based on the historical bathing event streams of N bathing users; The sequence clustering module is used to perform hierarchical clustering on N behavioral vector sequences to obtain K behavioral sequence clusters; The typical sequence acquisition module is used to acquire the typical behavior vector sequence of the cluster center of each of the K behavior sequence clusters; The current sequence acquisition module is used to obtain the latest behavior vector sequence of the current user; The matching degree calculation module is used to calculate the current user's security matching degree based on the latest behavior vector sequence; The security intervention module is used to intervene in security situations if the security matching degree is lower than a threshold.

2. The digital safety management and control system for bathing facilities based on an Internet of Things terminal according to claim 1, characterized in that, Based on the historical bathing event streams of N bathing users, construct N behavioral vector sequences, including: S2-1. Select the historical bathing event stream of a target user from the historical bathing event streams of N bathing users; S2-2. Based on the joint determination of water flow status and target user activity status, M behavioral events are segmented from the target user's historical bathing event stream; The behavioral events are mutually exclusive, continuous state segments covering the entire bathing process, including: No water supply event: A continuous period of time during which the water flow sensor detects that the water supply is off; Active water use events: The water flow sensor is detected as being turned on, and the infrared pyroelectric sensor detects continuous periods of human activity. Idle water usage incident: The water flow sensor detected that it was on, but the infrared pyroelectric sensor did not detect a continuous period of human activity. Each behavioral event includes: event category label, start timestamp, end timestamp, and event duration; S2-3. Assign event stage numbers to each of the M behavioral events based on their start and end timestamps. S2-4. Characterize the event stage number, event category label, start timestamp, end timestamp, and event duration, and concatenate them in order to form a behavior event vector; S2-5. Traverse the M behavior events and repeatedly concatenate the behavior event vectors until you get M behavior event vectors. S2-6. Arrange the M behavioral event vectors in ascending order according to their event stage numbers to construct the behavioral vector sequence of the target user; S2-7. Iterate through N bathing users and repeatedly construct the target user's behavior vector sequence until N behavior vector sequences are obtained.

3. The digital safety management and control system for bathing facilities based on an Internet of Things terminal according to claim 2, characterized in that, Assign event phase numbers to each of the M behavioral events based on their start and end timestamps: S2-3-1, Anchor the start and end timestamps of each behavioral event; S2-3-2. Determine the intermediate timestamp based on the start timestamp and the end timestamp; S2-3-3, Calculate the relative distance of events within the total event duration for intermediate timestamps; S2-3-4. Traverse the M behavioral events and repeatedly calculate the relative distances of the events until the relative distances of the M events are obtained. S2-3-5. Sort the relative distances of the M events in ascending order to obtain the relative distance sequence; S2-3-6 assigns monotonically increasing event stage numbers to the relative distances of M events in the relative distance sequence, and associates the event stage numbers with the corresponding behavioral events.

4. The digital safety management and control system for bathing facilities based on an Internet of Things terminal according to claim 1, characterized in that, Hierarchical clustering is performed on N action vector sequences to obtain K action sequence clusters, including: S3-1. Take the N behavior vector sequences as N initial clusters, and initialize the N initial clusters as the current cluster set; S3-2. In the current cluster set, identify any two clusters that have the minimum sequence distance and merge the cluster pair into a new cluster. S3-3. Remove the cluster pair from the current cluster set and add the new cluster, then update the current cluster set; S3-4. Repeat the update of the current cluster set until the current cluster set contains only a single cluster; S3-5. During each merging operation, record the merged cluster pairs and their corresponding sequence distances, and construct a hierarchical clustering tree representing the evolutionary relationship of bathing behavior patterns based on the merging order. S3-6. Based on the hierarchical clustering tree, extract K behavioral sequence clusters at the corresponding level.

5. A digital safety management and control system for bathing facilities based on an Internet of Things (IoT) terminal, as described in claim 4, is characterized in that... Identify cluster pairs that have the minimum sequence distance between any two clusters, including: S3-2-1. Retrieve all clusters in the current cluster set; S3-2-2. For any two different clusters C1 and C2, calculate the pairwise sequence distance between all behavior vector sequences in cluster C1 and all behavior vector sequences in cluster C2. S3-2-3. Perform pairwise sequence distance calculations on all cluster pairs to obtain all sequence distances under the current cluster set; S3-2-4. Select the minimum sequence distance from all the sequence distances; S3-2-5. Anchor the cluster pair corresponding to the minimum sequence distance as the two clusters to be merged.

6. The digital safety management system for bathing facilities based on an Internet of Things (IoT) terminal according to claim 5, characterized in that, A hierarchical clustering tree representing the evolutionary relationship of bathing behavior patterns is constructed based on the merging order, including: S3-5-1. Label the N initial clusters as the N leaf nodes of the hierarchical clustering tree; S3-5-2. In the t-th merge operation, t=1,2,…,N−1, mark the newly generated cluster as an internal node. S3-5-3, Take the sequence distance used for the t-th merging as the node height of the internal node; S3-5-4. Based on the order of merging and the cluster inclusion relationship, connect the leaf nodes and internal nodes from bottom to top to form a complete hierarchical clustering tree structure.

7. A digital safety management and control system for bathing facilities based on an Internet of Things (IoT) terminal according to claim 6, characterized in that, Based on the hierarchical clustering tree, extract K behavioral sequence clusters from the corresponding level, including: S3-6-1. Extract the node height of each internal node in the hierarchical clustering tree and arrange them in the merging order to generate a merging distance sequence; S3-6-2. Calculate the distance increment between the heights of adjacent nodes in the merged distance sequence to obtain the distance increment sequence; S3-6-3, Set the distance jump threshold T; S3-6-4. If, along the ascending direction of the distance increment sequence, there exists a distance increment in the Hth merge that is greater than the distance jump threshold, then clustering is stopped after the Hth merge is completed. S3-6-5. Define the K clusters remaining after the Hth clustering iteration as the behavior sequence clusters; where K=NH.

8. The digital safety management system for bathing facilities based on an Internet of Things (IoT) terminal according to claim 1, characterized in that, Obtain the latest behavior vector sequence of the current user, including: S5-1. Obtain the first Q behavioral events of the current user and assign event stage numbers to the first Q behavioral events; S5-2. Construct the first Q behavioral events into Q behavioral vectors, and sort them according to the event stage number to form the latest behavioral vector sequence.

9. A digital safety management and control system for bathing facilities based on an Internet of Things terminal according to claim 8, characterized in that, Based on the latest behavior vector sequence, calculate the current user's security match score, including: S6-1. Calculate the sequence distance between the latest behavior vector sequence and the K typical behavior vector sequences; S6-2. Select the typical behavior vector sequence corresponding to the minimum sequence distance as the optimal matching sequence; S6-3. Real-time update of the latest behavior vector corresponding to the latest behavior event in the latest behavior vector sequence; S6-4. Calculate the safe matching degree between the latest behavior vector and the corresponding behavior vector in the optimal matching sequence. A digital safety management system for bathing facilities based on Internet of Things (IoT) terminals Technical Field This invention relates to the field of bathing safety management, specifically a digital bathing safety management system based on Internet of Things (IoT) terminals. Background Technology Currently, bathroom security monitoring largely relies on a single sensor triggering fixed threshold rules. For example, a water flow sensor detects the duration of water supply; if it exceeds a preset time (such as 30 minutes), it is considered abnormal and the water supply is shut off; or an infrared sensor detects a person's stationary state, and if this continues for a certain period of time, an alarm is issued. However, such methods have significant drawbacks: First, fixed thresholds cannot adapt to the behavioral differences among different user groups—elderly people often involve multiple short pauses or water testing during bathing, which can easily be misjudged as abnormal; teenagers who quickly shower may also trigger false alarms if they briefly leave (e.g., to retrieve a towel) due to uninterrupted water flow. Second, focusing only on a single dimension (such as total duration or static state) ignores the combined temporal relationship between water supply status and human activity during bathing, making it difficult to distinguish between semantically distinct scenarios such as "normal water testing and idling" and "prolonged idling due to forgetting to turn off the water." Third, existing solutions typically require waiting until the bathing process is completely finished before making a judgment, failing to intervene in time during the process, resulting in a delayed response and difficulty in dealing with emergencies such as sudden fainting. Therefore, this invention provides a digital safety management system for bathing based on an IoT terminal. Summary of the Invention To address the shortcomings of existing technologies, this invention provides a digital safety management and control system for bathing based on Internet of Things (IoT) terminals. This system solves the technical problems mentioned in the background by introducing historical modeling and safety matching of water supply status. To achieve the above objectives, the present invention provides the following technical solution: A digital safety management system for bathing facilities based on Internet of Things (IoT) terminals includes: The event stream acquisition module is used to acquire the historical bathing event streams of N bathing users; The sequence construction module is used to construct N behavior vector sequences based on the historical bathing event streams of N bathing users; The sequence clustering module is used to perform hierarchical clustering on N behavioral vector sequences to obtain K behavioral sequence clusters; The typical sequence acquisition module is used to acquire the typical behavior vector sequence of the cluster center of each of the K behavior sequence clusters; The current sequence acquisition module is used to obtain the latest behavior vector sequence of the current user; The matching degree calculation module is used to calculate the current user's security matching degree based on the latest behavior vector sequence; The security intervention module is used to intervene in security situations if the security matching degree is lower than a threshold. In some specific embodiments, N behavioral vector sequences are constructed based on the historical bathing event streams of N bathing users, including: S2-1. Select the historical bathing event stream of a target user from the historical bathing event streams of N bathing users; S2-2. Based on the joint determination of water flow status and target user activity status, M behavioral events are segmented from the target user's historical bathing event stream; The behavioral events are mutually exclusive, continuous state segments covering the entire bathing process, including: No water supply event: A continuous period of time during which the water flow sensor detects that the water supply is off; Active water use events: The water flow sensor is detected as being turned on, and the infrared pyroelectric sensor detects continuous periods of human activity. Idle water usage incident: The water flow sensor detected that it was on, but the infrared pyroelectric sensor did not detect a continuous period of human activity. Each behavioral event includes: event category label, start timestamp, end timestamp, and event duration. S2-3. Assign event stage numbers to each of the M behavioral events based on their start and end timestamps. S2-4. Characterize the event stage number, event category label, start timestamp, end timestamp, and event duration, and concatenate them in order to form a behavior event vector; S2-5. Traverse the M behavior events and repeatedly concatenate the behavior event vectors until you get M behavior event vectors. S2-6. Arrange the M behavioral event vectors in ascending order according to their event stage numbers to construct the behavioral vector sequence of the target user; S2-7. Iterate through N bathing users and repeatedly construct the target user's behavior vector sequence until N behavior vector sequences are obtained. In some specific embodiments, an event phase number is assigned to each of the M behavioral events based on its start and end timestamps: S2-3-1, Anchor the start and end timestamps of each behavioral event; S2-3-2. Determine the intermediate timestamp based on the start timestamp and the end timestamp; S2-3-3, Calculate the relative distance of events within the total event duration for intermediate timestamps; S2-3-4. Traverse the M behavioral events and repeatedly calculate the relative distances of the events until the relative distances of the M events are obtained. S2-3-5. Sort the relative distances of the M events in ascending order to obtain the relative distance sequence; S2-3-6 assigns monotonically increasing event stage numbers to the relative distances of M events in the relative distance sequence, and associates the event stage numbers with the corresponding behavioral events. In some specific embodiments, hierarchical clustering is performed on N behavior vector sequences to obtain K behavior sequence clusters, including: S3-1. Take the N behavior vector sequences as N initial clusters, and initialize the N initial clusters as the current cluster set; S3-2. In the current cluster set, identify any two clusters that have the minimum sequence distance and merge the cluster pair into a new cluster. S3-3. Remove the cluster pair from the current cluster set and add the new cluster, then update the current cluster set; S3-4. Repeat the update of the current cluster set until the current cluster set contains only a single cluster; S3-5. During each merging operation, record the merged cluster pairs and their corresponding sequence distances, and construct a hierarchical clustering tree representing the evolutionary relationship of bathing behavior patterns based on the merging order. S3-6. Based on the hierarchical clustering tree, extract K behavioral sequence clusters at the corresponding level. In some specific embodiments, identifying cluster pairs with the minimum sequence distance between any two clusters includes: S3-2-1. Retrieve all clusters in the current cluster set; S3-2-2. For any two different clusters C1 and C2, calculate the pairwise sequence distance between all behavior vector sequences in cluster C1 and all behavior vector sequences in cluster C2. S3-2-3. Perform pairwise sequence distance calculations on all cluster pairs to obtain all sequence distances under the current cluster set; S3-2-4. Select the minimum sequence distance from all the sequence distances; S3-2-5. Anchor the cluster pair corresponding to the minimum sequence distance as the two clusters to be merged. In some specific embodiments, a hierarchical clustering tree representing the evolutionary relationship of bathing behavior patterns is constructed based on the merging order, including: S3-5-1. Label the N initial clusters as the N leaf nodes of the hierarchical clustering tree; S3-5-2. In the t-th merge operation, t=1,2,…,N−1, mark the newly generated cluster as an internal node. S3-5-3, Take the sequence distance used for the t-th merging as the node height of the internal node; S3-5-4. Based on the order of merging and the cluster inclusion relationship, connect the leaf nodes and internal nodes from bottom to top to form a complete hierarchical clustering tree structure. In some specific embodiments, based on the hierarchical clustering tree, K behavioral sequence clusters at corresponding levels are extracted, including: S3-6-1. Extract the node height of each internal node in the hierarchical clustering tree and arrange them in the merging order to generate a merging distance sequence; S3-6-2. Calculate the distance increment between the heights of adjacent nodes in the merged distance sequence to obtain the distance increment sequence; S3-6-3, Set the distance jump threshold T; S3-6-4. If, along the ascending direction of the distance increment sequence, there exists a distance increment in the Hth merge that is greater than the distance jump threshold, then clustering is stopped after the Hth merge is completed. S3-6-5. Define the K clusters remaining after the Hth clustering iteration as the behavior sequence clusters; where K=NH. In some specific embodiments, obtaining the latest behavior vector sequence of the current user includes: S5-1. Obtain the first Q behavioral events of the current user and assign event stage numbers to the first Q behavioral events; S5-2. Construct the first Q behavioral events into Q behavioral vectors, and sort them according to the event stage number to form the latest behavioral vector sequence. In some specific embodiments, the current user's security match degree is calculated based on the latest behavior vector sequence, including: S6-1. Calculate the sequence distance between the latest behavior vector sequence and the K typical behavior vector sequences; S6-2. Select the typical behavior vector sequence corresponding to the minimum sequence distance as the optimal matching sequence; S6-3. Real-time update of the latest behavior vector corresponding to the latest behavior event in the latest behavior vector sequence; S6-4. Calculate the safe matching degree between the latest behavior vector and the corresponding behavior vector in the optimal matching sequence. This invention provides a digital safety management and control system for bathing facilities based on Internet of Things (IoT) terminals, which has the following beneficial effects: This invention acquires timestamp event streams from door magnets, water flow sensors, and infrared pyroelectric sensors to construct vector sequences based on behavioral events. Hierarchical clustering is then used to summarize K typical behavioral patterns from historical user data. During real-time monitoring, the system performs stage-aligned matching between the current user's latest behavioral vector sequence and the typical sequences, dynamically calculating the safety matching degree. Because the typical behavioral sequences originate from clusters of real user groups, the system can automatically adapt to the habitual characteristics of different groups such as the elderly and teenagers, avoiding misjudging reasonable behavior as risk. Furthermore, the matching process is based on the first Q behavioral events that have occurred, eliminating the need to wait for the bath to end. Intervention can be triggered as early as the user enters an abnormal state (such as continuous idling in the second stage), significantly improving response timeliness.