Skip to content

About

Home Assistant app for Korea's DH Lottery (Lotto 6/45): auto purchase, winning results, statistics and sensors.

Topics

Resources

Stars

4 stars

Watchers

0 watching

Forks

Repository files navigation

DH Lottery Home Assistant Add-on

Home Assistant에 앱 저장소 추가

Unit Tests License GitHub stars

Home Assistant에서 동행복권 로또 6/45를 자동으로 구매하고 분석할 수 있는 애드온입니다. 실시간 당첨 결과, 통계 분석(Hot/Cold), 예치금 관리, MQTT Discovery, REST API를 한 번에 제공합니다.


실제 사용 화면

🎰 로또 6/45 당첨번호 & 구매 내역
로또 6/45 당첨번호 및 구매 내역
💰 예치금 · 원클릭 구매 · 연금복권
예치금 및 구매 버튼, 연금복권 당첨번호
✍️ 연금 구매내역 · 수동구매 · 랜덤생성
연금복권 구매내역 및 수동구매, 랜덤 번호 생성기

주요 기능

  • ✅ 자동 구매: 번호 랜덤 자동 구매 (1게임 / 5게임)
  • ✅ 수동 구매: 번호 수동 입력 + 자동 혼합 (예: 1,2,3,auto,auto,auto)
  • ✅ 가족용 다중 계정 지원: 최대 4개 계정까지 지원 (계정 간 20초 보안 간격 적용)
  • ✅ 주간 구매 한도 보호: 1계정당 주간 최대 5게임(5,000원) 강제 제한
  • ✅ 실시간 분석: 당첨번호·상금·통계 자동 업데이트
  • ✅ 자동화 연동: HA 자동화 트리거/액션 지원
  • ✅ 통계 분석: Hot / Cold 번호, 출현 빈도
  • ✅ 예치금 관리: 잔액 및 구매 가능 금액 모니터링
  • ✅ MQTT Discovery: HA 자동 통합
  • ✅ REST API: 외부 시스템 연동 + Swagger UI
  • ✅ 모바일 알림: 구매 완료, 당첨번호 발표 알림
  • ✅ 사이드바 대시보드 (v2.5.0~): 구매 내역 조회 + 구매 버튼, 테마 12종·개인화 설정 (v2.6.0)
  • ✅ 아이디 비공개: 웹 UI·API·애드온 로그에는 실제 아이디 대신 Account_1, Account_2 로 표시
  • ✅ 럭키 랩 (v2.12.0): 운 지수(확률상 상위 몇 %), 당첨금 수령 기한 도우미, 계정별 월 예산 가드(⏰ 자동 구매 카드), 주간 리포트·토요일 마감 알림, 번호 공정성 검정, 캘린더(.ics) 내보내기

목차


설치

저장소 추가

  1. Home Assistant → Settings → Add-ons → Add-on Store
  2. 우측 상단 메뉴(⋮) → Repositories
  3. 다음 URL 추가:
    https://github.com/redchupa/ha-app-dhlottery
    

애드온 설치

  1. Add-on Store에서 LotTo 선택 (예전 이름: DH Lotto 45)
  2. Install 클릭
  3. Configuration 탭에서 설정 (최대 4개 계정까지 등록 가능):
accounts:
  - username: "my_account_1"   # 동행복권 아이디
    password: "my_password_1"  # 동행복권 비밀번호
    enabled: true
  # 가족 구성원 추가 시 (최대 4계정까지만 로드됨)
  # - username: "family_account_2"
  #   password: "family_password_2"
  #   enabled: true
mqtt_url: "mqtt://core-mosquitto:1883"   # Mosquitto broker 애드온이면 그대로
mqtt_username: ""                        # 비워 두면 Mosquitto broker 접속 정보 자동 사용(권장)
mqtt_password: ""

로또6/45·연금복권720+·MQTT 는 항상 켜져 있고, 센서 갱신 주기는 1시간(3600초)으로 고정입니다.

MQTT 준비 (Mosquitto broker)

이 애드온은 MQTT Discovery 로 센서·버튼을 만들기 때문에 MQTT 브로커가 꼭 필요합니다.

  1. Mosquitto broker 설치: 설정 → 애드온(앱) → 애드온 스토어 → Mosquitto broker 설치 → 시작.
  2. MQTT 통합 추가: 설정 → 기기 및 서비스에 MQTT 가 발견되면 구성 → 확인. (안 보이면 통합 추가 → MQTT)
  3. 이 애드온 MQTT 칸
    • Mosquitto broker 애드온을 쓰면(대부분): mqtt_username·mqtt_password 를 비워 두세요. 사용자 계정을 따로 만들 필요가 없습니다. 애드온이 services: mqtt 로 등록돼 있어서, Supervisor 가 Mosquitto 에서 이 애드온 전용 MQTT 계정을 자동으로 발급해 연결합니다(Zigbee2MQTT 등 다른 애드온과 같은 방식). 로그에 MQTT: mqtt://core-mosquitto:1883 (auto (Mosquitto broker), user: set) 과 MQTT connected 가 보이면 정상입니다.
    • 직접 입력이 필요한 경우(다른 기기의 브로커, 또는 특정 계정을 쓰고 싶을 때): 먼저 계정을 만든 뒤 입력합니다. 둘 중 하나:
      • 설정 → 사람 → 사용자 추가 → 이름 예: mqtt_dhlotto, 비밀번호 지정 (로그인 허용은 꺼도 됨)
      • Mosquitto broker 애드온 → 구성 → logins 에 추가:
        logins:
          - username: mqtt_dhlotto
            password: your_mqtt_password
      그 다음 이 애드온에 mqtt_username: mqtt_dhlotto, mqtt_password: your_mqtt_password 입력.
    • 다른 기기의 브로커: mqtt_url: "mqtt://브로커주소:1883" (예: mqtt://mqtt.example.local:1883) + 그 브로커의 아이디·비밀번호.
  4. 애드온 재시작 → 로그에서 MQTT connected 확인.

연결이 안 되면? 애드온 로그에 이유가 나옵니다 — MQTT 인증 거부·아이디 또는 비밀번호가 틀림 이면 MQTT 칸을 비우거나 계정을 확인하고, 브로커를 사용할 수 없음 이면 Mosquitto broker 가 실행 중인지 확인하세요. 대시보드 상단에도 안내가 뜹니다. HA 재부팅 때 브로커가 늦게 켜져도 애드온이 계속 재시도해 연결되는 순간 센서·버튼을 자동으로 다시 만듭니다(v2.11.1).

  1. Start 클릭 → Log 탭에서 Login successful 확인

사이드바 대시보드

v2.5.0 부터 애드온의 웹 UI 가 대시보드로 바뀌었습니다. 구매한 복권 조회와 구매를 한 화면에서 할 수 있습니다.

사이드바에 표시하기: 설정 → 애드온(앱) → LotTo → 사이드바에 표시 켜기. 왼쪽 메뉴에 LotTo 가 생깁니다.

카드 내용
계정 요약 예치금, 구매 가능 금액, 로그인·동기화 상태
구매하기 로또 자동 1·5게임, 수동 1게임 / 연금복권 자동 1·5매, 수동 1매 (구매 전 확인 창)
로또 이번·지난 회차 구매 번호와 결과, 지난 회차 당첨번호
연금복권 이번·지난 회차 구매한 조·번호와 결과, 당첨 요약
최신 당첨번호 로또 6/45, 연금복권720+
  • 계정은 실제 아이디 대신 Account_1, Account_2 … (애드온 설정 순서)로 표시됩니다.
  • 구매 버튼에도 기존 보호 장치(주간 5게임, 연금 1일 한도, 계정 간 20초 간격, 15초 중복 방지)가 그대로 적용됩니다.
  • 로또 구매 불가 시간(토 20:00 ~ 일 06:00)에는 로또 버튼이 잠깁니다.

테마 · 개인화 (v2.6.0)

상단 테마 버튼(⚙️ 설정) 에서 화면을 꾸밀 수 있고, 설정은 HA에 저장돼 모든 기기에 똑같이 적용됩니다.

그룹 테마
기본 시스템 자동 · 라이트 · 다크 · HA 블루
행운 잭팟 골드 · 네잎클로버 · 복주머니 · 황금돼지 · 로또볼 팝
밤하늘 · 미래 네온 추첨기 · 오로라 · 은하수 소원
  • 행운 배너: 오늘의 행운 문구, 로또·연금 다음 추첨 카운트다운, 최신 당첨번호, 지난 회차 1등 당첨금
  • 🍀 행운 번호 뽑기: 수동 번호 칸을 무작위 번호로 채움 (구매는 확인 창을 거쳐야 진행)
  • 당첨 축하: 지난 회차 당첨 티켓이 있으면 금색 배너와 꽃가루, 1등이면 잭팟 배너
  • 설정 항목: 언어(한국어/English), 간격, 로또볼 모양(입체/평면), 애니메이션, 행운 배너, 나만의 행운 문구, 기본 계정, 카드 표시·순서

즐겨찾기 · 통계 · 자동 구매 · 알림 (v2.7.0)

카드 내용
⭐ 즐겨찾기 번호 자주 사는 로또 번호(반자동 auto 가능)·연금 조+번호를 최대 10개 저장, 버튼 하나로 구매(확인 창 거침)
📊 지출 · 당첨 통계 최근 12개월 월별 구매액·당첨금 막대그래프, 합계·회수율, 최근 당첨. 전체/계정별 전환
⏰ 자동 구매 · 알림 정기 자동 구매 일정, 알림 설정, 테스트 알림, 진단 리포트 복사
  • 번호 뽑기 옵션: 완전 무작위 / 자주 나온 번호 위주 / 덜 나온 번호 위주 / 섞기, 홀짝 균형·합계 100~175·3연속 제외 필터. 어떤 방식이든 당첨 확률은 같습니다(재미용).
  • 통계 기준: 애드온이 확인한 구매·당첨 기록입니다(/data/ledger.json). 다른 곳에서 산 복권도 동기화되면 포함되며, 설치 이전 기록은 없습니다.

정기 자동 구매

요일·시각(KST)·계정(전체 또는 하나)·종류(로또 자동 1/5게임, 연금 자동 1/5매)를 정해 두면 그 시각에 구매합니다. 켤 때 확인 창을 거치며, 아래 보호 장치가 항상 적용됩니다.

  • 일정마다 하루 1번, 예약 시각부터 10분 안에만 실행 (애드온이 늦게 켜져도 몰아서 사지 않음, 실행 기록을 먼저 남겨 재시작돼도 중복 없음)
  • 실행 직전 점검: 로그인 상태, 로또 판매 시간, 예치금(구매 가능 금액) 부족 시 건너뜀, 다른 구매 진행 중이면 건너뜀
  • 기존 한도 그대로: 로또 주간 5게임(5게임 자동은 그 주 미구매 시만), 연금 하루 한도, 계정 간 20초 간격, 15초 중복 방지
  • 여러 계정은 순서대로 25초 간격, 결과는 알림·이벤트로 남음

알림과 자동화 이벤트

  • HA 알림(종 모양) 기본 켜짐, 모바일 알림 서비스(예: notify.mobile_app_내폰)를 넣으면 휴대폰으로도 받습니다. 테스트 알림 버튼으로 확인하세요.
  • 알림 종류: 당첨(1등은 잭팟 알림), 구매 결과(대시보드·버튼·정기 구매 모두), 예치금 부족(기준 금액 미만, 계정별 하루 1회)
  • 자동화용 HA 이벤트(계정은 Account_N 으로만 표시):
이벤트 데이터
dhlotto45_purchase account, action, label, status(success/error/skipped), message, source(dashboard/button/schedule)
dhlotto45_win account, game(lotto/pension), round, result, amount
dhlotto45_low_deposit account, balance, threshold
dhlotto45_weekly_report title (일요일 주간 리포트를 보낼 때)

🛡️ 동행복권 서버와 계정 보호 (v2.14.0)

이 애드온은 동행복권 사이트를 평범한 웹 사용자처럼 이용하도록 만들어져 있습니다.

  • 조회는 1시간에 한 번(+무작위 0~2분)만, 구매 불가 시간에는 거의 하지 않습니다. 추첨이 끝난 회차 정보는 한 번만 가져옵니다.
  • 요청은 실제 크롬 브라우저와 같은 형태(첫 화면 → 로그인 화면 → 로그인, 화면 안 데이터 요청)로 보냅니다.
  • 로그인 보호: 로그인 시도 사이 최소 90초, 한 시간 최대 6번. 비밀번호가 틀리면 30분 → 2시간 쉬고, 3번 이어지면 자동 로그인을 멈춰 동행복권 계정이 잠기지 않게 합니다. 애드온 구성에서 비밀번호를 고치거나 대시보드의 다시 로그인을 누르면 다시 시도합니다.
  • 사이트가 점검 중이면 1분 → 2분 → … 최대 1시간 간격으로 천천히 다시 시도합니다.
  • 접속은 항상 인증서를 검증한 보안 연결로만 합니다(가짜 사이트에 아이디·비밀번호를 보내지 않음).

⚙️ 설정 (v2.18.1)

대시보드 오른쪽 위 ⚙️ 설정 버튼 하나에 화면 관련 설정이 모여 있습니다.

  • ↻ 새로고침: 최신 정보를 다시 불러옵니다.
  • 계정 이름: 계정마다 ✏️ 이름 바꾸기(아래 참고).
  • 테마·언어·표시: 테마 13종, 한국어/English, 간격·로또볼 모양, 축하 애니메이션.
  • 상단 배너 문구: 배너 제목("오늘도 1등을 향해 🏆" 자리, 최대 30자)과 한 줄 문구(최대 40자)를 직접 바꿀 수 있습니다. 비우면 기본 문구가 나옵니다.
  • 기본 계정·카드 구성: 처음 열 계정, 카드 순서와 보이기/숨기기.
  • 맨 아래에 앱 버전이 작게 표시됩니다(문제 신고할 때 확인용).

✏️ 계정 이름 바꾸기 (v2.16.0)

대시보드는 실제 아이디를 숨기려고 계정을 Account_1, Account_2로 보여 줍니다. ⚙️ 설정 → 계정 이름에서 계정마다 ✏️ 이름 바꾸기를 누르면 "아빠", "엄마"처럼 알아보기 쉬운 이름(최대 12자)으로 바꿀 수 있습니다. 대시보드·알림·HA 캘린더에 그 이름이 쓰이고, 비우고 저장하면 원래대로 돌아갑니다.

  • 실제 동행복권 아이디는 이름으로 쓸 수 없습니다.
  • 자동화에 쓰는 HA 이벤트의 account 값과 로그·진단 정보는 계속 Account_N이라 기존 자동화에 영향이 없습니다(새 이름은 이벤트의 name 필드에).

🔁 재시작해도 안전하게 (v2.15.0)

홈어시스턴트나 애드온이 언제 재시작되거나 전원이 나가도 기록과 동작이 이어지도록 만들어져 있습니다.

  • 알림을 잃지 않음: HA 가 재시작 중이라 받지 못한 당첨·구매 알림과 이벤트는 보관했다가 HA 가 돌아오면 보냅니다(24시간까지).
  • 두 번 사지 않고, 놓치지도 않음: 정기 자동 구매는 실행 전에 먼저 기록해 재시작해도 같은 날 두 번 사지 않습니다. 재부팅이 예약 시각과 겹치면 로그인이 끝날 때까지(최대 10분 창 안에서) 기다렸다가 삽니다.
  • 기록 보호: 구매 원장·설정은 쓰는 도중 꺼져도 깨지지 않게 저장하고, 혹시 깨지면 직전 백업으로 자동 복구합니다.
  • 화면은 바로: 재시작 직후에도 대시보드와 HA 센서는 지난 값으로 바로 보이고, 로그인이 끝나면 최신 값으로 바뀝니다.

🧠 럭키 랩 (v2.12.0)

대시보드의 🧠 럭키 랩 카드(운 지수·당첨금 수령·캘린더)와 ⏰ 자동 구매·알림 카드(월 예산·리포트·마감 알림 설정)에서 씁니다. 모두 애드온이 본 구매·당첨 기록(통계 카드와 같은 원장)으로 계산합니다.

기능 하는 일
🍀 운 지수 산 복권 수로 확률상 기대되는 당첨 횟수와 실제 당첨 횟수를 비교해 상위 몇 % 인지 보여 줍니다(이항분포 정확 계산, 추첨이 끝난 회차만). 지금 구매 속도로 로또 1등을 기대할 수 있는 시점도 함께 보여 줍니다.
💳 월 예산 가드 ⏰ 자동 구매·알림 카드의 💳 이번 달 예산 칸에 금액을 넣고 저장하면, 계정마다 이번 달 지출 + 이번 구매가 그 금액을 넘는 구매를 대시보드·HA 버튼·정기 자동 구매 모두에서 막습니다. 0 이면 꺼짐.
💰 당첨금 수령 도우미 당첨 회차의 지급기한(추첨일로부터 1년, 그날이 은행 휴무일이면 다음 영업일) D-day 와 등수별 수령 방법을 보여 주고, 직접 챙겨야 하는 당첨은 D-30·7·1 에 알립니다. 주말은 자동으로 넘기고, 공휴일과 겹치면 실제 기한이 더 늦어집니다(화면 날짜가 실제보다 늦게 나오는 일은 없음).
📬 주간 리포트 일요일 09시에 계정별 지난 회차 결과·이번 달 지출·운 지수·수령할 당첨을 한 번에 보냅니다(⏰ 알림 설정에서 켜기).
⏰ 마감 알림 토요일 18시에 이번 주 로또를 안 산 계정을 알려 줍니다(토요일 정기 자동 구매가 있는 계정은 제외).
🔬 공정성 검정 번호 통계 카드에 카이제곱 적합도 검정 결과(p 값)를 보여 줍니다. 많이·적게 나온 번호가 우연 범위인지 확인할 수 있습니다.
📅 캘린더 내보내기 휴대폰 캘린더에 로또 판매 마감(2시간 전 알림)·연금 추첨·정기 자동 구매·당첨금 지급기한(30·7·1일 전 알림)을 넣는 .ics 파일입니다. 아래 안내를 보고 필요한지 판단하세요.

인터넷 구매 당첨금 수령 방법 (출처: 동행복권 이용안내, 당첨자 가이드, 미수령 당첨금 안내)

복권 등수·금액 수령 방법
로또 6/45 200만원 이하 (3~5등) 추첨 다음 날(일요일 06시경) 예치금 자동 지급
로또 6/45 200만원 초과 (2~3등) NH농협은행 전국 지점 · 신분증, 당첨 복권 번호
로또 6/45 1등 NH농협은행 본점에서만 · 신분증, 당첨 복권 번호
연금복권720+ 1등·2등·보너스 (연금식) 신분증(실명확인증표)을 챙겨 당첨금 지급처 (주)동행복권 본사 방문·청구 → 청구한 다음 달부터 매월 20일 계좌 지급 (연금복권720+ 안내)
연금복권720+ 3~7등 예치금 자동 지급
  • 지급기한: 지급개시일(추첨일)로부터 1년. 그날이 은행 영업일이 아니면 다음 영업일까지. 지나면 복권기금으로 귀속됩니다.
  • 실제 사례로 확인: 1196회(2025-11-01 추첨) 기한 2026-11-01(일) → 11-02(월), 1203회(2025-12-20 추첨) → 2026-12-21(월).

📅 HA 캘린더에 자동 표시 (추천, v2.13.0)

한 번 연결해 두면 로또 판매 마감·연금 추첨·정기 자동 구매·당첨금 지급기한이 HA 사이드바 캘린더에 나타나고 하루 한 번 자동으로 갱신됩니다(정기 구매를 바꾸거나 새로 당첨되면 바로 갱신). 캘린더 일정으로 자동화도 만들 수 있습니다.

  1. 🧠 럭키 랩 카드 → 🔗 HA 캘린더 연결 방법 을 펼치면 캘린더 URL·사용자 이름·비밀번호가 보입니다(복사 버튼).
  2. HA 설정 → 기기 및 서비스 → 통합 구성요소 추가 → Remote calendar.
  3. 캘린더 이름 LotTo, 캘린더 URL 붙여넣기(HA 내부 주소라 http, SSL 확인은 꺼도 됨).
  4. 사용자 이름·비밀번호를 물으면 붙여넣고 완료. 카드의 상태가 ✅ 연결됨 으로 바뀌면 성공입니다.

이 주소는 HA 내부에서만 쓰며 비밀번호로 보호됩니다. 구글·아이폰 기본 캘린더는 바깥에서 접속할 수 없어 구독할 수 없으니, 휴대폰 기본 캘린더에는 아래 파일 받기를 쓰세요.

📅 캘린더 받기 — 언제 쓰고, 어떻게 쓰나요?

  • 이런 분께 좋아요: HA 알림을 안 쓰거나, 집 밖·HA가 꺼져 있을 때도 휴대폰 자체 알림으로 받고 싶은 분(일정과 알림이 휴대폰에 저장됨) / 가족 공유 캘린더로 마감·지급기한을 같이 보고 싶은 분 / 고액 당첨의 1년 지급기한을 휴대폰 알림으로 확실히 남겨 두고 싶은 분.
  • 안 써도 되는 경우: ⏰ 설정의 마감 알림·수령 기한 알림·주간 리포트를 HA 앱이나 카카오톡으로 이미 받고 있다면 내용이 거의 같습니다.
  • 사용 방법
    1. HA 앱이 아니라 휴대폰·PC의 웹 브라우저(크롬·사파리) 로 HA 주소에 접속해 🧠 럭키 랩 카드의 📅 캘린더 받기 (.ics) 를 누릅니다. HA 앱 안에서는 파일 저장이 안 될 수 있습니다.
    2. 아이폰: 파일 앱에서 dhlotto45.ics → 모두 추가 → 캘린더 선택.
    3. 안드로이드(구글 캘린더): PC에서 calendar.google.com → 설정 → 가져오기 및 내보내기 → 파일 선택 → 가져오기. 휴대폰에 자동으로 나타납니다.
    4. 삼성 캘린더: 내 파일에서 dhlotto45.ics 를 삼성 캘린더로 열어 저장.
  • 알아 두세요: 받은 순간의 내용만 담기고 저절로 갱신되지 않습니다(앞으로 8주). 일정을 바꾸거나 새로 고액 당첨되면 다시 받으세요. 'LotTo' 같은 별도 캘린더에 가져오면 다시 받을 때 비우고 넣기 쉬워 중복이 생기지 않습니다.

알림은 기존 알림 설정(HA 알림 + 추가 알림 서비스)을 그대로 씁니다. kakao-noti 의 notify.* 서비스를 넣으면 카카오톡 나에게 보내기로 받습니다.

새 센서(계정마다): lotto45_luck_index(운 지수 백분위 %), lotto45_month_spend(이번 달 지출, 예산·남은 금액 속성), lotto45_claim_deadline(가장 가까운 직접 수령 기한 D-n).

접기·펼치기 · 휴대폰 화면 (v2.11.0)

  • 카드 제목을 누르면 접고 펼칩니다. 자주 안 쓰는 카드(구매 용지·최신 당첨번호·번호 통계·지출 통계·자동 구매)는 처음에 접혀 있고, 펼친 상태는 모든 기기에 똑같이 저장됩니다.
  • 구매 카드는 자동 구매 버튼만 먼저 보이고, ✍️ 번호 직접 고르기를 누르면 수동·반자동 입력과 번호판이 열립니다.
  • 휴대폰에서 버튼과 입력칸을 크게 했고(아이폰 자동 확대 없음), 화면 아래 빠른 이동 바로 카드 사이를 오갑니다.

번호 통계 · 구매 용지 · 기록 백업 · 모바일 이동 (v2.10.0)

  • 🔢 번호 통계: 1~45 번호판 히트맵으로 최근 50/100회 출현 빈도와 미출현 기간을 보여 줍니다. 많이·적게·오래 안 나온 번호도 함께 표시합니다. 과거 통계일 뿐, 다음 추첨에서 모든 번호의 확률은 같습니다.
  • 🧾 구매 용지: 이번 회차에 산 로또·연금 번호를 복권 용지 모양으로 확인합니다(화면 확인용, 실제 복권 아님).
  • 기록 내보내기·가져오기: 지출·당첨 통계 카드에서 CSV 내보내기(엑셀용), 백업(JSON), 백업 가져오기. 새로 설치하거나 다른 HA 로 옮길 때 기록을 이어 쓸 수 있습니다.
  • 📱 빠른 이동 바: 휴대폰에서 화면 아래 버튼으로 원하는 카드로 바로 이동합니다.

진단 리포트

문제가 생기면 🩺 진단 리포트 복사(자동 구매·알림 카드 또는 ⚙️ 설정)를 눌러 문의 글에 붙여 주세요. 버전·기기·브라우저·계정 상태·최근 로그가 담기며, 아이디는 Account_N, IP·이메일·토큰은 가려집니다.

보안: 대시보드 데이터와 구매는 HA 사이드바(Ingress)로 열었을 때만 동작합니다. HA 로그인을 거친 요청만 통과하고, 포트 60099 로 직접 접속하면 차단됩니다. 구매 요청에는 페이지별 보안 토큰(CSRF)이 필요하며, 다른 사이트에서 사용자의 HA 세션으로 구매를 시도할 수 없도록 CORS 자격증명을 막았습니다. 화면은 CSP 로 보호됩니다.


사용 전 필수 체크

  1. 동행복권 사이트 https://www.dhlottery.co.kr 에서
    회원가입 → 로그인 → 마이페이지 → 건전구매 서약하기 (필수)
  2. 자동 구매를 위해 예치금 충전 필요

다중 계정 사용 및 자동화 주의사항

Important

다중 계정 사용 시 동시 구매는 불가능합니다. 오프라인 복권 판매점 보호, 서버 부하 방지 및 건전한 복권 구매 문화 유지를 위해 아래와 같은 보안 정책이 코드 레벨에 적용되어 있습니다.

적용된 보안 제한 정책

  1. 최대 4계정 제한: 동일 가구(가족 구성원)의 개별 동의 하에 최대 4개 계정까지만 등록 및 로드됩니다. (4개 초과 설정 시 상위 4개만 로드되며 나머지는 무시됩니다.)
  2. 1계정당 주간 최대 5게임(5,000원) 제한: 로또 6/45는 오프라인 판매점 매출 보호 및 사행성 방지 규정에 따라 계정당 주간 최대 5게임까지만 구매할 수 있도록 강제 제한됩니다.
  3. 연금복권 720+ 1일 구매 상한선(Hard Limit): 자동화 버그로 예치금이 한 번에 소진되는 오구매 사고를 방지하기 위해, 연금복권은 **1계정당 1일 최대 5매(5,000원)**까지만 구매할 수 있도록 코드 레벨 상한선이 적용되어 있습니다.
  4. 계정 간 20초 구매 간격 (동시 구매 차단):
    • A 계정이 구매 및 구매 정보 조회를 진행 중일 때는 다른 계정(B)의 구매 요청이 즉시 차단됩니다.
    • A 계정의 구매 및 구매 정보 조회가 완료된 시점부터 최소 20초가 지나야 다른 계정(B)으로 구매할 수 있습니다.
    • 20초 이내에 다른 계정으로 구매를 시도하면 구매가 실행되지 않으며, 해당 계정의 오류 센서(sensor.dhlotto_{username}_lotto45_purchase_error)에 남은 대기 시간이 표시됩니다.
  5. 폴링 하한선 및 랜덤 지연(Jitter): 서버 부하 방지를 위해 센서 갱신 주기는 최소 1,800초(30분) 이상으로 제한되며, 요청 집중을 막기 위해 랜덤 지연(Jitter)이 자동 적용됩니다.

Home Assistant 자동화 작성 가이드

다중 계정을 사용하는 경우, 하나의 자동화에서 여러 계정의 구매 버튼을 동시에 누르면 두 번째 계정부터 보안 로직에 의해 차단됩니다. 반드시 아래 예시처럼 계정 사이에 최소 30초 이상의 delay를 두거나, 계정별로 자동화 실행 시각을 다르게 설정해 주세요.

# ✅ 올바른 자동화 예시 (계정 간 충분한 지연 시간 추가)
alias: "가족 로또 자동 구매"
trigger:
  - platform: time
    at: "10:15:00"
action:
  # 1) 첫 번째 계정 구매
  - service: button.press
    target:
      entity_id: button.dhlotto_account1_buy_auto_5

  # 2) 구매 및 조회 완료 + 20초 보안 간격 확보를 위해 30초 이상 대기
  - delay: "00:00:30"

  # 3) 두 번째 계정 구매
  - service: button.press
    target:
      entity_id: button.dhlotto_account2_buy_auto_5

Tip

매주 토요일 마감 직전(19:50~20:00)이나 정각(09:00, 10:00 등)에 트래픽이 몰리는 시간대는 피하고, 여유 있는 시간대에 계정별로 1분 이상 간격을 두어 자동화를 분산 실행하는 것을 권장합니다.


대시보드 카드 예시 (2계정 기준)

위 스크린샷과 동일한 대시보드 카드를 그대로 복사해 사용하실 수 있습니다.

사전 준비 (HACS 프론트엔드 카드)

  • Bubble Card (custom:bubble-card)
  • button-card (custom:button-card)
  • (선택) 카드 펼치기/접기 토글용 Helper: input_boolean.lazy_lotto (설정 → 기기 및 서비스 → 도우미에서 토글 생성)

적용 방법

  1. 아래 YAML(또는 examples/dashboard_multi_account.yaml)을 복사합니다.
  2. 코드 내 account1, account2를 본인의 동행복권 아이디로 일괄 치환합니다. (단일 계정만 사용 시 account2 영역만 삭제하시면 됩니다.)
  3. Home Assistant 대시보드 → 편집 → 카드 추가 → 수동(YAML) 에 붙여넣어 저장합니다.
📋 2계정 대시보드 카드 YAML 전체 코드 펼치기 (클릭하여 복사)
type: custom:bubble-card
card_type: pop-up
hash: '#pop-up-lotto'
name: 🎰 로또 645
icon: mdi:dice-multiple
button_type: name
styles: |-
  .bubble-pop-up {
    height: 90vh !important;
  }
sub_button:
  main: []
  bottom: []
slider_fill_orientation: left
slider_value_position: right
cards:
- type: custom:bubble-card
  card_type: button
  button_type: switch
  entity: input_boolean.lazy_lotto
  name: 🎰 로또 카드 (펼치기)
  icon: mdi:dice-multiple
  show_state: true
  tap_action:
    action: toggle
  styles: |
    /* lazy-hero */
    .bubble-button-card-container {
      background: linear-gradient(135deg, #1e3a8a 0%, #6366f1 100%) !important;
      position: relative !important;
      min-height: 64px !important;
      border-radius: 16px !important;
      overflow: hidden !important;
      box-shadow: 0 4px 14px rgba(0,0,0,0.18) !important;
    }
    .bubble-button-card-container::before {
      content: '';
      position: absolute;
      inset: 0;
      background: linear-gradient(135deg, rgba(0,0,0,0.05) 0%, rgba(0,0,0,0.55) 100%);
      border-radius: 16px;
      z-index: 0;
      pointer-events: none;
    }
    .bubble-button-card-container > * {
      position: relative !important;
      z-index: 2 !important;
    }
    .bubble-name, .bubble-state, .bubble-sub-button {
      color: #fff !important;
      text-shadow: 0 1px 3px rgba(0,0,0,0.95), 0 0 8px rgba(0,0,0,0.7) !important;
      font-weight: 700 !important;
    }
    .bubble-name { font-size: 16px !important; }
    .bubble-icon, .bubble-icon-container {
      color: #fff !important;
      --mdc-icon-size: 24px !important;
      filter: drop-shadow(0 1px 3px rgba(0,0,0,0.95)) !important;
    }
    .bubble-icon-container {
      background: rgba(255,255,255,0.18) !important;
      backdrop-filter: blur(6px) !important;
      -webkit-backdrop-filter: blur(6px) !important;
      border-radius: 50% !important;
    }
- type: conditional
  conditions:
  - condition: state
    entity: input_boolean.lazy_lotto
    state: 'on'
  card:
    type: vertical-stack
    cards:
    - type: heading
      heading: 🎰 로또 645
      heading_style: subtitle
    - type: vertical-stack
      cards:
      - type: custom:button-card
        entity: sensor.dhlotto_account1_lotto645_winning_numbers
        show_name: false
        show_state: false
        show_icon: false
        styles:
          card:
          - background: rgba(255, 255, 255, 0.03)
          - border: 1px solid rgba(255, 215, 0, 0.3)
          - border-radius: 16px
          - padding: 20px
          - backdrop-filter: blur(10px)
          grid:
          - grid-template-areas: '"content"'
          - grid-template-columns: 1fr
          - grid-template-rows: 1fr
          custom_fields:
            content:
            - display: flex
            - justify-content: center
            - width: 100%
        custom_fields:
          content: |
            [[[
              const round =
                states['sensor.dhlotto_account1_lotto645_round']?.state || '';

              const rawNums =
                (entity.state.match(/\d+/g) || []).map(n => n.trim());

              const filtered = rawNums.filter(n => n !== String(round));

              if (filtered.length < 7) {
                return `<div style="color:#888;text-align:center;">당첨번호 데이터 오류</div>`;
              }

              const winNums = filtered.slice(0, 6);
              const bonus   = filtered[6];

              const drawDate =
                states['sensor.dhlotto_account1_lotto645_draw_date']?.state || '';

              function color(n) {
                n = parseInt(n);
                if (n <= 9) return '#fbc400';
                if (n <= 19) return '#69c8f2';
                if (n <= 29) return '#ff7272';
                if (n <= 39) return '#aaa';
                return '#b0d840';
              }

              let out = `
                <div style="width:100%;display:flex;flex-direction:column;align-items:center;">

                  <div style="font-size:18px;font-weight:700;color:gold;margin-bottom:4px;">
                    🎱 ${round}회 당첨번호
                  </div>

                  <div style="font-size:12px;opacity:0.65;margin-bottom:12px;">
                    ${drawDate}
                  </div>

                  <div style="display:flex;gap:8px;align-items:center;">
              `;

              winNums.forEach(n => {
                out += `
                  <div style="
                    width:33px;height:33px;border-radius:50%;
                    background:${color(n)};
                    display:flex;align-items:center;justify-content:center;
                    font-weight:700;font-size:15px;color:#000;
                    box-shadow:0 2px 6px rgba(0,0,0,0.3);
                  ">${n}</div>
                `;
              });

              out += `
                <div style="font-size:20px;font-weight:700;opacity:0.6;">+</div>

                <div style="
                  width:33px;height:33px;border-radius:50%;
                  background:${color(bonus)};
                  display:flex;align-items:center;justify-content:center;
                  font-weight:700;font-size:15px;color:#000;
                  border:2px solid gold;
                  box-shadow:0 2px 6px rgba(0,0,0,0.3);
                ">${bonus}</div>

              </div></div>`;

              return out;
            ]]]
      - type: custom:button-card
        entity: sensor.dhlotto_account1_lotto45_game_1
        show_name: false
        show_state: false
        show_icon: false
        styles:
          card:
          - background: rgba(255, 255, 255, 0.03)
          - border: 1px solid rgba(255, 215, 0, 0.3)
          - border-radius: 16px
          - padding: 20px
          - backdrop-filter: blur(10px)
          grid:
          - grid-template-areas: '"content"'
          - grid-template-columns: 1fr
        custom_fields:
          content: |
            [[[
              const winEnt = states['sensor.dhlotto_account1_lotto645_winning_numbers'];
              const winNums =
                winEnt &&
                winEnt.state &&
                !['unknown','unavailable','none',''].includes(winEnt.state)
                  ? winEnt.state.split(/[, ]+/).map(n => n.trim())
                  : [];

              const histList = [
                'sensor.dhlotto_account1_lotto45_game_1',
                'sensor.dhlotto_account1_lotto45_game_2',
                'sensor.dhlotto_account1_lotto45_game_3',
                'sensor.dhlotto_account1_lotto45_game_4',
                'sensor.dhlotto_account1_lotto45_game_5'
              ];

              function histColor(num) {
                const n = parseInt(num);
                if (n <= 10) return '#fbc400';
                if (n <= 20) return '#69c8f2';
                if (n <= 30) return '#ff7272';
                if (n <= 40) return '#aaa';
                return '#b0d840';
              }

              function resultIcon(state) {
                if (!state) return '<span style="opacity:.6;">⏳</span>';

                const s = String(state).trim();

                if (['미추첨','확인중','unknown','unavailable',''].includes(s))
                  return '<span style="opacity:.6;">⏳</span>';

                if (s === '낙첨')
                  return '<span style="color:#f44;">❌</span>';

                const match = s.match(/([1-5])등/);
                if (match) {
                  return `
                    <span style="
                      display:flex;
                      justify-content:flex-end;
                      align-items:center;
                      gap:4px;
                      color:gold;
                      font-weight:800;
                    ">
                      🏆 <span style="font-size:13px;">${match[1]}</span>
                    </span>
                  `;
                }

                return '<span style="opacity:.6;">⏳</span>';
              }

              let items = '';

              for (let i = 0; i < histList.length; i++) {
                const ent = states[histList[i]];
                if (!ent || ['unavailable','unknown','none',''].includes(ent.state)) continue;

                const resultEnt = states[histList[i] + '_result'];
                const resultValue =
                  resultEnt && resultEnt.state ? resultEnt.state : '확인중';

                const slot = ent.attributes['슬롯'] || String.fromCharCode(65 + i);
                const mode = ent.attributes['선택'] || '자동';

                const isWin = resultValue.includes('등');
                const isLose = resultValue === '낙첨';

                const nums = ent.state.split(/[, ]+/).map(n => n.trim()).filter(n => n);
                if (nums.length < 6) continue;

                let balls = `<div style="flex:1;display:flex;justify-content:center;gap:6px;">`;

                for (const n of nums) {
                  const isMatch = winNums.includes(String(n));

                  balls += `
                    <div style="
                      width:28px;
                      height:28px;
                      border-radius:50%;
                      background:${histColor(n)};
                      display:flex;
                      align-items:center;
                      justify-content:center;
                      font-weight:${isMatch ? 900 : 700};
                      font-size:13px;
                      color:#000;
                      box-shadow:${isMatch
                        ? '0 0 8px rgba(255,255,255,0.9)'
                        : '0 2px 4px rgba(0,0,0,0.2)'};
                      border:${isMatch ? '2px solid #fff' : 'none'};
                    ">${n}</div>
                  `;
                }

                balls += '</div>';

                let resultStyle = 'color:rgba(255,255,255,0.6);';
                if (isWin) resultStyle = 'color:gold;font-weight:800;';
                else if (isLose) resultStyle = 'color:#f44;opacity:.85;';

                items += `
                  <div style="
                    display:flex;
                    align-items:center;
                    padding:10px 12px;
                    background:${isWin ? 'rgba(255,215,0,0.15)' : 'rgba(255,255,255,0.03)'};
                    border-radius:10px;
                    border:1px solid ${isWin ? 'gold' : 'rgba(255,255,255,0.1)'};
                    margin-bottom:8px;
                  ">
                    <div style="width:65px;font-size:12px;color:rgba(255,255,255,0.6);">
                      ${slot}(${mode})
                    </div>

                    ${balls}

                    <div style="width:65px;font-size:18px;text-align:right;${resultStyle}">
                      ${resultIcon(resultValue)}
                    </div>
                  </div>
                `;
              }

              if (!items) {
                return '<div style="padding:20px;text-align:center;color:grey;">구매 내역 데이터가 없습니다.</div>';
              }

              return `
                <div style="width:100%;display:flex;flex-direction:column;align-items:center;">
                  <div style="font-size:16px;font-weight:700;color:gold;margin-bottom:14px;">
                    📋 계정 1 구매 내역
                  </div>
                  <div style="display:flex;flex-direction:column;width:100%;">
                    ${items}
                  </div>
                </div>
              `;
            ]]]
      - type: custom:button-card
        entity: sensor.dhlotto_account1_lotto45_balance
        show_name: false
        show_state: false
        show_icon: false
        styles:
          card:
          - background: rgba(255, 255, 255, 0.03)
          - border: 1px solid rgba(255, 215, 0, 0.3)
          - border-radius: 16px
          - padding: 14px 16px
          - backdrop-filter: blur(10px)
          grid:
          - grid-template-areas: '"content"'
          - grid-template-columns: 1fr
          - grid-template-rows: 1fr
        custom_fields:
          content: |
            [[[
              const value = parseInt(entity.state) || 0;
              const won = value.toLocaleString('ko-KR');

              return `
                <div style="
                  width:100%;
                  display:flex;
                  align-items:center;
                  justify-content:center;
                  gap:12px;
                ">
                  <div style="
                    font-size:13px;
                    font-weight:600;
                    color:rgba(255,255,255,0.7);
                    white-space:nowrap;
                  ">
                    💰 예치금
                  </div>

                  <div style="
                    font-size:18px;
                    font-weight:800;
                    color:${value > 0 ? 'gold' : '#888'};
                    letter-spacing:0.3px;
                    white-space:nowrap;
                  ">
                    ${won}원
                  </div>
                </div>
              `;
            ]]]
      - type: custom:button-card
        entity: sensor.dhlotto_account1_lotto45_total_winning
        show_name: false
        show_state: false
        show_icon: false
        styles:
          card:
          - background: rgba(255, 255, 255, 0.03)
          - border: 1px solid rgba(255, 215, 0, 0.3)
          - border-radius: 16px
          - padding: 14px 16px
          - backdrop-filter: blur(10px)
          grid:
          - grid-template-areas: '"content"'
          - grid-template-columns: 1fr
          - grid-template-rows: 1fr
        custom_fields:
          content: |
            [[[
              const value = parseInt(entity.state) || 0;
              const won = value.toLocaleString('ko-KR');

              return `
                <div style="
                  width:100%;
                  display:flex;
                  align-items:center;
                  justify-content:center;
                  gap:12px;
                ">
                  <div style="
                    font-size:13px;
                    font-weight:600;
                    color:rgba(255,255,255,0.7);
                    white-space:nowrap;
                  ">
                    💰 총 당첨금
                  </div>

                  <div style="
                    font-size:18px;
                    font-weight:800;
                    color:${value > 0 ? 'gold' : '#888'};
                    letter-spacing:0.3px;
                    white-space:nowrap;
                  ">
                    ${won}원
                  </div>
                </div>
              `;
            ]]]
      - type: horizontal-stack
        cards:
        - type: custom:button-card
          entity: button.dhlotto_account1_generate_random
          name: 랜덤생성
          icon: mdi:dice-multiple-outline
          show_state: false
          tap_action:
            action: call-service
            service: button.press
            service_data:
              entity_id: button.dhlotto_account1_generate_random
          confirmation:
            text: 랜덤 번호를 생성하시겠습니까?
          styles:
            card:
            - background: rgba(255, 255, 255, 0.05)
            - border: 1px solid rgba(255, 215, 0, 0.3)
            - border-radius: 12px
            - padding: 12px 8px
            - backdrop-filter: blur(10px)
            icon:
            - color: gold
            - width: 22px
            name:
            - font-size: 12px
            - font-weight: 600
            - color: rgba(255, 255, 255, 0.9)
            - margin-top: 4px
            grid:
            - grid-template-areas: '"i" "n"'
            - grid-template-rows: 1fr min-content
        - type: custom:button-card
          entity: button.dhlotto_account1_buy_auto_5
          name: 전체구매
          icon: mdi:cart-outline
          show_state: false
          tap_action:
            action: call-service
            service: button.press
            service_data:
              entity_id: button.dhlotto_account1_buy_auto_5
          confirmation:
            text: 로또 5게임을 구매하시겠습니까?
          styles:
            card:
            - background: rgba(255, 255, 255, 0.05)
            - border: 1px solid rgba(255, 215, 0, 0.3)
            - border-radius: 12px
            - padding: 12px 8px
            - backdrop-filter: blur(10px)
            icon:
            - color: gold
            - width: 22px
            name:
            - font-size: 12px
            - font-weight: 600
            - color: rgba(255, 255, 255, 0.9)
            - margin-top: 4px
            grid:
            - grid-template-areas: '"i" "n"'
            - grid-template-rows: 1fr min-content
        - type: custom:button-card
          entity: button.dhlotto_account1_buy_manual
          name: 수동구매
          icon: mdi:pencil-outline
          show_state: false
          tap_action:
            action: call-service
            service: button.press
            service_data:
              entity_id: button.dhlotto_account1_buy_manual
          confirmation:
            text: 수동으로 로또를 구매하시겠습니까?
          styles:
            card:
            - background: rgba(255, 255, 255, 0.05)
            - border: 1px solid rgba(255, 215, 0, 0.3)
            - border-radius: 12px
            - padding: 12px 8px
            - backdrop-filter: blur(10px)
            icon:
            - color: gold
            - width: 22px
            name:
            - font-size: 12px
            - font-weight: 600
            - color: rgba(255, 255, 255, 0.9)
            - margin-top: 4px
            grid:
            - grid-template-areas: '"i" "n"'
            - grid-template-rows: 1fr min-content
        - type: custom:button-card
          entity: button.dhlotto_account1_buy_auto_1
          name: 1게임
          icon: mdi:ticket-outline
          show_state: false
          tap_action:
            action: call-service
            service: button.press
            service_data:
              entity_id: button.dhlotto_account1_buy_auto_1
          confirmation:
            text: 로또 1게임을 구매하시겠습니까?
          styles:
            card:
            - background: rgba(255, 255, 255, 0.05)
            - border: 1px solid rgba(255, 215, 0, 0.3)
            - border-radius: 12px
            - padding: 12px 8px
            - backdrop-filter: blur(10px)
            icon:
            - color: gold
            - width: 22px
            name:
            - font-size: 12px
            - font-weight: 600
            - color: rgba(255, 255, 255, 0.9)
            - margin-top: 4px
            grid:
            - grid-template-areas: '"i" "n"'
            - grid-template-rows: 1fr min-content
      - type: entities
        entities:
        - entity: text.dhlotto_account1_lotto_manual_numbers
          name: 로또 수동번호
        card_mod:
          style: |
            ha-card {
              height: 64px;
              background: rgba(255, 255, 255, 0.05);
              border: 1px solid rgba(255, 215, 0, 0.3);
              border-radius: 12px;
              padding: 0 8px;
              display: flex;
              align-items: center;
              box-sizing: border-box;
            }

            .card-content {
              padding: 0 !important;
              width: 100%;
            }

            hui-input-text-entity-row {
              width: 100%;
            }

            ha-textfield {
              height: 40px;
              --mdc-theme-primary: gold;
              --mdc-text-field-fill-color: transparent;
            }
      visibility:
      - condition: user
        users:
        - 220063f4ced745a1b14c4a5b1476c4d2
    - type: vertical-stack
      cards:
      - type: custom:button-card
        entity: sensor.dhlotto_account2_lotto645_winning_numbers
        show_name: false
        show_state: false
        show_icon: false
        styles:
          card:
          - background: rgba(255, 255, 255, 0.03)
          - border: 1px solid rgba(255, 215, 0, 0.3)
          - border-radius: 16px
          - padding: 20px
          - backdrop-filter: blur(10px)
          grid:
          - grid-template-areas: '"content"'
          - grid-template-columns: 1fr
          - grid-template-rows: 1fr
          custom_fields:
            content:
            - display: flex
            - justify-content: center
            - width: 100%
        custom_fields:
          content: |
            [[[
              const round =
                states['sensor.dhlotto_account2_lotto645_round']?.state || '';

              const rawNums =
                (entity.state.match(/\d+/g) || []).map(n => n.trim());

              const filtered = rawNums.filter(n => n !== String(round));

              if (filtered.length < 7) {
                return `<div style="color:#888;text-align:center;">당첨번호 데이터 오류</div>`;
              }

              const winNums = filtered.slice(0, 6);
              const bonus   = filtered[6];

              const drawDate =
                states['sensor.dhlotto_account2_lotto645_draw_date']?.state || '';

              function color(n) {
                n = parseInt(n);
                if (n <= 9) return '#fbc400';
                if (n <= 19) return '#69c8f2';
                if (n <= 29) return '#ff7272';
                if (n <= 39) return '#aaa';
                return '#b0d840';
              }

              let out = `
                <div style="width:100%;display:flex;flex-direction:column;align-items:center;">

                  <div style="font-size:18px;font-weight:700;color:gold;margin-bottom:4px;">
                    🎱 ${round}회 당첨번호
                  </div>

                  <div style="font-size:12px;opacity:0.65;margin-bottom:12px;">
                    ${drawDate}
                  </div>

                  <div style="display:flex;gap:8px;align-items:center;">
              `;

              winNums.forEach(n => {
                out += `
                  <div style="
                    width:33px;height:33px;border-radius:50%;
                    background:${color(n)};
                    display:flex;align-items:center;justify-content:center;
                    font-weight:700;font-size:15px;color:#000;
                    box-shadow:0 2px 6px rgba(0,0,0,0.3);
                  ">${n}</div>
                `;
              });

              out += `
                <div style="font-size:20px;font-weight:700;opacity:0.6;">+</div>

                <div style="
                  width:33px;height:33px;border-radius:50%;
                  background:${color(bonus)};
                  display:flex;align-items:center;justify-content:center;
                  font-weight:700;font-size:15px;color:#000;
                  border:2px solid gold;
                  box-shadow:0 2px 6px rgba(0,0,0,0.3);
                ">${bonus}</div>

              </div></div>`;

              return out;
            ]]]
      - type: custom:button-card
        entity: sensor.dhlotto_account2_lotto45_game_1
        show_name: false
        show_state: false
        show_icon: false
        styles:
          card:
          - background: rgba(255, 255, 255, 0.03)
          - border: 1px solid rgba(255, 215, 0, 0.3)
          - border-radius: 16px
          - padding: 20px
          - backdrop-filter: blur(10px)
          grid:
          - grid-template-areas: '"content"'
          - grid-template-columns: 1fr
        custom_fields:
          content: |
            [[[
              const winEnt = states['sensor.dhlotto_account2_lotto645_winning_numbers'];
              const winNums =
                winEnt &&
                winEnt.state &&
                !['unknown','unavailable','none',''].includes(winEnt.state)
                  ? winEnt.state.split(/[, ]+/).map(n => n.trim())
                  : [];

              const histList = [
                'sensor.dhlotto_account2_lotto45_game_1',
                'sensor.dhlotto_account2_lotto45_game_2',
                'sensor.dhlotto_account2_lotto45_game_3',
                'sensor.dhlotto_account2_lotto45_game_4',
                'sensor.dhlotto_account2_lotto45_game_5'
              ];

              function histColor(num) {
                const n = parseInt(num);
                if (n <= 10) return '#fbc400';
                if (n <= 20) return '#69c8f2';
                if (n <= 30) return '#ff7272';
                if (n <= 40) return '#aaa';
                return '#b0d840';
              }

              function resultIcon(state) {
                if (!state) return '<span style="opacity:.6;">⏳</span>';

                const s = String(state).trim();

                if (['미추첨','확인중','unknown','unavailable',''].includes(s))
                  return '<span style="opacity:.6;">⏳</span>';

                if (s === '낙첨')
                  return '<span style="color:#f44;">❌</span>';

                const match = s.match(/([1-5])등/);
                if (match) {
                  return `
                    <span style="
                      display:flex;
                      justify-content:flex-end;
                      align-items:center;
                      gap:4px;
                      color:gold;
                      font-weight:800;
                    ">
                      🏆 <span style="font-size:13px;">${match[1]}</span>
                    </span>
                  `;
                }

                return '<span style="opacity:.6;">⏳</span>';
              }

              let items = '';

              for (let i = 0; i < histList.length; i++) {
                const ent = states[histList[i]];
                if (!ent || ['unavailable','unknown','none',''].includes(ent.state)) continue;

                const resultEnt = states[histList[i] + '_result'];
                const resultValue =
                  resultEnt && resultEnt.state ? resultEnt.state : '확인중';

                const slot = ent.attributes['슬롯'] || String.fromCharCode(65 + i);
                const mode = ent.attributes['선택'] || '자동';

                const isWin = resultValue.includes('등');
                const isLose = resultValue === '낙첨';

                const nums = ent.state.split(/[, ]+/).map(n => n.trim()).filter(n => n);
                if (nums.length < 6) continue;

                let balls = `<div style="flex:1;display:flex;justify-content:center;gap:6px;">`;

                for (const n of nums) {
                  const isMatch = winNums.includes(String(n));

                  balls += `
                    <div style="
                      width:28px;
                      height:28px;
                      border-radius:50%;
                      background:${histColor(n)};
                      display:flex;
                      align-items:center;
                      justify-content:center;
                      font-weight:${isMatch ? 900 : 700};
                      font-size:13px;
                      color:#000;
                      box-shadow:${isMatch
                        ? '0 0 8px rgba(255,255,255,0.9)'
                        : '0 2px 4px rgba(0,0,0,0.2)'};
                      border:${isMatch ? '2px solid #fff' : 'none'};
                    ">${n}</div>
                  `;
                }

                balls += '</div>';

                let resultStyle = 'color:rgba(255,255,255,0.6);';
                if (isWin) resultStyle = 'color:gold;font-weight:800;';
                else if (isLose) resultStyle = 'color:#f44;opacity:.85;';

                items += `
                  <div style="
                    display:flex;
                    align-items:center;
                    padding:10px 12px;
                    background:${isWin ? 'rgba(255,215,0,0.15)' : 'rgba(255,255,255,0.03)'};
                    border-radius:10px;
                    border:1px solid ${isWin ? 'gold' : 'rgba(255,255,255,0.1)'};
                    margin-bottom:8px;
                  ">
                    <div style="width:65px;font-size:12px;color:rgba(255,255,255,0.6);">
                      ${slot}(${mode})
                    </div>

                    ${balls}

                    <div style="width:65px;font-size:18px;text-align:right;${resultStyle}">
                      ${resultIcon(resultValue)}
                    </div>
                  </div>
                `;
              }

              if (!items) {
                return '<div style="padding:20px;text-align:center;color:grey;">구매 내역 데이터가 없습니다.</div>';
              }

              return `
                <div style="width:100%;display:flex;flex-direction:column;align-items:center;">
                  <div style="font-size:16px;font-weight:700;color:gold;margin-bottom:14px;">
                    📋 계정 2 구매 내역
                  </div>
                  <div style="display:flex;flex-direction:column;width:100%;">
                    ${items}
                  </div>
                </div>
              `;
            ]]]
      - type: custom:button-card
        entity: sensor.dhlotto_account2_lotto45_balance
        show_name: false
        show_state: false
        show_icon: false
        styles:
          card:
          - background: rgba(255, 255, 255, 0.03)
          - border: 1px solid rgba(255, 215, 0, 0.3)
          - border-radius: 16px
          - padding: 14px 16px
          - backdrop-filter: blur(10px)
          grid:
          - grid-template-areas: '"content"'
          - grid-template-columns: 1fr
          - grid-template-rows: 1fr
        custom_fields:
          content: |
            [[[
              const value = parseInt(entity.state) || 0;
              const won = value.toLocaleString('ko-KR');

              return `
                <div style="
                  width:100%;
                  display:flex;
                  align-items:center;
                  justify-content:center;
                  gap:12px;
                ">
                  <div style="
                    font-size:13px;
                    font-weight:600;
                    color:rgba(255,255,255,0.7);
                    white-space:nowrap;
                  ">
                    💰 예치금
                  </div>

                  <div style="
                    font-size:18px;
                    font-weight:800;
                    color:${value > 0 ? 'gold' : '#888'};
                    letter-spacing:0.3px;
                    white-space:nowrap;
                  ">
                    ${won}원
                  </div>
                </div>
              `;
            ]]]
      - type: custom:button-card
        entity: sensor.dhlotto_account2_lotto45_total_winning
        show_name: false
        show_state: false
        show_icon: false
        styles:
          card:
          - background: rgba(255, 255, 255, 0.03)
          - border: 1px solid rgba(255, 215, 0, 0.3)
          - border-radius: 16px
          - padding: 14px 16px
          - backdrop-filter: blur(10px)
          grid:
          - grid-template-areas: '"content"'
          - grid-template-columns: 1fr
          - grid-template-rows: 1fr
        custom_fields:
          content: |
            [[[
              const value = parseInt(entity.state) || 0;
              const won = value.toLocaleString('ko-KR');

              return `
                <div style="
                  width:100%;
                  display:flex;
                  align-items:center;
                  justify-content:center;
                  gap:12px;
                ">
                  <div style="
                    font-size:13px;
                    font-weight:600;
                    color:rgba(255,255,255,0.7);
                    white-space:nowrap;
                  ">
                    💰 총 당첨금
                  </div>

                  <div style="
                    font-size:18px;
                    font-weight:800;
                    color:${value > 0 ? 'gold' : '#888'};
                    letter-spacing:0.3px;
                    white-space:nowrap;
                  ">
                    ${won}원
                  </div>
                </div>
              `;
            ]]]
      - type: horizontal-stack
        cards:
        - type: custom:button-card
          entity: button.dhlotto_account2_generate_random
          name: 랜덤생성
          icon: mdi:dice-multiple-outline
          show_state: false
          tap_action:
            action: call-service
            service: button.press
            service_data:
              entity_id: button.dhlotto_account2_generate_random
          confirmation:
            text: 랜덤 번호를 생성하시겠습니까?
          styles:
            card:
            - background: rgba(255, 255, 255, 0.05)
            - border: 1px solid rgba(255, 215, 0, 0.3)
            - border-radius: 12px
            - padding: 12px 8px
            - backdrop-filter: blur(10px)
            icon:
            - color: gold
            - width: 22px
            name:
            - font-size: 12px
            - font-weight: 600
            - color: rgba(255, 255, 255, 0.9)
            - margin-top: 4px
            grid:
            - grid-template-areas: '"i" "n"'
            - grid-template-rows: 1fr min-content
        - type: custom:button-card
          entity: button.dhlotto_account2_buy_auto_5
          name: 전체구매
          icon: mdi:cart-outline
          show_state: false
          tap_action:
            action: call-service
            service: button.press
            service_data:
              entity_id: button.dhlotto_account2_buy_auto_5
          confirmation:
            text: 로또 5게임을 구매하시겠습니까?
          styles:
            card:
            - background: rgba(255, 255, 255, 0.05)
            - border: 1px solid rgba(255, 215, 0, 0.3)
            - border-radius: 12px
            - padding: 12px 8px
            - backdrop-filter: blur(10px)
            icon:
            - color: gold
            - width: 22px
            name:
            - font-size: 12px
            - font-weight: 600
            - color: rgba(255, 255, 255, 0.9)
            - margin-top: 4px
            grid:
            - grid-template-areas: '"i" "n"'
            - grid-template-rows: 1fr min-content
        - type: custom:button-card
          entity: button.dhlotto_account2_buy_manual
          name: 수동구매
          icon: mdi:pencil-outline
          show_state: false
          tap_action:
            action: call-service
            service: button.press
            service_data:
              entity_id: button.dhlotto_account2_buy_manual
          confirmation:
            text: 수동으로 로또를 구매하시겠습니까?
          styles:
            card:
            - background: rgba(255, 255, 255, 0.05)
            - border: 1px solid rgba(255, 215, 0, 0.3)
            - border-radius: 12px
            - padding: 12px 8px
            - backdrop-filter: blur(10px)
            icon:
            - color: gold
            - width: 22px
            name:
            - font-size: 12px
            - font-weight: 600
            - color: rgba(255, 255, 255, 0.9)
            - margin-top: 4px
            grid:
            - grid-template-areas: '"i" "n"'
            - grid-template-rows: 1fr min-content
        - type: custom:button-card
          entity: button.dhlotto_account2_buy_auto_1
          name: 1게임
          icon: mdi:ticket-outline
          show_state: false
          tap_action:
            action: call-service
            service: button.press
            service_data:
              entity_id: button.dhlotto_account2_buy_auto_1
          confirmation:
            text: 로또 1게임을 구매하시겠습니까?
          styles:
            card:
            - background: rgba(255, 255, 255, 0.05)
            - border: 1px solid rgba(255, 215, 0, 0.3)
            - border-radius: 12px
            - padding: 12px 8px
            - backdrop-filter: blur(10px)
            icon:
            - color: gold
            - width: 22px
            name:
            - font-size: 12px
            - font-weight: 600
            - color: rgba(255, 255, 255, 0.9)
            - margin-top: 4px
            grid:
            - grid-template-areas: '"i" "n"'
            - grid-template-rows: 1fr min-content
      - type: entities
        entities:
        - entity: text.dhlotto_account2_lotto_manual_numbers
          name: 로또 수동번호
        card_mod:
          style: |
            ha-card {
              height: 64px;
              background: rgba(255, 255, 255, 0.05);
              border: 1px solid rgba(255, 215, 0, 0.3);
              border-radius: 12px;
              padding: 0 8px;
              display: flex;
              align-items: center;
              box-sizing: border-box;
            }

            .card-content {
              padding: 0 !important;
              width: 100%;
            }

            hui-input-text-entity-row {
              width: 100%;
            }

            ha-textfield {
              height: 40px;
              --mdc-theme-primary: gold;
              --mdc-text-field-fill-color: transparent;
            }
      visibility:
      - condition: user
        users:
        - 27704182c6784fe19d7e2eb6155c824d
    - type: heading
      heading: 💰 연금복권720+
      heading_style: subtitle
    - type: custom:button-card
      entity: sensor.dhlotto_account1_pension720_winning_number
      show_name: false
      show_state: false
      show_icon: false
      styles:
        card:
        - background: rgba(255, 255, 255, 0.03)
        - border: 1px solid rgba(255, 215, 0, 0.3)
        - border-radius: 16px
        - padding: 20px
        - backdrop-filter: blur(10px)
        grid:
        - grid-template-areas: '"content"'
        - grid-template-columns: 1fr
        - grid-template-rows: 1fr
        custom_fields:
          content:
          - display: flex
          - justify-content: center
          - width: 100%
      custom_fields:
        content: |
          [[[
            const P = 'sensor.dhlotto_account1_pension720_';
            const round = states[P+'round']?.state || '';
            const win = entity.state || '';
            const m = win.match(/(\d+)\s*조\s*(\d+)/);
            const jo = m ? m[1] : '';
            const num = m ? m[2] : win;
            const bonus = states[P+'bonus_number']?.state || '';
            const drawDate = states[P+'draw_date']?.state || '';
            const rank1 = states[P+'rank1_winners']?.state || '';
            const store = states[P+'first_store']?.state || '';
            let out = `<div style="width:100%;display:flex;flex-direction:column;align-items:center;">
              <div style="font-size:18px;font-weight:700;color:gold;margin-bottom:4px;">💰 ${round}회 연금복권720+</div>
              <div style="font-size:12px;opacity:0.65;margin-bottom:12px;">${drawDate}</div>
              <div style="display:flex;gap:6px;align-items:center;flex-wrap:wrap;justify-content:center;">
                <div style="padding:0 12px;height:33px;border-radius:16px;background:gold;display:flex;align-items:center;justify-content:center;font-weight:700;font-size:15px;color:#000;">${jo}조</div>`;
            num.split('').forEach(d => {
              out += `<div style="width:33px;height:33px;border-radius:50%;background:#69c8f2;display:flex;align-items:center;justify-content:center;font-weight:700;font-size:15px;color:#000;box-shadow:0 2px 6px rgba(0,0,0,0.3);">${d}</div>`;
            });
            out += `</div>
              <div style="margin-top:10px;font-size:12px;opacity:0.7;">보너스 <span style="color:gold;font-weight:700;">${bonus}</span></div>
              <div style="margin-top:6px;font-size:12px;opacity:0.7;">1등 ${rank1}명 · ${store}</div>
            </div>`;
            return out;
          ]]]
    - type: heading
      heading: 🤖 연금 자동구매
      heading_style: subtitle
      visibility:
      - condition: user
        users:
        - 220063f4ced745a1b14c4a5b1476c4d2
    - type: horizontal-stack
      cards:
      - type: custom:button-card
        entity: button.dhlotto_account1_buy_pension_auto_1
        name: 연금 1매
        icon: mdi:cash
        show_state: false
        tap_action:
          action: call-service
          service: button.press
          service_data:
            entity_id: button.dhlotto_account1_buy_pension_auto_1
        confirmation:
          text: 연금복권 1매(1,000원)를 구매하시겠습니까?
        styles:
          card:
          - background: rgba(255, 255, 255, 0.05)
          - border: 1px solid rgba(255, 215, 0, 0.3)
          - border-radius: 12px
          - padding: 12px 8px
          - backdrop-filter: blur(10px)
          icon:
          - color: gold
          - width: 22px
          name:
          - font-size: 12px
          - font-weight: 600
          - color: rgba(255, 255, 255, 0.9)
          - margin-top: 4px
          grid:
          - grid-template-areas: '"i" "n"'
          - grid-template-rows: 1fr min-content
      - type: custom:button-card
        entity: button.dhlotto_account1_buy_pension_auto_5
        name: 연금 5매
        icon: mdi:cash-multiple
        show_state: false
        tap_action:
          action: call-service
          service: button.press
          service_data:
            entity_id: button.dhlotto_account1_buy_pension_auto_5
        confirmation:
          text: 연금복권 5매(5,000원)를 구매하시겠습니까?
        styles:
          card:
          - background: rgba(255, 255, 255, 0.05)
          - border: 1px solid rgba(255, 215, 0, 0.3)
          - border-radius: 12px
          - padding: 12px 8px
          - backdrop-filter: blur(10px)
          icon:
          - color: gold
          - width: 22px
          name:
          - font-size: 12px
          - font-weight: 600
          - color: rgba(255, 255, 255, 0.9)
          - margin-top: 4px
          grid:
          - grid-template-areas: '"i" "n"'
          - grid-template-rows: 1fr min-content
      visibility:
      - condition: user
        users:
        - 220063f4ced745a1b14c4a5b1476c4d2
    - type: markdown
      visibility:
      - condition: user
        users:
        - 220063f4ced745a1b14c4a5b1476c4d2
      entity_id:
      - sensor.dhlotto_account1_pension720_this_round
      - sensor.dhlotto_account1_pension720_last_round
      content: |-
        {% set tr = 'sensor.dhlotto_account1_pension720_this_round' %}
        {% set lr = 'sensor.dhlotto_account1_pension720_last_round' %}
        {% set nt = namespace(l=[]) %}
        {% for g in state_attr(tr,'games') or [] %}{% set nt.l = nt.l + [loop.index ~ '. ' ~ g.group ~ '조 ' ~ g.number] %}{% endfor %}
        {% set nl = namespace(l=[]) %}
        {% for g in state_attr(lr,'games') or [] %}{% set nl.l = nl.l + [loop.index ~ '. ' ~ g.group ~ '조 ' ~ g.number ~ ' — ' ~ g.result ~ (' 💰' ~ g.win_amount ~ '원' if g.win_amount else '')] %}{% endfor %}
        ## 🎫 연금복권 이번 회차 ({{ state_attr(tr,'round_no') }}회) · {{ states(tr) }}매

        {{ nt.l | join('
        ') }}

        ## 🏆 연금복권 지난 회차 결과

        {{ state_attr(lr,'result_summary') }}
        {{ nl.l | join('
        ') }}
    - type: heading
      heading: ✍️ 연금 수동구매 (조,번호 지정)
      heading_style: subtitle
      visibility:
      - condition: user
        users:
        - 220063f4ced745a1b14c4a5b1476c4d2
    - type: vertical-stack
      visibility:
      - condition: user
        users:
        - 220063f4ced745a1b14c4a5b1476c4d2
      cards:
      - type: entities
        entities:
        - entity: text.dhlotto_account1_pension_manual
          name: 연금 수동번호 (조,번호)
      - type: custom:button-card
        entity: button.dhlotto_account1_buy_pension_manual
        name: 연금 수동구매
        icon: mdi:hand-pointing-right
        show_state: false
        tap_action:
          action: call-service
          service: button.press
          service_data:
            entity_id: button.dhlotto_account1_buy_pension_manual
        confirmation:
          text: 입력한 조·번호로 연금복권 1매(1,000원)를 수동 구매하시겠습니까?
        styles:
          card:
          - background: rgba(255, 255, 255, 0.05)
          - border: 1px solid rgba(255, 215, 0, 0.3)
          - border-radius: 12px
          - padding: 12px 8px
          - backdrop-filter: blur(10px)
          icon:
          - color: gold
          - width: 22px
          name:
          - font-size: 12px
          - font-weight: 600
          - color: rgba(255, 255, 255, 0.9)
          - margin-top: 4px
    - type: heading
      heading: 🤖 연금 자동구매
      heading_style: subtitle
      visibility:
      - condition: user
        users:
        - 27704182c6784fe19d7e2eb6155c824d
    - type: horizontal-stack
      visibility:
      - condition: user
        users:
        - 27704182c6784fe19d7e2eb6155c824d
      cards:
      - type: custom:button-card
        entity: button.dhlotto_account2_buy_pension_auto_1
        name: 연금 1매
        icon: mdi:cash
        show_state: false
        tap_action:
          action: call-service
          service: button.press
          service_data:
            entity_id: button.dhlotto_account2_buy_pension_auto_1
        confirmation:
          text: 연금복권 1매(1,000원)를 구매하시겠습니까?
        styles:
          card:
          - background: rgba(255, 255, 255, 0.05)
          - border: 1px solid rgba(255, 215, 0, 0.3)
          - border-radius: 12px
          - padding: 12px 8px
          - backdrop-filter: blur(10px)
          icon:
          - color: gold
          - width: 22px
          name:
          - font-size: 12px
          - font-weight: 600
          - color: rgba(255, 255, 255, 0.9)
          - margin-top: 4px
          grid:
          - grid-template-areas: '"i" "n"'
          - grid-template-rows: 1fr min-content
      - type: custom:button-card
        entity: button.dhlotto_account2_buy_pension_auto_5
        name: 연금 5매
        icon: mdi:cash-multiple
        show_state: false
        tap_action:
          action: call-service
          service: button.press
          service_data:
            entity_id: button.dhlotto_account2_buy_pension_auto_5
        confirmation:
          text: 연금복권 5매(5,000원)를 구매하시겠습니까?
        styles:
          card:
          - background: rgba(255, 255, 255, 0.05)
          - border: 1px solid rgba(255, 215, 0, 0.3)
          - border-radius: 12px
          - padding: 12px 8px
          - backdrop-filter: blur(10px)
          icon:
          - color: gold
          - width: 22px
          name:
          - font-size: 12px
          - font-weight: 600
          - color: rgba(255, 255, 255, 0.9)
          - margin-top: 4px
          grid:
          - grid-template-areas: '"i" "n"'
          - grid-template-rows: 1fr min-content
    - type: markdown
      visibility:
      - condition: user
        users:
        - 27704182c6784fe19d7e2eb6155c824d
      entity_id:
      - sensor.dhlotto_account2_pension720_this_round
      - sensor.dhlotto_account2_pension720_last_round
      content: |-
        {% set tr = 'sensor.dhlotto_account2_pension720_this_round' %}
        {% set lr = 'sensor.dhlotto_account2_pension720_last_round' %}
        {% set nt = namespace(l=[]) %}
        {% for g in state_attr(tr,'games') or [] %}{% set nt.l = nt.l + [loop.index ~ '. ' ~ g.group ~ '조 ' ~ g.number] %}{% endfor %}
        {% set nl = namespace(l=[]) %}
        {% for g in state_attr(lr,'games') or [] %}{% set nl.l = nl.l + [loop.index ~ '. ' ~ g.group ~ '조 ' ~ g.number ~ ' — ' ~ g.result ~ (' 💰' ~ g.win_amount ~ '원' if g.win_amount else '')] %}{% endfor %}
        ## 🎫 연금복권 이번 회차 ({{ state_attr(tr,'round_no') }}회) · {{ states(tr) }}매

        {{ nt.l | join('
        ') }}

        ## 🏆 연금복권 지난 회차 결과

        {{ state_attr(lr,'result_summary') }}
        {{ nl.l | join('
        ') }}
    - type: heading
      heading: ✍️ 연금 수동구매 (조,번호 지정)
      heading_style: subtitle
      visibility:
      - condition: user
        users:
        - 27704182c6784fe19d7e2eb6155c824d
    - type: vertical-stack
      visibility:
      - condition: user
        users:
        - 27704182c6784fe19d7e2eb6155c824d
      cards:
      - type: entities
        entities:
        - entity: text.dhlotto_account2_pension_manual
          name: 연금 수동번호 (조,번호)
      - type: custom:button-card
        entity: button.dhlotto_account2_buy_pension_manual
        name: 연금 수동구매
        icon: mdi:hand-pointing-right
        show_state: false
        tap_action:
          action: call-service
          service: button.press
          service_data:
            entity_id: button.dhlotto_account2_buy_pension_manual
        confirmation:
          text: 입력한 조·번호로 연금복권 1매(1,000원)를 수동 구매하시겠습니까?
        styles:
          card:
          - background: rgba(255, 255, 255, 0.05)
          - border: 1px solid rgba(255, 215, 0, 0.3)
          - border-radius: 12px
          - padding: 12px 8px
          - backdrop-filter: blur(10px)
          icon:
          - color: gold
          - width: 22px
          name:
          - font-size: 12px
          - font-weight: 600
          - color: rgba(255, 255, 255, 0.9)
          - margin-top: 4px
    - type: heading
      heading: 🎲 로또 랜덤 번호 생성기
      heading_style: title
    - type: custom:bubble-card
      card_type: button
      button_type: state
      entity: input_text.lotto_6_numbers
      scrolling_effect: false
      name: 로또 번호 생성기
      show_icon: true
      icon: mdi:dice-multiple-outline
      tap_action:
        action: more-info
        entity: switch.roddo_beonho_6gae_saengseonggi
      double_tap_action:
        action: more-info
        entity: switch.roddo_beonho_6gae_saengseonggi
      hold_action:
        action: more-info
        entity: switch.roddo_beonho_6gae_saengseonggi
      button_action:
        tap_action:
          action: more-info
          entity: switch.roddo_beonho_6gae_saengseonggi
        double_tap_action:
          action: more-info
          entity: switch.roddo_beonho_6gae_saengseonggi
        hold_action:
          action: more-info
          entity: switch.roddo_beonho_6gae_saengseonggi
      sub_button:
        main: []
        bottom: []
      grid_options:
        columns: 6
        rows: auto
    - type: markdown
      content: |-
        생성된 번호는 " {{ states('input_text.lotto_6_numbers') }} " 입니다
        해당 번호는 3분뒤에 삭제 됩니다. 해당 번호를 다시 보실거면 텔레그램 채팅을 확인하세요.
    - type: custom:button-card
      name: 💳 예치금 충전
      icon: mdi:cash-plus
      show_state: false
      tap_action:
        action: url
        url_path: https://www.dhlottery.co.kr/mypage/mndpChrg
      styles:
        card:
        - background: rgba(255, 255, 255, 0.05)
        - border: 1px solid rgba(255, 215, 0, 0.3)
        - border-radius: 12px
        - padding: 10px
        - backdrop-filter: blur(10px)
        icon:
        - color: gold
        - width: 22px
        name:
        - font-size: 13px
        - font-weight: 600
        - color: rgba(255, 255, 255, 0.9)
        grid:
        - grid-template-areas: '"i n"'
        - grid-template-columns: min-content 1fr
        - gap: 8px

생성되는 센서

애드온을 시작하면 다음 센서들이 자동으로 생성됩니다.

계정 정보 센서

동행복권 예치금

  • 센서 ID: sensor.dhlotto_{username}_lotto45_balance
  • 단위: KRW
  • 추가 속성:
    • purchase_available: 구매 가능 금액
    • reservation_purchase: 예약 구매 금액
    • withdrawal_request: 출금 신청 중 금액
    • this_month_accumulated: 이번 달 누적 구매 금액
로또 당첨 결과 센서

기본 정보

  • sensor.dhlotto_{username}_lotto645_round — 최신 회차
  • sensor.dhlotto_{username}_lotto645_draw_date — 추첨일 (YYYY-MM-DD)
  • sensor.dhlotto_{username}_lotto645_winning_numbers — 전체 당첨번호

당첨번호 (개별)

  • sensor.dhlotto_{username}_lotto645_number1 ~ number6
  • sensor.dhlotto_{username}_lotto645_bonus
상금 및 당첨자 정보 센서

총 판매액

  • sensor.dhlotto_{username}_lotto645_total_sales (KRW)

등수별 정보

각 등수마다 상금과 당첨자 센서가 생성됩니다:

  • 1등: first_prize, first_winners
  • 2등: second_prize, second_winners
  • 3등: third_prize, third_winners
  • 4등: fourth_prize, fourth_winners
  • 5등: fifth_prize, fifth_winners
  • 전체: total_winners
번호 통계 분석 센서
  • sensor.dhlotto_{username}_lotto45_top_frequency_number — 최다 출현 번호 (최근 50회차)
  • sensor.dhlotto_{username}_lotto45_hot_numbers — 핫 넘버 (최근 20회차 상위 10개)
  • sensor.dhlotto_{username}_lotto45_cold_numbers — 콜드 넘버 (최근 20회차 하위 10개)
  • sensor.dhlotto_{username}_lotto45_total_winning — 총 당첨금 (최근 1년, KRW)

total_winning 추가 속성

  • total_purchase: 총 구매 금액
  • total_purchase_count: 총 구매 횟수
  • total_winning_count: 총 당첨 횟수
  • win_rate: 당첨률 (%)
  • roi: 수익률 (%)
  • rank_distribution: 등수별 당첨 횟수
구매 내역 센서
  • sensor.dhlotto_{username}_lotto45_latest_purchase — 가장 최근 구매 정보
  • sensor.dhlotto_{username}_lotto45_purchase_history_count — 구매 기록 수 (최근 1주)
  • sensor.dhlotto_{username}_lotto45_game_1 ~ game_5 — 구매한 게임별 번호

연금복권720+ 구매 내역 (v2.5.0)

로또와 같은 기준으로 현재(판매 중인 회차) 와 이전(추첨 완료 회차) 을 나눕니다.

  • sensor.dhlotto_{username}_pension720_game_1 ~ game_5 — 현재 회차 구매 1~5매 (예: 1조 486449)
  • sensor.dhlotto_{username}_pension720_prev_game_1 ~ prev_game_5 — 이전 회차 구매 1~5매와 결과
  • sensor.dhlotto_{username}_pension720_this_round — 현재 회차 구매 매수 (속성 games 에 전체 목록)
  • sensor.dhlotto_{username}_pension720_last_round — 이전 회차 구매 매수 (속성 games, win_count, total_win_amount, result_summary)

pension720_game_* / prev_game_* 추가 속성: round_no, group, number, result, rank, win_amount, color, total_in_round 한 회차에 5매를 넘게 사면 앞의 5매만 개별 센서로 나오고, 전체는 this_round/last_round 의 games 속성에 있습니다. 구매 직후 바로 갱신됩니다.

latest_purchase 추가 속성

round_no, barcode, result, games, games_count

game_* 추가 속성

slot(A~E), mode(자동/수동/반자동), numbers, round_no, result

시스템 센서
  • sensor.dhlotto_{username}_lotto45_last_update — 마지막 업데이트 시간

버튼 엔티티

MQTT Discovery를 활성화하면 자동 구매 버튼이 생성됩니다.

  • button.dhlotto_{username}_buy_auto_1 — 1게임 자동 구매
  • button.dhlotto_{username}_buy_auto_5 — 5게임 자동 구매 (주간 최대)

사용 시 자동 체크

  • 구매 가능 시간: 평일·일 06:00–24:00, 토 06:00–20:00
  • 주간 한도: 1계정당 최대 5게임 (5,000원)
  • 다중 계정 간격: 다른 계정 구매 및 조회 완료 후 20초 경과 필수
  • 예치금: 게임당 1,000원

REST API

포트 60099 로 접근 가능합니다.

Base URL: http://homeassistant.local:60099

조회 (GET)

  • /health — 상태 확인 (계정 상태, 최대 계정 수, 주간 한도, 계정 간 쿨다운 정책 포함). 계정은 Account_N 으로 표시
  • /accounts — 등록된 계정 목록 및 로그인 상태 (Account_N 표시)
  • /api/dashboard, POST /api/purchase — 사이드바 대시보드 전용 (HA Ingress 경유만 허용)
  • /api/ingress — Home Assistant Ingress 경유 여부

Swagger UI

  • 외부 직접 접근: http://homeassistant.local:60099/docs
  • HA Ingress 경로: /api-docs

문제 해결

증상 해결
로그인 실패 동행복권 웹에서 직접 로그인 테스트 → 5회 실패 시 잠금. 잠시 대기 후 재시도. 2차 인증(OTP) 계정은 미지원.
다중 계정 구매 차단 다른 계정 구매 및 조회 완료 후 20초가 지나야 다음 계정 구매가 가능합니다. HA 자동화에서 액션 간 delay: "00:00:30" 이상을 추가하세요.
5번째 이상 계정 미로드 보안 정책상 최대 4계정까지만 지원합니다.
센서 미갱신 갱신 주기는 1시간 고정. homeassistant.update_entity 서비스로 수동 호출.
MQTT 센서 미생성 Mosquitto broker 실행 여부, MQTT 통합 추가 여부 확인. 아이디를 직접 넣었다면 계정·비밀번호 확인(비워 두면 자동). 로그의 MQTT connected 확인 후 재시작.
구매 실패 시간 / 예치금 / 주간 5게임 한도 / Log 탭 에러 메시지 확인.
포트 충돌 60099 점유 애드온 확인.

참고 사항

  • 구매 가능 시간: 평일·일 06:00–24:00, 토 06:00–20:00
  • 주간 한도: 1계정당 최대 5게임 (5,000원)
  • 최대 계정 수: 최대 4계정
  • 다중 계정 구매 간격: 계정 간 최소 20초 (동시 구매 불가)
  • 게임당 비용: 1,000원
  • 기본 갱신 주기: 3600초 (1시간, 최소 1800초 + 랜덤 지연 적용)
  • 연금복권 1일 상한선: 1계정당 최대 5매 (5,000원, 오구매 방지)
  • 수동 갱신: Developer Tools → Services → homeassistant.update_entity
  • 보안: 100% 로컬 실행, 외부 서버 미전송, 로그 아이디 마스킹, HTTPS 통신

☕ 후원

이 애드온이 도움이 되셨다면 따뜻한 커피 한 잔으로 응원해 주세요 🙏

토스 (Toss)
Toss 후원 QR
1000-1261-7813 (우*만)
PayPal
PayPal 후원 QR

지원 / 문의


라이선스

MIT License — LICENSE


면책 조항

Warning

사용 전 필수 확인 본 애드온은 동행복권과 무관한 비공식 개인 오픈소스 프로젝트입니다. 모든 통신은 사용자의 Home Assistant 로컬 환경에서 직접 이루어지며 외부 서버로 데이터를 전송하거나 중계하지 않습니다. 동행복권 이용약관 위반 소지 및 사용 중 발생하는 계정 정지, 오구매, 금전적 손실 등 모든 책임은 사용자 본인에게 있습니다.

  1. 비공식 오픈소스 프로젝트: 본 프로젝트는 주식회사 동행복권 및 복권위원회와 어떠한 공식적인 제휴·후원·승인 관계도 없는 개인 학습 및 편의 목적의 비공식 오픈소스 프로젝트입니다.
  2. 로컬 실행 및 개인정보 보호: 모든 로그인, 조회, 구매 요청은 사용자 본인의 로컬 Home Assistant 환경에서 동행복권 서버로 직접 통신합니다. 개발자는 사용자의 계정 정보, 비밀번호, 구매 내역 등 어떠한 데이터도 수집·저장·중계하지 않습니다.
  3. 이용약관 및 법적 책임: 동행복권은 공식 외부 API를 제공하지 않으며, 자동화 도구 사용은 동행복권 이용약관에 위배될 소지가 있습니다. 본 애드온의 설치 및 사용으로 인해 발생할 수 있는 계정 정지, 서비스 이용 제한, 오구매, 중복 구매, 당첨 확인 오류, 금전적 손실 등 모든 직·간접적 결과에 대한 책임은 전적으로 사용자 본인에게 있습니다.
  4. 건전한 이용 및 상업적 악용 금지: 본 애드온은 오프라인 복권 판매점과의 상생 및 사행성 방지를 위해 1계정당 주간 5게임(5,000원) 제한, 최대 4계정 제한, 계정 간 20초 구매 간격 제한을 두고 있습니다. 본 소스코드를 타인의 복권 구매 대행, 영리 목적의 유료 판매, 한도 우회 또는 서버에 과도한 부하를 주는 용도로 변조·악용하는 행위를 엄격히 금지하며, 이로 인한 모든 법적 책임은 행위자 본인에게 있습니다.
  5. 무보증(AS-IS) 및 중단 안내: 본 소프트웨어는 MIT 라이선스에 따라 어떠한 명시적·묵시적 보증 없이 "있는 그대로(AS-IS)" 제공됩니다. 동행복권 사이트의 구조 변경으로 인해 기능이 예고 없이 동작하지 않을 수 있으며, 동행복권 또는 관계 기관의 요청이 있을 경우 사전 예고 없이 배포 및 유지보수가 즉시 중단될 수 있습니다.

기여

  1. Fork
  2. Feature 브랜치 생성 (git checkout -b feature/AmazingFeature)
  3. 커밋 (git commit -m 'Add some AmazingFeature')
  4. Push (git push origin feature/AmazingFeature)
  5. Pull Request 생성

Made with ❤️ for Home Assistant Community

About

Home Assistant app for Korea's DH Lottery (Lotto 6/45): auto purchase, winning results, statistics and sensors.

Topics

Resources

Stars

4 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages