MallocArray / airgradient_esphome

ESPHome definition for an AirGradient DIY device to send data to HomeAssistant and AirGradient servers
GNU General Public License v3.0
224 stars 34 forks source link

Compile error with ESPHome 2024.8.0 for #80

Closed jeroenleenarts closed 3 weeks ago

jeroenleenarts commented 3 weeks ago
INFO ESPHome 2024.8.0
INFO Reading configuration /config/esphome/air-gradient-pro.yaml...
Failed config

interval: [source /data/packages/76b4402f/packages/display_sh1106_multi_page.yaml:192]
  - interval: 10s
    startup_delay: 1s
    then: 
      if: 
        condition: 
          switch.is_on: display_boot_page
        then: 
          switch.turn_off: display_boot_page
  - interval: 5s
    then: 
      - if: 
          condition: 
            switch.is_on: display_blank_page
          then: 
            - display.page.show: blank
            - component.update: oled_display
          else: 
            - display.page.show_next: oled_display
            - component.update: oled_display
  - interval: 5s
    then: 
      - if: 
          condition: 
            light.is_on: led_strip
          then: 
            - if: 
                condition: 
                  lambda: return !(isnan(id(co2).state));
                then: 
                  - light.addressable_set: 
                      id: led_strip
                      color_brightness: !lambda |-
                        return ((id(led_brightness).state - (id(led_fade).state * 5)) / 100.0);
                      range_from: 0
                      range_to: 10
                      red: !lambda |-
                        return (id(co2).state < 400) ? 0 : (id(co2).state <= 1000) ? (id(co2).state - 400) / (1000 - 400) : 1;
                      green: !lambda |-
                        return (id(co2).state < 1000) ? 1 : (id(co2).state <= 2000) ? 1 - (id(co2).state - 1000) / (2000 - 1000) : 0;
                      blue: !lambda |-
                        return (id(co2).state < 2000) ? 0 : (id(co2).state <= 4000) ? (id(co2).state - 2000) / (4000 - 2000) : 1;
                  - light.addressable_set: 
                      id: led_strip
                      color_brightness: !lambda |-
                        return ((id(led_brightness).state - (id(led_fade).state * 4)) / 100.0);
                      range_from: 1
                      range_to: 9
                      red: !lambda |-
                        return (id(co2).state < 400) ? 0 : (id(co2).state <= 1000) ? (id(co2).state - 400) / (1000 - 400) : 1;
                      green: !lambda |-
                        return (id(co2).state < 1000) ? 1 : (id(co2).state <= 2000) ? 1 - (id(co2).state - 1000) / (2000 - 1000) : 0;
                      blue: !lambda |-
                        return (id(co2).state < 2000) ? 0 : (id(co2).state <= 4000) ? (id(co2).state - 2000) / (4000 - 2000) : 1;
                  - light.addressable_set: 
                      id: led_strip
                      color_brightness: !lambda |-
                        return ((id(led_brightness).state - (id(led_fade).state * 3)) / 100.0);
                      range_from: 2
                      range_to: 8
                      red: !lambda |-
                        return (id(co2).state < 400) ? 0 : (id(co2).state <= 1000) ? (id(co2).state - 400) / (1000 - 400) : 1;
                      green: !lambda |-
                        return (id(co2).state < 1000) ? 1 : (id(co2).state <= 2000) ? 1 - (id(co2).state - 1000) / (2000 - 1000) : 0;
                      blue: !lambda |-
                        return (id(co2).state < 2000) ? 0 : (id(co2).state <= 4000) ? (id(co2).state - 2000) / (4000 - 2000) : 1;
                  - light.addressable_set: 
                      id: led_strip
                      color_brightness: !lambda |-
                        return ((id(led_brightness).state - (id(led_fade).state * 2)) / 100.0);
                      range_from: 3
                      range_to: 7
                      red: !lambda |-
                        return (id(co2).state < 400) ? 0 : (id(co2).state <= 1000) ? (id(co2).state - 400) / (1000 - 400) : 1;
                      green: !lambda |-
                        return (id(co2).state < 1000) ? 1 : (id(co2).state <= 2000) ? 1 - (id(co2).state - 1000) / (2000 - 1000) : 0;
                      blue: !lambda |-
                        return (id(co2).state < 2000) ? 0 : (id(co2).state <= 4000) ? (id(co2).state - 2000) / (4000 - 2000) : 1;
                  - light.addressable_set: 
                      id: led_strip
                      color_brightness: !lambda |-
                        return ((id(led_brightness).state - (id(led_fade).state)) / 100.0);
                      range_from: 4
                      range_to: 6
                      red: !lambda |-
                        return (id(co2).state < 400) ? 0 : (id(co2).state <= 1000) ? (id(co2).state - 400) / (1000 - 400) : 1;
                      green: !lambda |-
                        return (id(co2).state < 1000) ? 1 : (id(co2).state <= 2000) ? 1 - (id(co2).state - 1000) / (2000 - 1000) : 0;
                      blue: !lambda |-
                        return (id(co2).state < 2000) ? 0 : (id(co2).state <= 4000) ? (id(co2).state - 2000) / (4000 - 2000) : 1;
                  - light.addressable_set: 
                      id: led_strip
                      color_brightness: !lambda |-
                        return id(led_brightness).state / 100.0;
                      range_from: 5
                      range_to: 5
                      red: !lambda |-
                        return (id(co2).state < 400) ? 0 : (id(co2).state <= 1000) ? (id(co2).state - 400) / (1000 - 400) : 1;
                      green: !lambda |-
                        return (id(co2).state < 1000) ? 1 : (id(co2).state <= 2000) ? 1 - (id(co2).state - 1000) / (2000 - 1000) : 0;
                      blue: !lambda |-
                        return (id(co2).state < 2000) ? 0 : (id(co2).state <= 4000) ? (id(co2).state - 2000) / (4000 - 2000) : 1;
            - if: 
                condition: 
                  lambda: return (isnan(id(co2).state));
                then: 
                  - light.addressable_set: 
                      id: led_strip
                      color_brightness: !lambda |-
                        return id(led_brightness).state / 100.0;
                      range_from: 0
                      range_to: 10
                      red: 0%
                      green: 0%
                      blue: 0%
  - interval: 2.5min
    then: 
      if: 
        condition: 
          switch.is_on: upload_airgradient
        then: 
          - http_request.post: 
              url: !lambda |-
                return "https://hw.airgradient.com/sensors/airgradient:" + get_mac_address() + "/measures";
              headers: 
                Content-Type: application/json
              json: 
                wifi: !lambda |-
                  return to_string(id(wifi_dbm).state);
                rco2: !lambda |-
                  return to_string(id(co2).state);
                pm01: !lambda |-
                  return to_string(id(pm_1_0).state);
                pm02: !lambda |-
                  return to_string(id(pm_2_5).state);
                pm10: !lambda |-
                  return to_string(id(pm_10_0).state);
                pm003Count: !lambda |-
                  return to_string(id(pm_0_3um).state);
                atmp: !lambda |-
                  return to_string(id(temp_raw).state);
                atmpCompensated: !lambda |-
                  return to_string(id(temp).state);
                rhum: !lambda |-
                  return to_string(id(humidity_raw).state);
                rhumCompensated: !lambda |-
                  return to_string(id(humidity).state);
                tvocIndex: !lambda |-
                  return to_string(id(voc).state);
                noxIndex: !lambda |-
                  return to_string(id(nox).state);
                boot: !lambda |-
                  return to_string(round(id(device_uptime).state/60));
  - interval: 2.5min
    then: 
      - 
        ID 'watchdog' conflicts with the name of an esphome integration, please use another ID name.
        output.turn_on: watchdog
      - delay: 20ms
      - output.turn_off: watchdog

My config:

# AirGradient ONE - Board v9
# https://www.airgradient.com/open-airgradient/instructions/overview/

substitutions:
  name: "ag-one"
  friendly_name: "AG One"
  name_add_mac_suffix: "false"  # Must have quotes around value

# Enable Home Assistant API
api:
  encryption:
    key: !secret api_encryption_key

ota:
  password: !secret ota_password
  platform: esphome

wifi:
  ssid: !secret wifi_ssid
  password: !secret wifi_password

dashboard_import:
  package_import_url: github://MallocArray/airgradient_esphome/airgradient-one.yaml
  import_full_config: false

packages:
  board: github://MallocArray/airgradient_esphome/packages/airgradient_esp32-c3_board.yaml
  pm_2.5: github://MallocArray/airgradient_esphome/packages/sensor_pms5003.yaml
  co2: github://MallocArray/airgradient_esphome/packages/sensor_s8.yaml
  temp_humidity: github://MallocArray/airgradient_esphome/packages/sensor_sht40.yaml
  tvoc: github://MallocArray/airgradient_esphome/packages/sensor_sgp41.yaml
  display: github://MallocArray/airgradient_esphome/packages/display_sh1106_multi_page.yaml
  led: github://MallocArray/airgradient_esphome/packages/led.yaml
  led_co2: github://MallocArray/airgradient_esphome/packages/led_co2.yaml
  airgradient_api: github://MallocArray/airgradient_esphome/packages/airgradient_api_esp32-c3.yaml
  // hardware_watchdog: github://MallocArray/airgradient_esphome/packages/watchdog.yaml
  config_button: github://MallocArray/airgradient_esphome/packages/config_button.yaml
  wifi: github://MallocArray/airgradient_esphome/packages/sensor_wifi.yaml
  uptime: github://MallocArray/airgradient_esphome/packages/sensor_uptime.yaml

binary_sensor:
  - id: !extend config_button
    pin:
      ignore_strapping_warning: true  # Acknowledging that this is a strapping pin and should not have external pullup/down resistors  https://esphome.io/guides/faq.html#why-am-i-getting-a-warning-about-strapping-pins
jeroenleenarts commented 3 weeks ago

As you can see. I commented the 'hardware_watchdog' package, but that didn't help.

MallocArray commented 3 weeks ago

There was something in the change log about separating out the watchdog component so it wasn't linked only to the http_request component. I'll take a look at what needs to be done.

def1149 commented 3 weeks ago

I experienced the same issue. It looks like the ID watchdog is now taken by some other ESPHome code Maybe you just need to rename your ID to a1_watchdog

MallocArray commented 3 weeks ago

As you can see. I commented the 'hardware_watchdog' package, but that didn't help.

I'm surprised that commenting out the watchdog package didn't resolve it.

MallocArray commented 3 weeks ago

I experienced the same issue. It looks like the ID watchdog is now taken by some other ESPHome code Maybe you just need to rename your ID to a1_watchdog

I just updated watchdog.yaml to the following which is letting me get past the previous hurdle. Doing some additional testing before pushing it up to the repo. If you wanted to also test, you could comment out the watchdog.yaml line and add this at the bottom of your file:

output:
  - platform: gpio
    # Pin to notify external watchdog that activity is present
    id: external_watchdog
    pin:
      number: GPIO2
      ignore_strapping_warning: true  # Acknowledging that this is a strapping pin and should not have external pullup/down resistors  https://esphome.io/guides/faq.html#why-am-i-getting-a-warning-about-strapping-pins

interval:
  - interval: 2.5min
    # Notify watchdog device it is still alive
    then:
      - output.turn_on: external_watchdog
      - delay: 20ms
      - output.turn_off: external_watchdog
MallocArray commented 3 weeks ago

Just pushed an update to the repo. If you have already tried to update today, ESPHome by default keeps a cache of packages for 24 hours, so you may not be able to pull it down until that expires, unless you can delete the config/.esphome/packages/ directory.

jeroenleenarts commented 3 weeks ago

Got EspHome running as an add on. So I will take the 24h wait. 👍

def1149 commented 3 weeks ago

Update Successful. No errors. The new firmware executing and reporting to Home Assistant Thanks

jeroenleenarts commented 3 weeks ago

Fixed