Display Motion Sensor Information

I have an ESP-32 hooked up to a bunch of sensors as well as an ILI9341 2.8 screen on which I am displaying data from my sensors.

One of the sensors is a PIR to let me know if there is any motion. It shows motion activation in the logs so it is working.

What I would like to do is display a mdi motion icon on my screen, or at least say CLEAR if no motion is detected (icon prefered).
I am at a loss on how to write it in EspHome so that it is siplayed on the screen.
Can anyone point me in the right direction.
Thanks

You can try something like this:

binary_sensor:
  - platform: ...
    id: motion
    ...

display:
  - platform: ...
    ...
    lambda: |-
      if (id(motion).state) {
        it.fill(COLOR_OFF);
        it.print(0, 0, id(font1), TextAlign::TOP_CENTER, "MOTION");
      } else {
        it.fill(COLOR_OFF);
        it.print(0, 0, id(font1), TextAlign::TOP_CENTER, "CLEAR");
      }
1 Like

Thank you I will give t a try

to make use of images instead the yaml could be something like this:

image:
  - file: "my_mdi_image.png"
    id: my_mdi_image
    resize: 64x64
  - file: "my_other_mdi_image.png"
    id: my_other_mdi_image
    resize: 64x64


display:
  - platform: ...
    ...
    lambda: |-
      if (id(motion).state) {
        it.image(0, 0, id(my_mdi_image));
      } else {
        it.image(0, 0, id(my_other_mdi_image));
      }

See Display Component # Images

1 Like

Thanks for the answer, I now have time to tinker with this, but I can not seem to make it work as written.

In the lambda of

      if (id(motion).state) {
        it.fill(COLOR_OFF);
        it.print(0, 0, id(font1), TextAlign::TOP_CENTER, "MOTION");
      } else {
        it.fill(COLOR_OFF);
        it.print(0, 0, id(font1), TextAlign::TOP_CENTER, "CLEAR");
      }

what triggers the motion. In otherwords what tells it if there is MOTION or it is CLEAR.

Does an β€œon” or β€œoff” or state change have to be added.

Thanks for the input