● ha작업) LVGL구성 Display 날짜와 요일 표시 조건




컨텐츠 정보


본문

● ha작업) LVGL구성 Display  날짜와 요일 표시 조건

3232235521_1726945424.6883.png

script:
# Time update  
  - id: date_update        # 날짜 업데이트 스크립트
    then:
      - lvgl.label.update:
          id: title_date
          text: !lambda |-
            static char date_buf[50];  // 한글 처리를 위한 버퍼 크기 증가
            auto now = id(time_comp).now();
            const char* weekdays[] = {"월", "화", "수", "목", "금", "토", "일"};  // 월요일부터 시작
            snprintf(date_buf, sizeof(date_buf), "%04d-%02d-%02d(%s)", now.year, now.month, now.day_of_month, weekdays[now.day_of_week]);
            // snprintf(date_buf, sizeof(date_buf), "%04d-%02d-%02d", now.year, now.month, now.day_of_month);
            return date_buf;

 
      - lvgl.label.update:
          id: main_bar_time1
          text: !lambda |-
            static char time_buf[20];
            auto now = id(time_comp).now();
            snprintf(time_buf, sizeof(time_buf), "%02d:%02d:%02d", now.hour, now.minute, now.second);
            return time_buf;


조건 > '*' 로 하면 초단위로 변함

time:
  - platform: homeassistant
    id: time_comp
    on_time_sync:         #시간 동기화가 되면
      - script.execute: time_update         # 시간 업데이트 스크립트 실행
      - script.execute: date_update         # 날짜 업데이트 스크립트 실행
    on_time:              # 시간이 변하면
      - minutes: '*'      # 매분
        seconds: '*'      # '*' 로 하면 초단위로 변함, 단 Label을 초단위 표기로 변경해야 함 초시간 초시계 동작
        then:
          - script.execute: time_update     # 시간 업데이트 스크립트 실행
          - script.execute: date_update    # 날짜 업데이트 스크립트 실행



폰트 적용은 필수 조건입니다


표시 > 

          widgets:
            - label:                
                text: "오전00:00"
                id: title_time
                align: TOP_LEFT
                text_font: font_26 # ID: font_26
                text_color: 0x0000FF
                x: -5
                y: -5
                text_align: CENTER

 
            - label:
                text: "2000-00-00(일)"
                text_color: 0xFFFFFF   # 색상 코드 수정 (6자리로 변경)
                id: title_date
                align: BOTTOM_RIGHT
                text_font: title_font  # ID: font_20
                x: -30
                y: 5
                text_align: CENTER


☞ https://11q.kr 에 등록된 자료 입니다. ♠ 정보찾아 공유 드리며 출처는 링크 참조 바랍니다♠1.png

뷰PDF add1,add2



관련자료

댓글 0
등록된 댓글이 없습니다.



♥간단_메모글♥


최근글


새댓글



PHP 안에 HTML ☞ 홈페이지 화면갱신 시간은 ♨
▶ 2024-09-22 08:41:25

오늘의 홈 현황


  • 현재 접속자♨ 414(1) 명
  • 오늘 가입자※ 0 명
  • 어제 가입자※ 1 명
  • 주간 가입자※ 13 명
  • 오늘 방문자 1,717 명
  • 어제 방문자 3,088 명
  • 최대 방문자 13,042 명
  • 전체 방문자 4,576,686 명
  • 전체 게시물※ 8,799 개
  • 전체 댓글수※ 25,106 개
  • 전체 회원수 11,246 명

QR코드


☞ QR코드 스캔은 kakao앱 자체 QR코드

알림 0








최신글↑