Python error reloading configuration

Hi newbe here.

I am getting a python error when trying to reload my configuration.yaml file. I have no idea what is in that file that is causing it to throw that error.

  • [547927401664] ‘<’ not supported between instances of ‘str’ and ‘NoneType’
  • [547920703296] ‘<’ not supported between instances of ‘str’ and ‘NoneType’

I can post the file if needed. But its probably something I did that was stupid.

A little progress
If I remove the sensor section then it loads.

I tried adding one back in and it triggers the error.

Welcome to the forums, andersonas25!
Please post your code.

I restored a backup and got to a point where the error no longer occurs. But I have not put the entire confguration.yaml back. This is the file that was failing.

homeassistant:
  name: Home
  latitude: 38.9
  longitude: -104.72
  unit_system: us_customary
  time_zone: America/Denver
# Loads default set of integrations. Do not remove.

default_config:
# Load frontend themes from the themes folder
frontend:
  themes: !include_dir_merge_named themes

automation: !include automations.yaml
script: !include scripts.yaml
scene: !include scenes.yaml
template:
  - sensor:
      - name: "Envoy Total Lifetime Production"
        unit_of_measurement: "MWh"
        device_class: energy
        unique_id: 10000
        state: >
          {{ [ states('sensor.envoy_121736108162_lifetime_energy_production'),
               states('input_number.old_envoy_lifetime_production') ]
               | map('float') | sum }}
        availability: >
          {{ not 'unavailable' in
             [ states('sensor.envoy_121736108162_lifetime_energy_production'),
               states('input_number.old_envoy_lifetime_production') ] }}
  - sensor:
        name: Solar Power Corrected
        state_class: measurement
        icon: mdi:solar-panel
        unit_of_measurement: W
        device_class: power
        unique_id: 10001
        state: >
            {% set value = states('sensor.energy_production') | int %}
            {% if is_state('sun.sun','below_horizon') %}
              0
             {%- else -%}
              {{ value }}
            {% endif %}
  - sensor:
        name: Grid Import Power
        state_class: measurement
        icon: mdi:transmission-tower
        unit_of_measurement: W
        device_class: power
        unique_id: 10002
        state: >
            {{ [0, states('sensor.energy_usage') | int - states('sensor.solar_power_corrected') | int ] | max }}
  - sensor:
        name: Grid Export Power
        state_class: measurement
        icon: mdi:transmission-tower
        unit_of_measurement: W
        device_class: power
        unique_id: 10003
        state: >
            {{ [0, states('sensor.solar_power_corrected') | int - states('sensor.energy_usage') | int ] | max }}
  - sensor:
        name: Grid Seven Days Import Power
        state_class: measurement
        icon: mdi:transmission-tower
        unit_of_measurement: kW
        device_class: power
        unique_id: 10004
        state: >
            {{ [0, states('sensor.envoy_121736108162_energy_consumption_last_seven_days') | int - states('sensor.envoy_121736108162_energy_production_last_seven_days') | int ] | max }}
  - sensor:
        name: Grid Seven Days Export Power
        state_class: measurement
        icon: mdi:transmission-tower
        unit_of_measurement: kW
        device_class: power
        unique_id: 10005
        state: >
            {{ [0, states('sensor.envoy_121736108162_energy_production_last_seven_days') | int - states('sensor.envoy_121736108162_energy_consumption_last_seven_days') | int ] | max }}
  - sensor:
        name: Grid Today Import Power
        state_class: measurement
        icon: mdi:transmission-tower
        unit_of_measurement: kW
        device_class: power
        unique_id: 10006
        state: >
            {{ [0, states('sensor.envoy_121736108162_energy_consumption_today') | int - states('sensor.envoy_121736108162_energy_production_today') | int ] | max }}
  - sensor:
        name: Grid Today Export Power
        state_class: measurement
        icon: mdi:transmission-tower
        unit_of_measurement: kW
        device_class: power
        unique_id: 10007
        state: >
            {{ [0, states('sensor.envoy_121736108162_energy_production_today') | int - states('sensor.envoy_121736108162_energy_consumption_today') | int ] | max }}
sensor:
 - platform: integration
    name: Grid Import Energy
    source: sensor.grid_import_power
    unit_prefix: k
    unit_time: h
    method: left
  - platform: integration
    name: Grid Export Energy
    source: sensor.grid_export_power
    unit_prefix: k
    unit_time: h
    method: left
  - platform: integration
    name: Solar Energy Corrected
    source: sensor.solar_power_corrected
    unit_prefix: k
    unit_time: h
    method: left
  - platform: integration
    name: Grid Seven Days Import Power
    source: sensor.grid_seven_days_import_power
    unit_prefix: k
    unit_time: h
    method: left
  - platform: integration
    name: Grid Seven Days Export Power
    source: sensor.grid_seven_days_export_power
    unit_prefix: k
    unit_time: h
    method: left
  - platform: integration
    name: Today Export Power
    source: sensor.grid_today_export_power
    unit_prefix: k
    unit_time: h
    method: left
my:

During reload the sensors have no value, it’s ‘None’. Assign a default value, this would be in relation to the first sensor e.g.


          {{ [ states('sensor.envoy_121736108162_lifetime_energy_production'),
               states('input_number.old_envoy_lifetime_production') ]
               | map('float', 'unavailable')
               | select('is_number')
               | sum }}

and to all |int e.g. |int(0)

Thanks

I made those changes.