Invalid conversion from 'esphome::homeassistant::HomeassistantSensor*' to 'uint8_t

Hi folks!
I’m trying to pass an input number to a lambda function but I got this error:

invalid conversion from

esphome::homeassistant::HomeassistantSensor*' to 'uint8_t {aka unsigned char}' [-fpermissive]
         it.intensity(mynumber);

My code is the following:

esphome:
  name: max7219_test
  platform: ESP8266
  board: d1_mini

wifi:
  ssid: !secret ssid
  password: !secret password

  # Enable fallback hotspot (captive portal) in case wifi connection fails
  ap:
    ssid: "Max7219 Test Fallback Hotspot"
    password: "1ObNXsEs5d8I"

captive_portal:

# Enable logging
logger:

# Enable Home Assistant API
api:

ota:

text_sensor:
  - platform: wifi_info
    ip_address:
      name: ESP IP Address
      icon: mdi:wifi
    ssid:
      name: ESP Connected SSID
      icon: mdi:wifi
    bssid:
      name: ESP Connected BSSID
      icon: mdi:wifi
    mac_address:
      name: ESP Mac Wifi Address
      icon: mdi:chip
  - platform: homeassistant
    id: mytext
    name: mytext
    entity_id: input_text.max7219
    internal: true
  - platform: homeassistant
    name: "Today Weather Icon"
    entity_id: weather.home
    id: weather_icon
    internal: true    
    
sensor:
  - platform: wifi_signal
    name: "WiFi Signal"
    icon: mdi:wifi
    update_interval: 60s
  - platform: homeassistant
    id: mynumber
    name: mynumber
    entity_id: input_number.max7219_intensity
    internal: true    
    
font:
  - file: "thintel.ttf"
    id: digit_font
    size: 16

spi:
  clk_pin: D5
  mosi_pin: D7

display:
  - platform: max7219digit
    id: my_display
    cs_pin: D6
    num_chips: 4
    intensity: 1
    rotate_chip: 180
    reverse_enable: true
    lambda: |-
        it.intensity(mynumber);
        it.scroll(true, 0, 100, 1000, 1000);
        it.print(it.get_width()/2, 11, id(digit_font), TextAlign::BOTTOM_CENTER, id(mytext).state.c_str());

Where I’m wrong?

Try:

it.intensity(id(mynumber).state);
3 Likes

yes, it is! many thanks!