github.com/e154/smart-home@v0.17.2-0.20240311175135-e530a6e5cd45/doc/content/en/docs/plugins/sensor.md (about) 1 2 --- 3 title: "Sensor" 4 linkTitle: "sensor" 5 date: 2021-10-20 6 description: > 7 8 --- 9 10 This "sensor" plugin allows you to create and manage various types of sensors that can measure and track various environmental parameters such as temperature, humidity, light intensity, and other physical quantities. 11 12 Creating an abstract device based on the "sensor" plugin simplifies the process of integrating different sensors into a smart home system. It provides a unified interface for working with different types of sensors, making it easy to retrieve data from them, set their state, and configure their operation parameters. 13 14 Thanks to the flexibility and versatility of the "sensor" plugin, it is suitable for most use cases where working with sensors and obtaining data about the environment's state is required. 15 16 The "sensor" plugin also implements a JavaScript handler called `entityAction`. This handler is designed to handle actions related to "entity" type devices based on the "sensor" plugin. 17 18 Example implementation of the `entityAction` handler: 19 20 ```javascript 21 entityAction = (entityId, actionName, args) => { 22 // Action handling code 23 }; 24 ``` 25 26 In this example, the `entityAction` handler takes two parameters: `entityId`, representing the identifier of the "entity" type device, and `actionName`, representing the name of the action to be performed. 27 28 The `entityAction` handler allows you to perform the necessary logic in response to actions related to "entity" type devices. Inside the handler, you can access functions and methods of the "sensor" plugin to perform specific operations, update the devices' state, or interact with other components of the smart home system. 29 30 Example usage of the `entityAction` handler: 31 32 ```javascript 33 EntityCallAction('sensor.sensor123', 'turnOn'); 34 ``` 35 36 In this example, the `entityAction` handler is called with the device identifier "sensor123" and the action name "turnOn". Inside the handler, you can define the logic associated with executing the required action for the specified device.