zahk
(Hazk)
September 10, 2021, 10:03am
1
Hello,
I am using ESP32 to read values from INA3221 - voltage - and if that is more than 6v - it needs to switch the relay. After the voltage is low - it should revert change.
In my code I have used (of course that are parts of, I see values from INA3221 in logs and webserver.
That doesn’t work.
But… when clicking button itself in web gui work. ;(
- platform: gpio
restore_mode: always_off
name: "bagrelay_e2_PCF8574 pin#0"
id: b0
pin:
pcf8574: e2_p
number: 0
mode: OUTPUT
inverted: true
- platform: gpio
restore_mode: always_off
name: "bagrelay_e2_PCF8574 Pin #1"
id: b1
pin:
pcf8574: e2_p
number: 1
mode: OUTPUT
inverted: true
- platform: gpio
restore_mode: always_off
name: "FRONT_bagrelay_e2_PCF8574 Pin #2"
id: b2
pin:
pcf8574: e2_p
number: 2
mode: OUTPUT
inverted: true
- platform: ina3221
i2c_id: e2
update_interval: 30s
address: 0x40
channel_1:
shunt_resistance: 0.1 ohm
current:
name: "INA3221 Channel 1 Current"
# state_topic: redacted/feeds/ina31c
# discovery: False
power:
name: "INA3221 Channel 1 Power"
# state_topic: redacted/feeds/ina31p
# discovery: False
bus_voltage:
name: "INA3221 Channel 1 Bus Voltage"
on_value_range:
- above: 6
then:
- switch.turn_on: b2
- below: 1
then:
- switch.turn_off: b2
tom_l
September 10, 2021, 10:23am
2
zahk:
switch.turn_on: b2
Is b2 a switch or an output?
You have not included that important part of your config in your post.
zahk
(Hazk)
September 10, 2021, 10:34am
3
hmm, b2 is OUTPUT. If I properly undesrstand yr doubt
tom_l
September 10, 2021, 10:39am
4
Then you cant use the switch .turn_on service. It must be the output .turn_on service.
1 Like
zahk
(Hazk)
September 10, 2021, 11:30am
5
hmm, Just after your hint Ive tried to compile:
sensor.ina3221:
platform: ina3221
i2c_id: e2
update_interval: 30s
address: 0x40
channel_1:
shunt_resistance: 0.1
current:
name: INA3221 Channel 1 Current
force_update: False
unit_of_measurement: A
icon: mdi:flash
accuracy_decimals: 2
power:
name: INA3221 Channel 1 Power
force_update: False
unit_of_measurement: W
icon: mdi:flash
accuracy_decimals: 2
bus_voltage:
name: INA3221 Channel 1 Bus Voltage
on_value_range:
- above: 14.01
then:
- output.turn_on:
ID 'b2' of type gpio::GPIOSwitch doesn't inherit from output::BinaryOutput. Please double check your ID is pointing to the correct value.
id: b2
- below: 14.0
then:
- output.turn_off:
ID 'b2' of type gpio::GPIOSwitch doesn't inherit from output::BinaryOutput. Please double check your ID is pointing to the correct value.
id: b2
force_update: False
unit_of_measurement: V
icon: mdi:flash
accuracy_decimals: 2
shunt_voltage:
zahk
(Hazk)
September 10, 2021, 11:34am
6
btw thats part of my physical buttons config:
binary_sensor:
- platform: gpio
name: 5_14-btn3
pin:
number: 14
mode: input
on_double_click:
min_length: 50ms
max_length: 350ms
then:
- switch.toggle: b2
tom_l
September 10, 2021, 11:44am
7
Can you show what is above this part of your config please?
- platform: gpio
restore_mode: always_off
name: "bagrelay_e2_PCF8574 pin#0"
id: b0
pin:
pcf8574: e2_p
number: 0
mode: OUTPUT
inverted: true
zahk
(Hazk)
September 10, 2021, 1:05pm
8
All of my code:
esphome:
name: a_cc
platform: ESP32
board: esp32dev
wifi:
ssid "redacted"
passwor "redacted"
use_addres redacted
# Enable logging
logger:
# Enable Home Assistant API
api:
reboot_timeout: 0s
ota:
web_server:
port: 80
binary_sensor:
- platform: gpio
name: 5_14-btn3
pin:
number: 14
mode: input
on_double_click:
min_length: 50ms
max_length: 350ms
then:
- switch.toggle: b2
#on_press:
#
# then:
# - rtttl.play: 'two short:d=4,o=5,b=100:16e6'
#
#- switch.toggle: a10
- platform: gpio
name: 4_25-btn1
pin:
number: 25
mode: input
on_press:
then:
- rtttl.play: 'two short:d=4,o=5,b=100:16e6'
- switch.toggle: rll30a
- platform: gpio
name: 6_27-btn2
pin:
number: 27
mode: input
on_press:
then:
- rtttl.play: 'two short:d=4,o=5,b=100:16e6'
- switch.toggle: a5
- platform: gpio
name: 2_39-btn5
pin:
number: 39
mode: input
on_press:
then:
- rtttl.play: 'two short:d=4,o=5,b=100:16e6,16e6,16e6'
- switch.toggle: rll3
- platform: gpio
name: 3_dupa36-btn4
pin:
number: 36
mode: input
on_press:
then:
- switch.toggle: a1
- rtttl.play: 'two short:d=4,o=5,b=100:16e6'
- platform: gpio
name: 9_fiol26-btn8
pin:
number: 26
mode: input
on_press:
then:
- switch.toggle: a7
#- switch.toggle: rll1
- rtttl.play: 'two short:d=4,o=5,b=100:16e6'
- platform: gpio
name: 1_dupa34-btn6
pin:
number: 34
mode: input
on_press:
then:
- rtttl.play: 'two short:d=4,o=5,b=100:16e6,16e6'
- switch.toggle: a1
- platform: gpio
name: 8_dupa4-btn9
pin:
number: 4
mode: input
on_press:
then:
- rtttl.play: 'two short:d=4,o=5,b=100:16e6,16e6,16e6'
- switch.toggle: rll2
- platform: gpio
name: 7_siodmy-pin16-btn7
pin:
number: 16
mode: input
on_press:
then:
- rtttl.play: 'two short:d=4,o=5,b=100:16e6,16e6,16e6'
#- switch.toggle: a10
switch:
- platform: template
name: relayll
id: rll1
turn_on_action:
- switch.turn_on: a1
- delay: 900ms
- switch.turn_off: a1
- platform: template
name: relayll2-patttern-R
id: rll2
turn_on_action:
- switch.turn_on: a2
- delay: 300ms
- switch.turn_off: a2
- platform: template
name: rrll3-patternL
id: rll3
turn_on_action:
- switch.turn_on: a3
- delay: 300ms
- switch.turn_off: a3
- platform: template
name: relayll4
id: rll4
turn_on_action:
- switch.turn_on: a4
- delay: 900ms
- switch.turn_off: a4
- platform: template
name: relayll5
id: rll5
turn_on_action:
- switch.turn_on: a5
- delay: 900ms
- switch.turn_off: a5
- platform: template
name: relayll6
id: rll6
turn_on_action:
- switch.turn_on: a6
- delay: 900ms
- switch.turn_off: a6
- platform: gpio
name: d17-relay30a
restore_mode: always_off
id: rll30a
pin:
number: 17
inverted: False
- platform: gpio
restore_mode: always_off
name: "PCF8574 Pin #1"
id: a1
pin:
pcf8574: e1_p
number: 1
mode: OUTPUT
inverted: true
- platform: gpio
restore_mode: always_off
name: "PCF8574 Pin #2"
id: a2
pin:
pcf8574: e1_p
number: 2
mode: OUTPUT
inverted: true
- platform: gpio
restore_mode: always_off
name: "PCF8574 Pin #3"
id: a3
pin:
pcf8574: e1_p
number: 3
mode: OUTPUT
inverted: true
- platform: gpio
restore_mode: always_off
name: "hgw-horn__PCF8574 Pin #4"
id: a4
pin:
pcf8574: e1_p
number: 4
mode: OUTPUT
inverted: true
- platform: gpio
restore_mode: always_off
name: "PCF8574 Pin #5"
id: a5
pin:
pcf8574: e1_p
number: 5
mode: OUTPUT
inverted: true
- platform: gpio
restore_mode: always_off
name: "pusty_PCF8574 Pin #6"
id: a6
pin:
pcf8574: e1_p
number: 6
mode: OUTPUT
inverted: true
- platform: gpio
restore_mode: always_off
name: "PCF8574 Pin #7"
id: a7
pin:
pcf8574: e1_p
number: 0
mode: OUTPUT
inverted: true
- platform: gpio
restore_mode: always_off
name: "pusty__PCF8574 Pin #7"
id: a7true7relay
pin:
pcf8574: e1_p
number: 7
mode: OUTPUT
inverted: true
- platform: gpio
restore_mode: always_off
name: "bagrelay_e2_PCF8574 pin#0"
id: b0
pin:
pcf8574: e2_p
number: 0
mode: OUTPUT
inverted: true
- platform: gpio
restore_mode: always_off
name: "bagrelay_e2_PCF8574 Pin #1"
id: b1
pin:
pcf8574: e2_p
number: 1
mode: OUTPUT
inverted: true
- platform: gpio
restore_mode: always_off
name: "FRONT_bagrelay_e2_PCF8574 Pin #2"
id: b2
pin:
pcf8574: e2_p
number: 2
mode: OUTPUT
inverted: true
- platform: gpio
restore_mode: always_off
name: "KAM360_bagrelay_e2_PCF8574 Pin #3"
id: b3
pin:
pcf8574: e2_p
number: 3
mode: OUTPUT
inverted: true
# - platform: gpio
# restore_mode: always_off
# name: "bagrelay_e2_PCF8574 Pin #4"
# id: b4
# pin:
# pcf8574: e2_p
# number: 4
# mode: OUTPUT
# inverted: true
# - platform: gpio
# restore_mode: always_off
# name: "bagrelay_e2_PCF8574 Pin #5"
# id: b5
# pin:
# pcf8574: e2_p
# number: 5
# mode: OUTPUT
# inverted: true
# - platform: gpio
# restore_mode: always_off
# name: "PCF8574 Pin #6"
# id: b6
# pin:
# pcf8574: e2_p
# number: 6
# mode: OUTPUT
# inverted: true
# - platform: gpio
# restore_mode: always_off
# name: "bagrelay_e2_PCF8574 Pin #7"
# id: b7
# pin:
# pcf8574: e2_p
# number: 7
# mode: OUTPUT
# inverted: true
- platform: restart
name: "OSTROZNIE___RESTART"
sensor:
# commented out due to looking for cause of restarting
# - platform: wifi_signal
# name: "esp32 car WiFi signal"
# update_interval: 300s
- platform: uptime
name: "esp32 car uptime"
update_interval: 300s
- platform: htu21d
update_interval: 300s
i2c_id: e1
temperature:
name: "temp"
humidity:
name: "hum"
- platform: ina3221
i2c_id: e2
update_interval: 30s
address: 0x40
channel_1:
shunt_resistance: 0.1 ohm
current:
name: "INA3221 Channel 1 Current"
# state_topic: redacted/feeds/ina31c
# discovery: False
power:
name: "INA3221 Channel 1 Power"
# state_topic: redacted/feeds/ina31p
# discovery: False
bus_voltage:
name: "INA3221 Channel 1 Bus Voltage"
on_value_range:
- above: 14.01
then:
- output.turn_on: b2
- below: 14
then:
- output.turn_off: b2
# state_topic: redacted/feeds/ina31bv
# discovery: False
shunt_voltage:
name: "INA3221 Channel 1 Shunt Voltage"
# state_topic: redacted/feeds/ina31sv
# discovery: False
channel_2:
shunt_resistance: 0.1 ohm
current:
name: "INA3221 Channel 2 Current"
# state_topic: redacted/feeds/ina32c
# discovery: False
power:
name: "INA3221 Channel 2 Power"
# state_topic: redacted/feeds/ina32p
# discovery: False
shunt_voltage:
name: "INA3221 Channel 2 Shunt Voltage"
# state_topic: redacted/feeds/ina32sv
# discovery: False
bus_voltage:
name: "INA3221 Channel 2 Bus Voltage"
# state_topic: redacted/feeds/ina32bv
# discovery: False
channel_3:
shunt_resistance: 0.1 ohm
current:
name: "INA3221 Channel 3 Current"
# state_topic: redacted/feeds/ina33c
# discovery: False
power:
name: "INA3221 Channel 3 Power"
# state_topic: ${topic_prefix}/ina33p
# discovery: False
bus_voltage:
name: "INA3221 Channel 3 Bus Voltage"
# state_topic: ${topic_prefix}/ina33bv
# discovery: False
shunt_voltage:
name: "INA3221 Channel 3 Shunt Voltage"
# state_topic: ${topic_prefix}/ina33sv
# discovery: False
i2c:
- sda: 21
scl: 22
id: e1
- sda: 23
scl: 5
id: e2
pcf8574:
- id: 'e1_p'
i2c_id: e1
address: 0x21
pcf8575: False
- id: 'e2_p'
i2c_id: e2
address: 0x22
pcf8575: False
time:
- platform: sntp
id: my_time
# Status Sensors
output:
- platform: ledc
pin: GPIO2
id: rtttl_out
rtttl:
output: rtttl_out
tom_l
September 10, 2021, 1:22pm
9
So it is a switch, not an output. It is under the switch:
key. Ignore my previous advice.
zahk
(Hazk)
September 16, 2021, 12:12pm
10
Thank you for your reply.
So, then my first assumption was proper one - but it doesn’t work.
May the value should have a unit? “above: 6v” not pure “above: 6” ?