PhoneProfilesPlus
PhoneProfilesPlus copied to clipboard
Custom Sensors
Please add a way to send an intent for a custom sensor. Here is the "documentation" on such an event.
Send Intent [
Action: sk.henrichg.phoneprofilesplus.ACTION_SET_SENSOR_VALUE
Extra: sensor_name:sensor name
Extra: sensor_value:sensor value
Target: Activity
]
On the Event preferences screen, in the Sensor parameters section, please add a Custom sensor. The Custom sensor screen will show the names of all of "sensor names" and their values from the Send Intents that PPP has received so far. For each sensor name, the user can enable the sensor and specify a criteria for the value (e.g. =, !=, <, <=, >, >=).
For example, I could have an app called Automate detect when Zoom is running on my laptop. Automate will then send an intent to PPP with sensor_name = Laptop Zoom Meeting" and a sensor_value=1. In PPP, I could enable the Laptop Zoom Meeting` custom sensor in an event and require the value to be 1. When true, the event will change PPP to a vibrate profile and my Zoom meeting will not be bothered by noises from my cell phone. When I end the meeting in Zoom on my laptop, Automate will detect this, send an intent to PPP. The event will no longer be triggered and PPP will change to a different profile.
Note: I wrote a very simple HTTP server on my laptop that returns 1 or 0 if a Zoom meeting is running or not. Automate simply does an HTTP request to my laptop.
The user should be allowed to delete a "sensor name" in case they want to rename it or discontinue using it. All of the events drop using the custom sensor. If a Send Intent arrives with the same name, then PPP creates a new custom sensor for it.
I leave it to the implementer to figure out how to distinguish between a number and String in a sensor_value. I leave it to the implementer to figure out how to make the criteria handle numbers and Strings for the comparisons.
Right now, I have implemented in Automate the logic to request the HTTP server on my laptop for the Zoom meeting state. This is easy. I have implemented the event logic in Automate with the Laptop Zoom Meeting custom sensor. However, the event logic is proving to be challenging to get right. With the above feature, the Automate logic will be very simple (i.e. request the HTTP server on my laptop and send the intent to PPP).
Here is another use case. Automate calls the HTTP server on my laptop to see if I am working on my laptop. If so, Automate sends an intent for Working on Laptop with 0 or 1. I can then have an event set my phone to a quiet profile if I am working on my laptop.
Typically during the night, I have PPP set a silent profile. If a priority person calls during the night, PPP sets a loud profile so I will wake up and answer the emergency call.
However, what if the person is not a priority person? What if they call me several times in a row? They will not get through to me during the night. The next morning when I look at my phone, I will see that they called frantically and wish I had known.
With custom sensors and Automate this is easy to implement. Automate can detect that the person is calling for the second time within X minutes. Automate can then set the Frantic Call custom sensor. PPP events will take care of changing to a loud profile.
II I correctly uderstand:
Automate sent action Intent sk.henrichg.phoneprofilesplus.ACTION_SET_SENSOR_VALUE and PPP must start it, as other Intents from extermal appliactions (for example k.henrichg.phoneprofilesplus.ACTION_ACTIVATE_PROFILE). This must save all received extra sensor_name, sensor_value.
Then must exists for event new sensor. In this sensor must be configured sensor_name and sensor_value. And sensor must be passed (green), when for saved sensor_name its sensor_value is configured sensor_value from event sensor.
This is correct?
There were a few typos but I hopefully interpreted correctly what you are saying. I think you understand correctly.