Untitled
unknown
plain_text
10 months ago
5.9 kB
8
Indexable
esphome:
name: esphome-web-6ab7d2
friendly_name: "INA3221 Power Monitor"
min_version: 2024.11.0
name_add_mac_suffix: false
esp8266:
board: esp01_1m
# Enable logging
logger:
# Enable Home Assistant API
api:
# Allow Over-The-Air updates
ota:
- platform: esphome
wifi:
ssid: ""
password: ""
# Define I2C interface
i2c:
sda: 4
scl: 5
scan: true
globals:
- id: mah_usage_ch1
type: float
restore_value: no
initial_value: '0.0'
- id: mah_usage_ch2
type: float
restore_value: no
initial_value: '0.0'
- id: mah_usage_ch3
type: float
restore_value: no
initial_value: '0.0'
- id: tracking_enabled_ch1
type: bool
restore_value: no
initial_value: 'false'
- id: tracking_enabled_ch2
type: bool
restore_value: no
initial_value: 'false'
- id: tracking_enabled_ch3
type: bool
restore_value: no
initial_value: 'false'
- id: tracking_time_ch1
type: int
restore_value: no
initial_value: '3600' # Default: 60 seconds
- id: tracking_time_ch2
type: int
restore_value: no
initial_value: '3600' # Default: 60 seconds
- id: tracking_time_ch3
type: int
restore_value: no
initial_value: '3600' # Default: 60 seconds
switch:
- platform: template
name: "Track mAh Channel 1"
id: track_mah_ch1
optimistic: true
restore_mode: ALWAYS_OFF
turn_on_action:
- lambda: |-
id(mah_usage_ch1) = 0.0;
id(tracking_enabled_ch1) = true;
- delay: !lambda "return id(tracking_time_ch1) * 1000;"
- lambda: |-
id(tracking_enabled_ch1) = false;
- switch.turn_off: track_mah_ch1
- platform: template
name: "Track mAh Channel 2"
id: track_mah_ch2
optimistic: true
restore_mode: ALWAYS_OFF
turn_on_action:
- lambda: |-
id(mah_usage_ch2) = 0.0;
id(tracking_enabled_ch2) = true;
- delay: !lambda "return id(tracking_time_ch2) * 1000;"
- lambda: |-
id(tracking_enabled_ch2) = false;
- switch.turn_off: track_mah_ch2
- platform: template
name: "Track mAh Channel 3"
id: track_mah_ch3
optimistic: true
restore_mode: ALWAYS_OFF
turn_on_action:
- lambda: |-
id(mah_usage_ch3) = 0.0;
id(tracking_enabled_ch3) = true;
- delay: !lambda "return id(tracking_time_ch3) * 1000;"
- lambda: |-
id(tracking_enabled_ch3) = false;
- switch.turn_off: track_mah_ch3
sensor:
- platform: ina3221
address: 0x42
update_interval: 1s
channel_1:
shunt_resistance: 0.1 ohm
current:
name: "INA3221 Channel 1 Current"
unit_of_measurement: "mA"
accuracy_decimals: 1
filters:
- multiply: 1000
id: current_sensor_ch1
on_value:
- lambda: |-
if (id(tracking_enabled_ch1)) {
id(mah_usage_ch1) += x * (1.0 / 3600.0);
}
power:
name: "INA3221 Channel 1 Power"
unit_of_measurement: "mW"
accuracy_decimals: 1
filters:
- multiply: 1000
bus_voltage:
name: "INA3221 Channel 1 Bus Voltage"
channel_2:
shunt_resistance: 0.1 ohm
current:
name: "INA3221 Channel 2 Current"
unit_of_measurement: "mA"
accuracy_decimals: 1
filters:
- multiply: 1000
id: current_sensor_ch2
on_value:
- lambda: |-
if (id(tracking_enabled_ch2)) {
id(mah_usage_ch2) += x * (1.0 / 3600.0);
}
power:
name: "INA3221 Channel 2 Power"
unit_of_measurement: "mW"
accuracy_decimals: 1
filters:
- multiply: 1000
bus_voltage:
name: "INA3221 Channel 2 Bus Voltage"
channel_3:
shunt_resistance: 0.1 ohm
current:
name: "INA3221 Channel 3 Current"
unit_of_measurement: "mA"
accuracy_decimals: 1
filters:
- multiply: 1000
id: current_sensor_ch3
on_value:
- lambda: |-
if (id(tracking_enabled_ch3)) {
id(mah_usage_ch3) += x * (1.0 / 3600.0);
}
power:
name: "INA3221 Channel 3 Power"
unit_of_measurement: "mW"
accuracy_decimals: 1
filters:
- multiply: 1000
bus_voltage:
name: "INA3221 Channel 3 Bus Voltage"
- platform: template
name: "mAh Used Channel 1"
id: mah_used_ch1
unit_of_measurement: "mAh"
accuracy_decimals: 2
lambda: |-
return id(mah_usage_ch1);
- platform: template
name: "mAh Used Channel 2"
id: mah_used_ch2
unit_of_measurement: "mAh"
accuracy_decimals: 2
lambda: |-
return id(mah_usage_ch2);
- platform: template
name: "mAh Used Channel 3"
id: mah_used_ch3
unit_of_measurement: "mAh"
accuracy_decimals: 2
lambda: |-
return id(mah_usage_ch3);
number:
- platform: template
name: "Track Time for Channel 1"
id: track_time_ch1
min_value: 10
max_value: 86400
step: 10
initial_value: 3600
set_action:
- lambda: |-
id(tracking_time_ch1) = x;
- platform: template
name: "Track Time for Channel 2"
id: track_time_ch2
min_value: 10
max_value: 86400
step: 10
initial_value: 3600
set_action:
- lambda: |-
id(tracking_time_ch2) = x;
- platform: template
name: "Track Time for Channel 3"
id: track_time_ch3
min_value: 10
max_value: 86400
step: 10
initial_value: 3600
set_action:
- lambda: |-
id(tracking_time_ch3) = x;Editor is loading...
Leave a Comment