I have a ESP32 board with 2 INA219 sensors to monitor DC Current, Voltage and Power. I have scripts to perform specific functions when any of the sensors outputs reach and/or react to VERY specific data when triggered by an array of binary sensors. To properly react, the MINIMUM ‘update_interval’ for the INA219 sensors is 0.4 seconds, however; the projected time per day the INA219 sensors would be active is LESS than 0.1 %. As the ESP32 would, based on the ‘update_interval’, continually collect and transmit data that is 99.9% worthless, is there a way I could, via a script triggered by one of the binary sensors, change the ‘update_interval’ from ‘update_interval: never’ to ‘update_interval: 0.4s’, then back to ‘update_interval: never’???
PS: Yes, I have ‘EXCLUDED’ the two INA219 sensor entities form the ‘RECORD’ function of HA. I just don’t want to beat up the ESP32 with un-necessary functions as well as un-necessary increased WiFi traffic.
TRIED:
Object: 1-Set ’ update_interval: ’ to ‘never’
2-Wait for any one of the TRIGGERS to switch to ‘ON’
3- CHANGE the ’ update_interval: ’ for SPECIFIC sensors to ‘0.4 seconds’
4 - AFTER the last script has executed, Change the ’ update_interval: ’ for SPECIFIC sensors back to ‘never’
globals:
Global string variable
- id: global_string
type: std::string
restore_value: no # Strings cannot be saved/restored
initial_value: ‘“never”’ #IS this correct?
#For INA219 Power-Volt-Current sensors
i2c:
sda: 21 #pin for esp32
scl: 22 #pin for esp32
scan: true
sensor:
#Main-1 Current sensor
- platform: ina219
address: 0x44
shunt_resistance: 0.1 ohm
current:
name: “Main-1 Current”
id: main_1_current
icon: mdi:gauge
accuracy_decimals: 2
update_interval: global_string #WHAT goes HERE? As shown does not work
More sensors, etc
This is one of the TRIGGERS
binary_sensor:
#FIRST trigger
- platform: gpio # signal input to start measurement process
pin:
number: GPIO18
mode: INPUT_PULLUP
inverted: True
name: “Main Signal”
on_press:- globals.set:
id: main_1_current
value: ‘“0.4s”’ #Need to set the “update_interval:” to 0.4 Seconds
- globals.set: