jonathan3
(Jonathan)
January 3, 2025, 4:26am
1
what am i doing wrong here,
sensor:
- platform: hx711
name: "Scale A g"
id: "SAg"
dout_pin: GPIO4
clk_pin: GPIO5
gain: 64
update_interval: 1s
filters:
- calibrate_linear:
- -10000 -> 0
- -11567 -> 1000
device_class: "weight"
state_class: "measurement"
unit_of_measurement: g
icon: mdi:scale
accuracy_decimals: 1
internal: false
- platform: hx711
name: "Scale B g"
id: "SBg"
dout_pin: GPIO12
clk_pin: GPIO14
gain: 64
update_interval: 1s
filters:
- calibrate_linear:
- -10000 -> 0
- -11567 -> 1000
device_class: "weight"
state_class: "measurement"
unit_of_measurement: g
icon: mdi:scale
accuracy_decimals: 1
internal: false
- platform: template
name: "Scale A kg"
id: SAkg
lambda: |-
return id("SAR") / 1000.0;
update_interval: 5s
device_class: "weight"
state_class: "measurement"
unit_of_measurement: kg
icon: mdi:scale
accuracy_decimals: 3
internal: false
- platform: template
name: "Scale B kg"
id: SBkg
lambda: |-
return id("SBR") / 1000.0;
update_interval: 5s
device_class: "weight"
state_class: "measurement"
unit_of_measurement: kg
icon: mdi:scale
accuracy_decimals: 3
internal: false
the Scale A/B kg just show 83 (statically) , where as the Scale A/B g shows correctly and changes
stevemann
(Stephen Mann (YAML-challenged))
January 3, 2025, 4:38am
3
As my signature says- I am no expert. But, where are “SAR” and “SBR” defined? Shouldn’t that be “SAg” and “SBg”?
2 Likes
jonathan3
(Jonathan)
January 3, 2025, 10:22am
4
substitutions:
device_name: -test
esphome:
name: ${device_name}
friendly_name: ${device_name}
#name_add_mac_suffix: true
esp8266:
board: esp01_1m
# Enable logging
logger:
# Enable Home Assistant API
api:
encryption:
key: "Key="
ota:
- platform: esphome
password: "Key"
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
# Enable fallback hotspot (captive portal) in case wifi connection fails
ap:
ssid: "Gas-Bottles"
password: "vziYD1UCzCLT"
sensor:
- platform: uptime
name: "Uptime"
- platform: wifi_signal
name: "WiFi Signal"
update_interval: 60s
- platform: hx711
name: "Scale A g"
id: SAg
dout_pin: GPIO4
clk_pin: GPIO5
gain: 64
update_interval: 1s
filters:
- calibrate_linear:
- -10000 -> 0
- -11567 -> 1
device_class: "weight"
state_class: "measurement"
unit_of_measurement: g
icon: mdi:scale
accuracy_decimals: 4
#internal: true
- platform: hx711
name: "Scale B g"
id: SBg
dout_pin: GPIO12
clk_pin: GPIO14
gain: 64
update_interval: 1s
filters:
- calibrate_linear:
- -10000 -> 0
- -11567 -> 1
device_class: "weight"
state_class: "measurement"
unit_of_measurement: g
icon: mdi:scale
accuracy_decimals: 4
#internal: true
- platform: template
name: "Scale A kg"
id: SAkg
lambda: |-
return id("SAg") / 1000.00 ;
update_interval: 5s
device_class: "weight"
state_class: "measurement"
unit_of_measurement: kg
icon: mdi:scale
accuracy_decimals: 1
internal: false
- platform: template
name: "Scale B kg"
id: SBkg
lambda: |-
return id("SBg") /1000.00 ;
update_interval: 5s
device_class: "weight"
state_class: "measurement"
unit_of_measurement: kg
icon: mdi:scale
accuracy_decimals: 1
internal: false
text_sensor:
- platform: version
name: "ESPHome Version"
- platform: wifi_info
ip_address:
name: "IP Address"
id: "ip_address"
icon: mdi:ip-network
binary_sensor:
- platform: status
name: "Status"
button:
- platform: restart
name: "Restart"
captive_portal:
web_server:
port: 80
so this is the full config, i did notice a couple of typos which have been fixed and it still does not play nicely.
the kg still isn’t showing correctly.
in terms of compilation errors there are none, but the return id(“SBg”) dosen’t appear to pull the g value.
Troon
(Troon)
January 3, 2025, 10:45am
5
You want:
lambda: |-
return id(SAg).state / 1000.0;
jonathan3
(Jonathan)
January 3, 2025, 11:18am
6
that gives me compilation errors.
/config/esphome/-test.yaml: In lambda function:
/config/esphome/-test.yaml:82:24: error: request for member 'state' in 'esphome::id<const char>(((const char*)"SAg"))', which is of non-class type 'const char'
82 | return id("SAg").state / 1000.00 ;
| ^~~~~
/config/esphome/-test.yaml: In lambda function:
/config/esphome/-test.yaml:95:24: error: request for member 'state' in 'esphome::id<const char>(((const char*)"SBg"))', which is of non-class type 'const char'
95 | return id("SBg").state /1000.00 ;
| ^~~~~
*** [.pioenvs/-test/src/main.cpp.o] Error 1
========================= [FAILED] Took 10.56 seconds =========================
Troon
(Troon)
January 3, 2025, 11:20am
7
Look again at my code. No quotes around SAg
.
Please format logs, code etc correctly using the </> button to avoid destroying quotes and indentation, like you did in your original post.
jonathan3
(Jonathan)
January 3, 2025, 11:25am
8
Thank you, I’m sure i’d tried that last night though it was very late
stevemann
(Stephen Mann (YAML-challenged))
January 3, 2025, 4:07pm
9
Go back and edit your post with code tags. We can’t read your configuration until you do.