What am i doing wrong in ESPHome (Sensor Conversions)

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

no logs - no issue

As my signature says- I am no expert. But, where are “SAR” and “SBR” defined? Shouldn’t that be “SAg” and “SBg”?

2 Likes
 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.

You want:

    lambda: |-
      return id(SAg).state / 1000.0;

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 =========================

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.

Thank you, I’m sure i’d tried that last night though it was very late

Go back and edit your post with code tags. We can’t read your configuration until you do.