SmartHome-yourself / m5-dial-for-esphome

M5 Stack Dial - Custom Component for ESPHome
MIT License
56 stars 8 forks source link

LD2410 and main page support #21

Open ZeniaBol opened 2 months ago

ZeniaBol commented 2 months ago

Hi, Daniel Thank you so much for this great project. I install your project in 15 minutes without any problem. 3 questions: 1) Is it possible to make a climate card looks like a HA card? 2) I try to add LD2410 sensor for backlight to turn ON when some one close to M5 dial( around 2 feet or so) but don't know how. @dgaust add this to his code: https://github.com/dgaust/esphome_files.

uart:
  tx_pin: GPIO2
  rx_pin: GPIO1
  baud_rate: 256000
  parity: NONE
  stop_bits: 1

ld2410:

spi:
  mosi_pin: GPIO6
  clk_pin: GPIO5

number:

  - platform: ld2410
    timeout:
      name: timeout
    light_threshold:
      name: light threshold
    max_move_distance_gate:
      name: max move distance gate
    max_still_distance_gate:
      name: max still distance gate
    g0:
      move_threshold:
        name: g0 move threshold
      still_threshold:
        name: g0 still threshold
    g1:
      move_threshold:
        name: g1 move threshold
      still_threshold:
        name: g1 still threshold
    g2:
      move_threshold:
        name: g2 move threshold
      still_threshold:
        name: g2 still threshold
    g3:
      move_threshold:
        name: g3 move threshold
      still_threshold:
        name: g3 still threshold
    g4:
      move_threshold:
        name: g4 move threshold
      still_threshold:
        name: g4 still threshold
    g5:
      move_threshold:
        name: g5 move threshold
      still_threshold:
        name: g5 still threshold
    g6:
      move_threshold:
        name: g6 move threshold
      still_threshold:
        name: g6 still threshold
    g7:
      move_threshold:
        name: g7 move threshold
      still_threshold:
        name: g7 still threshold
    g8:
      move_threshold:
        name: g8 move threshold
      still_threshold:
        name: g8 still threshold

binary_sensor:
  - platform: ld2410
    has_target:
      name: Presence
    has_moving_target:
      name: Moving Target
    has_still_target:
      name: Still Target

sensor:
  - platform: ld2410
    detection_distance:
      name: Detection Distance
      id: ddistance
      filters:
        - throttle: 0.5s
      on_value: 
        then:
          if:
            condition:
              - lambda: 'return id(ddistance).state < 150;'  
            then:
              if:
                condition:
                  - light.is_off: backlight
                then:              
                  - light.turn_on: backlight
            else:
              - light.turn_off: 
                  id: backlight
                  transition_length: 1s     
    light:
      name: light
    moving_distance:
      name : Moving Distance
    still_distance:
      name: Still Distance
    moving_energy:
      name: Move Energy
    still_energy:
      name: Still Energy
    g0:
        move_energy:
          name: g0 move energy
        still_energy:
          name: g0 still energy
    g1:
      move_energy:
        name: g1 move energy
      still_energy:
        name: g1 still energy
    g2:
      move_energy:
        name: g2 move energy
      still_energy:
        name: g2 still energy
    g3:
      move_energy:
        name: g3 move energy
      still_energy:
        name: g3 still energy
    g4:
      move_energy:
        name: g4 move energy
      still_energy:
        name: g4 still energy
    g5:
      move_energy:
        name: g5 move energy
      still_energy:
        name: g5 still energy
    g6:
      move_energy:
        name: g6 move energy
      still_energy:
        name: g6 still energy
    g7:
      move_energy:
        name: g7 move energy
      still_energy:
        name: g7 still energy
    g8:
      move_energy:
        name: g8 move energy
      still_energy:
        name: g8 still energy

text_sensor:
   - platform: ld2410
    version:
      name: "firmware version"
    mac_address:
      name: "mac address"
switch:
  - platform: ld2410
    engineering_mode:
      name: "engineering mode"
    bluetooth:
      name: "control bluetooth"
light:
  - platform: monochromatic
    id: backlight
    name: "Backlight"
    output: oledbacklight
    default_transition_length: 250ms

output:
  - id: oledbacklight
    platform: ledc
    pin: GPIO9
    max_power: 1
    min_power: 0

using B-plug on the back of the M5 dail. 3) Any plans to add main page with icons for shortcuts to pages of the devices. Thank you again. You are ROCK. Screenshot 2024-04-23 175749

danielscheidler commented 2 months ago

Hi, first of all, the layout will be optimized, after add all devicetypes. But I've done a bit in this direction. (comming soon in dev) image

I think the backlight problem is, because the integration set the brightness it self and "overwrite" your feature. But I can think about, how to get the backlight customizable.

My idea was not a shortcut page as "homepage" but a menu where you can get in with long button press from everywhere to fast-select the device and perhaps handle some settings like beep and so on.

The only other way at the moment is a service "selectdevice", where you can set current device on the dial with a home assistant service call. (will be renamed to select_device in future release)

service: esphome.m5_dial_dev_selectdevice
data:
  entity_id: light.nanoleaf
ZeniaBol commented 2 months ago

Great. Thank you again for your hard work. Ld2410 is at your to do list? I try but no luck yet ( not much experience with coding).

danielscheidler commented 2 months ago

not the ld2410, but the ability to control the backlight. local sensors and other stuff on the gpios you can use as usual https://esphome.io/components/sensor/ld2410.html

ZeniaBol commented 2 months ago

I know what and how ld2410 works. And actually still :-) this idea from the other M5 dial developer. But can't figure it out how to add to your code. I think it will be great if display will come on when you come close. https://community.home-assistant.io/t/m5stack-dial-esp32-s3-smart-rotary-knob/623518/158. Thank you

ZeniaBol commented 2 months ago

Daniel, I installed a DEV code and it's work GREAT. Thank you. Is it possible to change an icons? I want to change blinds to mdi: curtains and heater to hvac. I try to do this like it's explained on Esphome page but no luck. Example: sensor:

danielscheidler commented 2 months ago

No, the icons are hardcoded atm. in https://github.com/SmartHome-yourself/m5-dial-for-esphome/blob/main/components/shys_m5_dial/global_image_data.h

The graphics already take up too much space, so I'm reluctant to expand the list at the moment. But since you're definitely not the only one who would like to define your own icons, I'll definitely come back to the topic sooner or later.

ZeniaBol commented 2 months ago

Thank you again. Excellent job. If you need someone to test something ( not code wise, not good in coding), just let me know. 9f47e422-9012-4cae-ae2c-15eb1a5ff937 780734bc-110f-4d11-a838-40c5d1c80537