#!/usr/bin/env python3 """Get current entity IDs after upgrade""" import urllib.request import json import sys TOKEN = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiI4NmM2ZGNlMTY2MWU0M2U5YjQ2MDI3MjMxYjE0NDFlMyIsImlhdCI6MTc2NzE3ODUyNiwiZXhwIjoyMDgyNTM4NTI2fQ.E8eShOsejwDYglixpgM_d_JYBlB1OVNhN7cHPnPiLOs" HA_URL = "http://192.168.68.25:8123" def get_entities(): """Get all entities and filter for dashboard-relevant ones""" url = f"{HA_URL}/api/states" req = urllib.request.Request(url) req.add_header("Authorization", f"Bearer {TOKEN}") try: with urllib.request.urlopen(req) as response: states = json.loads(response.read().decode()) print("="*60) print("CURRENT ENTITIES (After Upgrade)") print("="*60) print() # Weather entities print("WEATHER:") weather = [e for e in states if 'weather' in e['entity_id'].lower()] for e in weather: print(f" {e['entity_id']}: {e.get('attributes', {}).get('friendly_name', 'N/A')}") print() # Sun entities print("SUN:") sun = [e for e in states if e['entity_id'].startswith('sun.') or 'sun_' in e['entity_id']] for e in sun: print(f" {e['entity_id']}: {e.get('state', 'N/A')}") print() # Public transport print("PUBLIC TRANSPORT:") transport = [e for e in states if any(x in e['entity_id'].lower() for x in ['roslagsbanan', 'sl_departure', 'next_departure'])] for e in transport: print(f" {e['entity_id']}: {e.get('attributes', {}).get('friendly_name', 'N/A')}") print() # Camera motion print("CAMERA MOTION:") motion = [e for e in states if 'motion' in e['entity_id'].lower() and 'binary_sensor' in e['entity_id']] for e in motion: print(f" {e['entity_id']}: {e.get('attributes', {}).get('friendly_name', 'N/A')}") print() # Occupancy/Person count print("OCCUPANCY / PERSON COUNT:") occupancy = [e for e in states if any(x in e['entity_id'].lower() for x in ['person_count', 'occupancy', 'people'])] for e in occupancy: print(f" {e['entity_id']}: {e.get('attributes', {}).get('friendly_name', 'N/A')}") print() # Network print("NETWORK:") network = [e for e in states if any(x in e['entity_id'].lower() for x in ['xe75', 'download_speed', 'upload_speed', 'external_ip', 'wan_status'])] for e in network: print(f" {e['entity_id']}: {e.get('attributes', {}).get('friendly_name', 'N/A')}") print() # All entities for reference print("="*60) print("ALL ENTITY IDs (for reference):") print("="*60) for entity in sorted(states, key=lambda x: x.get('entity_id', '')): print(entity.get('entity_id')) return states except Exception as e: print(f"Error: {e}", file=sys.stderr) return None if __name__ == '__main__': get_entities()