Building Self-Sufficiency System with Home Assistant

Hello! I’m bunkergardenlabs, working on building a self-sufficiency system with Home Assistant.

Project Overview: I’m working on a project that aims for complete self-sufficient living based on solar power, with all systems integrated and controlled through Home Assistant.

Current Progress:

Phase 1: Converted refrigerator → Smart plant growing chamber (ESPHome + relay control)

Phase 2: Home Assistant API → TouchDesigner real-time integration success! Implemented visualization where sensor data transforms into colors and shapes

Final Goal: Complete independent living with solar power + plant cultivation + water purification systems

:clapper: Process Documentation: I’m recording this entire process as a documentary film series. This is not a step-by-step tutorial!

1 Like

:floppy_disk: For those who might need it, I’ll share the TouchDesigner API integration code!

import requests
import time

# Reference to existing table - use existing table if available
table_ref = op('sensor_data')  # Change to your existing table name

# Completely reset table structure (adding CO2)
table_ref.clear()
table_ref.appendRow(['Temperature', '0'])
table_ref.appendRow(['Humidity', '0'])
table_ref.appendRow(['CO2', '0'])  # 🔥 Add CO2 row

# Home Assistant Configuration
HA_URL = " "  # Your actual Home Assistant URL
TOKEN = " "  # Your token
TEMP_ENTITY_ID = " "  # Temperature sensor
HUMID_ENTITY_ID = " "  # Humidity sensor
CO2_ENTITY_ID = " "  # 🔥 Add CO2 sensor

# API request headers
headers = {
    "Authorization": f"Bearer {TOKEN}",
    "Content-Type": "application/json"
}

def update_sensor_data():
    try:
        # Fetch temperature sensor data
        temp_response = requests.get(f"{HA_URL}/api/states/{TEMP_ENTITY_ID}", 
                              headers=headers, 
                              verify=False, 
                              timeout=10)
        
        # Fetch humidity sensor data
        humid_response = requests.get(f"{HA_URL}/api/states/{HUMID_ENTITY_ID}", 
                              headers=headers, 
                              verify=False, 
                              timeout=10)
        
        # 🔥 Fetch CO2 sensor data
        co2_response = requests.get(f"{HA_URL}/api/states/{CO2_ENTITY_ID}", 
                              headers=headers, 
                              verify=False, 
                              timeout=10)
        
        # Update temperature data
        if temp_response.status_code == 200:
            temp_data = temp_response.json()
            table_ref[0, 1] = temp_data.get('state', '0')
            print(f"Temperature updated: {temp_data.get('state')}°C")
        
        # Update humidity data
        if humid_response.status_code == 200:
            humid_data = humid_response.json()
            table_ref[1, 1] = humid_data.get('state', '0')
            print(f"Humidity updated: {humid_data.get('state')}%")
        
        # 🔥 Update CO2 data
        if co2_response.status_code == 200:
            co2_data = co2_response.json()
            table_ref[2, 1] = co2_data.get('state', '0')
            print(f"CO2 updated: {co2_data.get('state')}ppm")
            
    except Exception as e:
        print(f"Error occurred: {e}")
    
    # Update every 3 seconds
    run("update_sensor_data()", delayMilliSeconds=3000, fromOP=me)

# Initial execution
update_sensor_data()

Raspberry Pi Pico W 코드

switch:
  - platform: gpio
    pin: 21
    name: "Relay 1 (CH1)"
  - platform: gpio
    pin: 20
    name: "Relay 2 (CH2)"
  - platform: gpio
    pin: 19
    name: "Relay 3 (CH3)"
  - platform: gpio
    pin: 18
    name: "Relay 4 (CH4)"
  - platform: gpio
    pin: 17
    name: "Relay 5 (CH5)"
  - platform: gpio
    pin: 16
    name: "Relay 6 (CH6)"
  - platform: gpio
    pin: 15
    name: "Relay 7 (CH7)"
  - platform: gpio
    pin: 14
    name: "Relay 8 (CH8)"
1 Like