Help With Error - project name needs to have a namespace

I’d like to include project information, name and version, in code that I’m writing for a salt level sensor. I though it was a simple matter of adding a project section to the yaml file. Everything I’ve read suggests the following should work;

esphome:
  name: salt-level-sensor
  platform: esp8266
  board: d1_mini
  comment: Water Softener Salt Level Sensor
  project:
    name: "Water Softener Salt Level Sensor"
    version: "salt-level-sensor_2022_08_26_01"
  
# WiFi connection, replace these with values for your WiFi.
wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password

# Enable logging
logger:

# Enable Home Assistant API
api:

# Enable over-the-air updates.
ota:
  password: !secret ota_password

# Enable Web server.
web_server:
  port: 80

# Sync time with Home Assistant.
time:
  - platform: homeassistant
    id: homeassistant_time

# Text sensors with general information.
text_sensor:
  # Expose ESPHome version as sensor.
  - platform: version
    name: salt_level_sensor ESPHome Version
  # Expose WiFi information as sensors.
  - platform: wifi_info
    ip_address:
      name: salt_level_sensor IP
    ssid:
      name: salt_level_sensor SSID
    bssid:
      name: salt_level_sensor BSSID

# Exposed switches.
# Switch to restart the salt_level_sensor.   
switch:
  - platform: restart
    name: "salt_level_sensor Restart"

# Enable On-Board Status LED.
status_led:
  pin:
    # Pin D4
    number: GPIO2
    inverted: true

When I attempt to install the file using ESPHome, I’m presented with an error

project name needs to have a namespace.

INFO Reading configuration /config/esphome/salt-level-sensor.yaml...
INFO Detected timezone 'America/Toronto'
Failed config

esphome: None
  name: salt-level-sensor
  comment: Water Softener Salt Level Sensor
  project: 
    
    project name needs to have a namespace.
    name: Water Softener Salt Level Sensor
    version: salt-level-sensor_2022_08_26_01
  build_path: .esphome/build/salt-level-sensor

I’ve searched the forum without finding a solution. Why is this error occurring?

Sure! As soon as I post the issue I find the solution. Instaed of this;

I should have had this;

esphome:
  name: salt-level-sensor
  platform: esp8266
  board: d1_mini
  comment: Water Softener Salt Level Sensor
  project:
    name: "Robert.Water_Softener_Salt_Level_Sensor"
    version: "salt-level-sensor_2022_08_26_01"

Hi @rcblackwell , is it possible to have the whole code? I am trying to use this Salt level sensor for water softener in Home Assistant with ESPHome – ADONNO but I am getting the following error:
[17:02:00][D][ultrasonic.sensor:036]: ‘Saltlevel in percent’ - Distance measurement timed out!
[17:02:00][D][sensor:126]: ‘Saltlevel in percent’: Sending state -nan % with 2 decimals of accuracy

Sure! I’ve modified code structure since first posting for help. I’m using ‘substitutions:’ which allowed me to create a file to use as a template for each new project. The code below is functioning on my salt-tank.

# Establish Substitutions
substitutions:
    esphome_name: salt-level-sensor
    esphome_platform: ESP8266
    esphome_board: d1_mini
    esphome_comment: Water Softener Salt Level Sensor
    esphome_project_name: "Robert.Water Softener Salt Level Sensor"
    esphome_project_version: "salt-level-sensor_2022_08_31_04"
    devicename: salt_level_sensor
    upper_devicename: Salt Level Sensor

#Define Project Deatils and ESP Board Type
esphome:
    name: $esphome_name
    platform: $esphome_platform
    board: $esphome_board
    comment: $esphome_comment
    project:
        name: $esphome_project_name
        version: $esphome_project_version
        
# WiFi connection, replace these with values for your WiFi.
wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password

# Enable logging
logger:

# Enable Home Assistant API
api:
  encryption:
    key: !secret api_encryption
  password: !secret api_password

# Enable over-the-air updates.
ota:
  password: !secret ota_password

# Enable Web server.
web_server:
  port: 80

# Sync time with Home Assistant.
time:
  - platform: homeassistant
    id: homeassistant_time

# Text sensors with general information.
text_sensor:
  # Expose ESPHome version as sensor.
  - platform: version
    name: $devicename ESPHome Version
  # Expose WiFi information as sensors.
  - platform: wifi_info
    ip_address:
      name: $devicename IP
    ssid:
      name: $devicename SSID
    bssid:
      name: $devicename BSSID

# Exposed switches.
# Switch to restart the salt_level_sensor.   
switch:
  - platform: restart
    name: "$devicename Restart"

# Enable On-Board Status LED.
status_led:
  pin:
    # Pin D4
    number: GPIO2
    inverted: true

sensor:
  # Uptime sensor.
  - platform: uptime
    name: $devicename Uptime

  # WiFi Signal sensor.
  - platform: wifi_signal
    name: $devicename WiFi Signal
    update_interval: 60s

  - platform: ultrasonic
    trigger_pin: GPIO5
    echo_pin: GPIO4
    name: "Saltlevel in percent"
    update_interval: 24h
    filters:

    ### Calculate level in percent ###
    # Sensor comes from factory with unit of measurement set in meters
    # Storage tank height (sensor to bottom of tank) = 84.7cm, 0.847m
    # Subtract measured value from the storage tank height => difference is the salt level = 84.7cm - 44.7cm = 40cm, .847m - .447m = .400
    # 100 % salt level is the container height minus 0.400 meters since nobody will drawn the sensor at full salt level
    # divide salt level through container height minus 0.4000, then multiply result with 100 to achieve percents
    - lambda: return (0.847-x) * (100/0.847);
    unit_of_measurement: "%"
    
  - platform: ultrasonic
    trigger_pin: GPIO5
    echo_pin: GPIO4
    name: "Saltlevel in cm"
    update_interval: 24h
    filters:
    # Container height 52.75cm. From the sensor to the top of the water that accumulates in the bin.
    # Multiply result by 100 - convert M to CM. Sensor works in meters
    - lambda: return (0.847-x)*100.0;
    unit_of_measurement: "cm"
1 Like

Thank you so much for sharing the code, I like the substitution idea.
So I copy pasted exactly everything and I am ending up with the same error:

[22:38:21][D][ultrasonic.sensor:036]: ‘Saltlevel in percent’ - Distance measurement timed out!
[22:38:21][D][sensor:126]: ‘Saltlevel in percent’: Sending state -nan % with 2 decimals of accuracy
[22:38:31][D][sensor:126]: ‘salt_level_sensor Uptime’: Sending state 223.32001 s with 0 decimals of accuracy
[22:38:38][D][sensor:126]: ‘salt_level_sensor WiFi Signal’: Sending state -63.00000 dBm with 0 decimals of accuracy
[22:38:44][D][ultrasonic.sensor:036]: ‘Saltlevel in cm’ - Distance measurement timed out!
[22:38:44][D][sensor:126]: ‘Saltlevel in cm’: Sending state -nan cm with 2 decimals of accuracy

How can I add, inverted: true for both GPIO4&5, maybe this could resolve the issue… cos I can’t think of any other thing. I am using a D1 mini and a AZDelivery HC-SR04 ultrasound sensor…

All good, thanks a lot for the help. Faulty pin… I had to solder the board so it came back online!

Been there before! Please to hear it’s now working.