Just show my state on LCD


it is possible to show my sensor switch state from other sensor in HOMEASSISTANT on my LCD?
My LCD is just a ESP-01 (esphome). I want to use like a remote monitor to show state of other sensor hardware. Just want to see ON or OFF.:

esphome config

  sda: 0
  scl: 2

  - platform: lcd_pcf8574
    dimensions: 18x2
    address: 0x27
    lambda: |-
     it.printf ("My State:",id(mysprinkler_1_2).state);  // Wrong format here i guess
    platform: homeassistant
    id: mysprinkler_1_2
    entity_id: switch.mysprinkler_1_2

Thank for help.

Assuming nothing else is wrong in your setup and you can successfully print static text, I’d do something like:

    lambda: |-
      it.printf("My State: %s", id(mysprinkler_1_2).state ? "on" : "off");

I believe the state of a binary sensor in ESPHome is true or false, not text like on or off.

Thank for fast reply. Resolved. Nice. Also, I had made another mistake. I did not configure my new integration despite the notification. That’s why I always had NANs on my requests.