Photoshop-Cafe.de :: Dein Photoshop-Forum

Energyclient Updated -

def fetch_latest(self): resp = self.session.get(f"self.api_root/meters/self.meter_id/reading") resp.raise_for_status() data = resp.json() # Cache it self.conn.execute( "INSERT OR REPLACE INTO readings (ts, power_w, cumulative_wh) VALUES (?, ?, ?)", (datetime.now(timezone.utc).isoformat(), data["power_w"], data["cumulative_wh"]) ) self.conn.commit() return data

def __post_init__(self): self._init_db() self.session = requests.Session() self.session.headers.update("Authorization": f"Bearer self.token")

def control_load(self, state: bool): """Turn load on/off (demand response)""" resp = self.session.post( f"self.api_root/meters/self.meter_id/control", json="load_control": state ) return resp.status_code == 200

def close(self): self.conn.close() | Problem | Strategy | |---------|----------| | Network failure | Retry with backoff (3–5 attempts) | | Rate limiting | Parse Retry-After header, queue commands | | Invalid token | Re‑authenticate automatically once | | Data gaps | Interpolate or flag missing samples | | Meter offline | Cache commands; apply when reconnected |

import requests import sqlite3 import time from dataclasses import dataclass from datetime import datetime, timezone @dataclass class EnergyClient: api_root: str meter_id: str token: str

"timestamp": "2025-03-15T10:00:00Z", "device_id": "meter_001", "measurements": "power_w": 1243.5, "energy_wh_cumulative": 1203400, "voltage_v": 239.2, "current_a": 5.2, "frequency_hz": 50.02 , "tariff": "off_peak"

def _init_db(self): self.conn = sqlite3.connect("energy_cache.db") self.conn.execute(""" CREATE TABLE IF NOT EXISTS readings ( ts TEXT PRIMARY KEY, power_w REAL, cumulative_wh REAL ) """)

def fetch_latest(self): resp = self.session.get(f"self.api_root/meters/self.meter_id/reading") resp.raise_for_status() data = resp.json() # Cache it self.conn.execute( "INSERT OR REPLACE INTO readings (ts, power_w, cumulative_wh) VALUES (?, ?, ?)", (datetime.now(timezone.utc).isoformat(), data["power_w"], data["cumulative_wh"]) ) self.conn.commit() return data

def __post_init__(self): self._init_db() self.session = requests.Session() self.session.headers.update("Authorization": f"Bearer self.token")

def control_load(self, state: bool): """Turn load on/off (demand response)""" resp = self.session.post( f"self.api_root/meters/self.meter_id/control", json="load_control": state ) return resp.status_code == 200

def close(self): self.conn.close() | Problem | Strategy | |---------|----------| | Network failure | Retry with backoff (3–5 attempts) | | Rate limiting | Parse Retry-After header, queue commands | | Invalid token | Re‑authenticate automatically once | | Data gaps | Interpolate or flag missing samples | | Meter offline | Cache commands; apply when reconnected |

import requests import sqlite3 import time from dataclasses import dataclass from datetime import datetime, timezone @dataclass class EnergyClient: api_root: str meter_id: str token: str

"timestamp": "2025-03-15T10:00:00Z", "device_id": "meter_001", "measurements": "power_w": 1243.5, "energy_wh_cumulative": 1203400, "voltage_v": 239.2, "current_a": 5.2, "frequency_hz": 50.02 , "tariff": "off_peak"

def _init_db(self): self.conn = sqlite3.connect("energy_cache.db") self.conn.execute(""" CREATE TABLE IF NOT EXISTS readings ( ts TEXT PRIMARY KEY, power_w REAL, cumulative_wh REAL ) """)

 

Stichworte
absturz, photoshop cc 2015.5

Lesezeichen
Themen-Optionen

energyclient Forumregeln
Es ist Ihnen nicht erlaubt, neue Themen zu verfassen.
Es ist Ihnen nicht erlaubt, auf Beiträge zu antworten.
Es ist Ihnen nicht erlaubt, Anhänge hochzuladen.
Es ist Ihnen nicht erlaubt, Ihre Beiträge zu bearbeiten.

BB-Code ist An.
Smileys sind An.
[IMG] Code ist An.
HTML-Code ist Aus.

Gehe zu

energyclient Ähnliche Themen
Thema Autor Forum Antworten Letzter Beitrag
Photoshop Freistellungswerkzeug funktioniert nicht mehr? Millenotti Hilfestellung, Tipps und Tricks 8 05.04.16 00:08
Photoshop Freistellen funktioniert nicht mehr IreneM Hilfestellung, Tipps und Tricks 9 01.12.15 09:34
Photoshop Elements Photoshop Elements 12: Organizer funktioniert nicht mehr pimpl Hilfestellung, Tipps und Tricks 10 10.03.15 01:07
Zusammenziehwerkzeug funktioniert nicht mehr Jaz Hilfestellung, Tipps und Tricks 1 26.06.12 17:31


Alle Zeitangaben in WEZ +2. Es ist jetzt 03:23 Uhr.

energyclient

Impressum

Kontakt      Photoshop-Cafe      Archiv     Impressum     Nach oben

Powered by vBulletin® Version 3.8.7 (Deutsch)
Copyright ©2000 - 2026, Jelsoft Enterprises Ltd.
©2005-2024 photoshop-cafe.de

Seite wurde generiert in 0,11315 Sekunden mit 9 Queries