def test_pins_version_on_creation(self): pw = Powerwall(ENDPOINT, pin_version="1.49.0") self.assertEqual(pw.get_pinned_version(), version.LooseVersion("1.49.0")) pw = Powerwall(ENDPOINT, pin_version=version.LooseVersion("1.49.0")) self.assertEqual(pw.get_pinned_version(), version.LooseVersion("1.49.0"))
def main(): pp = pprint.PrettyPrinter(indent=2) creds = get_login_credentials() power_wall = Powerwall(POWERWALL_HOST) try: power_wall.detect_and_pin_version() except PowerwallUnreachableError as e: print(e) return print("Detected and pinned version: {}".format( power_wall.get_pinned_version())) _ = power_wall.login(creds["password"]) print("Current charge: {}".format(power_wall.get_charge())) print("Device Type: {}".format(power_wall.get_device_type())) print(f"Authenticated: {power_wall.get_api().is_authenticated()}") print(f"Sitemaster: {power_wall.get_sitemaster()}") print(f"Grid status: {power_wall.get_grid_status()}") print(f"Grid service activer: {power_wall.is_grid_services_active()}") site_info = power_wall.get_site_info() print(f"Site info: {pp.pformat(site_info.response)}") status = power_wall.get_status() print(f"Status: {pp.pformat(status.response)}") print(f"Device type: {power_wall.get_device_type()}") print(f"Serial numbers: {power_wall.get_serial_numbers()}") print(f"Version: {power_wall.get_version()}") # # XXX These methods need auth: print(f"Operation mode: {power_wall.get_operation_mode()}") # print(f"Backup reserved pct: {power_wall.get_backup_reserved_percentage()}") print(f"Solars: {power_wall.get_solars()}") print(f"VIN: {power_wall.get_vin()}") meters = power_wall.get_meters() # print(f"Meters: {pp.pformat(meters.response)}") for meter_type in MeterType: meter = meters.get_meter(meter_type) print(f"Meter: {meter_type}") print(f" Energy exported: {meter.energy_exported}") print(f" Energy imported: {meter.energy_imported}") print(f" Instant power: {meter.instant_power}") print(f" meter info: {pp.pformat(meter)}") # print(f" Instant reactive power: {meter.instant_reactive_power}") # print(f" Instant apparent power: {meter.instant_apparent_power}") # print(f" Instant average voltage: {meter.instant_average_voltage}") # print(f" Instant total current: {meter.instant_total_current}") # print(f" Is Active: {meter.is_active()}") # print(f" Is drawing from: {meter.is_drawing_from()}") # print(f" Is sending to: {meter.is_sending_to()}") return
def main(): pp = pprint.PrettyPrinter(indent=2) creds = get_login_credentials() power_wall = Powerwall(BACKUP_GW_ADDR) try: power_wall.detect_and_pin_version() except PowerwallUnreachableError as e: print(e) return print("Detected and pinned version: {}".format( power_wall.get_pinned_version()))
write_api = client.write_api(write_options=SYNCHRONOUS) # Powerwall ip = os.getenv("POWERWALL_IP") if ip is None: raise ValueError("POWERWALL_IP must be set") email = os.getenv("POWERWALL_EMAIL") password = os.getenv("POWERWALL_PASSWORD") power_wall = Powerwall(ip) # Program # Identify the powerwall version power_wall.detect_and_pin_version() print("Detected and pinned version: {}".format( power_wall.get_pinned_version())) print("Current charge: {}".format(power_wall.get_charge())) print("Device Type: {}".format(power_wall.get_device_type())) # Sending Data while True: p = influxdb_client.Point("Measurement").field("Charge", power_wall.get_charge) write_api.write(bucket=bucket, org=org, record=p) sleep(1)