From e1e6c2129e500485a6ee54479bdcd7f279ea372d Mon Sep 17 00:00:00 2001 From: Georg Ledermann Date: Sat, 11 Jan 2025 07:14:06 +0100 Subject: [PATCH] Cloud: Add support for Dashboard v2 --- README.md | 33 +++- lib/senec/cloud/dashboard.rb | 35 ++-- spec/lib/senec/cloud/dashboard_spec.rb | 136 ++++++++----- .../cloud/fetch-dashboard-invalid-system.yml | 8 +- ... => fetch-dashboard-v1-default-system.yml} | 18 +- ...=> fetch-dashboard-v1-specific-system.yml} | 10 +- .../fetch-dashboard-v2-default-system.yml | 179 ++++++++++++++++++ .../fetch-dashboard-v2-specific-system.yml | 91 +++++++++ 8 files changed, 429 insertions(+), 81 deletions(-) rename spec/support/cassettes/cloud/{fetch-dashboard-default-system.yml => fetch-dashboard-v1-default-system.yml} (78%) rename spec/support/cassettes/cloud/{fetch-dashboard-specific-system.yml => fetch-dashboard-v1-specific-system.yml} (66%) create mode 100644 spec/support/cassettes/cloud/fetch-dashboard-v2-default-system.yml create mode 100644 spec/support/cassettes/cloud/fetch-dashboard-v2-specific-system.yml diff --git a/README.md b/README.md index 0e20917..68d23ec 100644 --- a/README.md +++ b/README.md @@ -69,14 +69,43 @@ puts Senec::Cloud::Dashboard[connection].find("123456").data # {"stromerzeugung"=>{"wert"=>0.01, "einheit"=>"W"}, # .... -# Get the Technical Data of a specific system (by ID): +# Dashboard data can be requested in different versions, v1 and v2 are available, v1 is the default. +# To request the data in version 2, pass the version parameter to the `data` method: +puts Senec::Cloud::Dashboard[connection].first.data(version: 'v2') + +# => { +# 'currently' => { +# 'powerGenerationInW' => 1.0e-05, +# 'powerConsumptionInW' => 1350.37, +# 'gridFeedInInW' => 1.0e-05, +# 'gridDrawInW' => 1321.26966059603, +# 'batteryChargeInW' => 1.0e-05, +# 'batteryDischargeInW' => 11.6411423841, +# 'batteryLevelInPercent' => 1.0e-05, +# 'selfSufficiencyInPercent' => 2.16, +# 'wallboxInW' => 1.0e-05 +# }, +# 'today' => { +# 'powerGenerationInWh' => 3.90625, +# 'powerConsumptionInWh' => 9119.14, +# 'gridFeedInInWh' => 0.0, +# 'gridDrawInWh' => 9011.71875, +# 'batteryChargeInWh' => 0.0, +# 'batteryDischargeInWh' => 107.421875, +# 'batteryLevelInPercent' => 1.0e-05, +# 'selfSufficiencyInPercent' => 1.18, +# 'wallboxInWh' => 0.0 +# }, +# 'timestamp' => '2025-01-11T06:45:09Z', +# 'electricVehicleConnected' => false +# } +# Get the Technical Data of a specific system (by ID): puts Senec::Cloud::TechnicalData[connection].find("123456").data # => {"systemOverview"=>{"systemId"=>123456, "productName"=>"SENEC.Home V3 hybrid duo", ... # Get the Technical Data of first systems (without knowing the ID): - puts Senec::Cloud::TechnicalData[connection].first.data # => {"systemOverview"=>{"systemId"=>123456, "productName"=>"SENEC.Home V3 hybrid duo", ... diff --git a/lib/senec/cloud/dashboard.rb b/lib/senec/cloud/dashboard.rb index 255e251..59cb96d 100644 --- a/lib/senec/cloud/dashboard.rb +++ b/lib/senec/cloud/dashboard.rb @@ -7,14 +7,23 @@ # connection = Senec::Cloud::Connection.new(username: '...', password: '...') # # # Get the data of a specific system: -# Dashboard[connection].find('123456') +# Dashboard[connection].find('123456').data # # # Get the data of the default system: -# Dashboard[connection].first +# Dashboard[connection].first.data +# +# By default, it returns v1 data. To get v2 data, use: +# +# Dashboard[connection].find('123456').data(version: 'v2') +# or +# Dashboard[connection].first.data(version: 'v2') # module Senec module Cloud class Dashboard + AVAILABLE_VERSIONS = %w[v1 v2].freeze + DEFAULT_VERSION = 'v1'.freeze + class Finder def initialize(connection) @connection = connection @@ -22,7 +31,7 @@ def initialize(connection) attr_reader :connection def find(system_id) - Dashboard.new(connection:, system_id:).tap(&:load_data) + Dashboard.new(connection:, system_id:) end def first @@ -41,17 +50,18 @@ def initialize(connection: nil, system_id: nil, data: nil) @system_id = system_id # Useful for testing only - @data = data + @data = { + 'v1' => data, + 'v2' => data + } end - def load_data - raise 'Data already present!' if @data - - @system_id ||= connection.default_system_id - @data = fetch_data + def data(version: DEFAULT_VERSION) + @data ||= {} + @data[version] ||= fetch_data(version:) end - attr_reader :system_id, :data + attr_reader :system_id private @@ -59,10 +69,11 @@ def get(path, params: nil) @connection.get(path, params:) end - def fetch_data + def fetch_data(version:) + raise ArgumentError unless AVAILABLE_VERSIONS.include?(version) return unless system_id - get("/v1/senec/systems/#{system_id}/dashboard") + get("/#{version}/senec/systems/#{system_id}/dashboard") end end end diff --git a/spec/lib/senec/cloud/dashboard_spec.rb b/spec/lib/senec/cloud/dashboard_spec.rb index 0d91dfd..eb29b81 100644 --- a/spec/lib/senec/cloud/dashboard_spec.rb +++ b/spec/lib/senec/cloud/dashboard_spec.rb @@ -8,58 +8,23 @@ ) end - describe '#initialize' do - it 'sets the connection' do - dashboard = described_class.new(connection:) - expect(dashboard.instance_variable_get(:@connection)).to eq(connection) - end - - it 'sets the data' do - dashboard = described_class.new(data: { foo: 42 }) - expect(dashboard.data).to eq(foo: 42) - end - - it 'fails without connection or data' do - expect { described_class.new }.to raise_error(ArgumentError) - end - - it 'fails when both connection and data given' do - expect do - described_class.new(connection:, data: { foo: 42 }) - end.to raise_error(ArgumentError) - end - - it 'fails when using loaddata after setting data' do - dashboard = described_class.new(data: { foo: 42 }) - - expect { dashboard.load_data }.to raise_error( - RuntimeError, - 'Data already present!', - ) - end - end - describe 'Finder' do - describe '#first', vcr: 'cloud/fetch-dashboard-default-system' do + describe '#first' do subject(:dashboard) { finder.first } - it 'returns a Dashboard instance' do + it 'returns a Dashboard instance', vcr: 'cloud/fetch-dashboard-v1-default-system' do expect(dashboard).to be_a(described_class) end - it 'uses the default_system_id' do + it 'uses the default_system_id', vcr: 'cloud/fetch-dashboard-v1-default-system' do expect(dashboard.system_id).to eq(connection.default_system_id) end - - it 'fetches the data' do - expect(dashboard.data).to include('aktuell', 'heute') - end end - describe '#find', vcr: 'cloud/fetch-dashboard-specific-system' do + describe '#find' do subject(:dashboard) { finder.find(system_id) } - context 'with VALID system_id', vcr: 'cloud/fetch-dashboard-specific-system' do + context 'with VALID system_id' do let(:system_id) { ENV.fetch('SENEC_SYSTEM_ID') } it 'returns a Dashboard instance' do @@ -69,32 +34,105 @@ it 'uses the provided system_id' do expect(dashboard.system_id).to eq(system_id) end + end + + context 'with INVALID system_id', vcr: 'cloud/fetch-dashboard-invalid-system' do + let(:system_id) { 123_456 } + + it 'fails' do + expect { dashboard.data }.to raise_error(Senec::Cloud::Error, 'Error 401') + end + end + end + + describe '#initialize' do + it 'sets the connection' do + dashboard = described_class.new(connection:) + expect(dashboard.instance_variable_get(:@connection)).to eq(connection) + end + + it 'sets the data' do + dashboard = described_class.new(data: { foo: 42 }) + expect(dashboard.data).to eq(foo: 42) + end + + it 'fails without connection or data' do + expect { described_class.new }.to raise_error(ArgumentError) + end + + it 'fails when both connection and data given' do + expect do + described_class.new(connection:, data: { foo: 42 }) + end.to raise_error(ArgumentError) + end + end + + describe '#data' do + let(:dashboard) { finder.first } + + context 'with default version of 1', vcr: 'cloud/fetch-dashboard-v1-default-system' do + subject(:data) { dashboard.data } it 'fetches the data' do - expect(dashboard.data).to include('aktuell', 'heute') + expect(data).to include('aktuell', 'heute') end it 'fetches data with keys' do expected_keys = %w[ - stromerzeugung stromverbrauch - netzeinspeisung netzbezug - speicherbeladung speicherentnahme + stromerzeugung + stromverbrauch + netzeinspeisung + netzbezug + speicherbeladung + speicherentnahme speicherfuellstand autarkie wallbox ] %w[aktuell heute].each do |key| - expect(dashboard.data[key].keys).to match_array(expected_keys) + expect(data[key].keys).to match_array(expected_keys) end end end - context 'with INVALID system_id', vcr: 'cloud/fetch-dashboard-invalid-system' do - let(:system_id) { 123_456 } + context 'with version 2', vcr: 'cloud/fetch-dashboard-v2-default-system' do + subject(:data) { dashboard.data(version: 'v2') } - it 'fails' do - expect { dashboard }.to raise_error(Senec::Cloud::Error, 'Error 401') + it 'fetches the data' do + expect(data).to include('currently', 'today') + end + + it 'fetches currently data' do + expect(data['currently'].keys).to match_array( + %w[ + batteryChargeInW + batteryDischargeInW + batteryLevelInPercent + gridDrawInW + gridFeedInInW + powerConsumptionInW + powerGenerationInW + selfSufficiencyInPercent + wallboxInW + ], + ) + end + + it 'fetches today data' do + expect(data['today'].keys).to match_array( + %w[ + batteryChargeInWh + batteryDischargeInWh + batteryLevelInPercent + gridDrawInWh + gridFeedInInWh + powerConsumptionInWh + powerGenerationInWh + selfSufficiencyInPercent + wallboxInWh + ], + ) end end end diff --git a/spec/support/cassettes/cloud/fetch-dashboard-invalid-system.yml b/spec/support/cassettes/cloud/fetch-dashboard-invalid-system.yml index 5ef9e31..295cf0b 100644 --- a/spec/support/cassettes/cloud/fetch-dashboard-invalid-system.yml +++ b/spec/support/cassettes/cloud/fetch-dashboard-invalid-system.yml @@ -17,7 +17,7 @@ http_interactions: message: '' headers: date: - - Sat, 11 Jan 2025 06:11:13 GMT + - Sat, 11 Jan 2025 06:15:56 GMT content-type: - application/json transfer-encoding: @@ -43,7 +43,7 @@ http_interactions: body: encoding: UTF-8 string: '{"token":"","refreshToken":""}' - recorded_at: Sat, 11 Jan 2025 06:11:13 GMT + recorded_at: Sat, 11 Jan 2025 06:15:56 GMT - request: method: get uri: https://app-gateway.prod.senec.dev/v1/senec/systems/123456/dashboard @@ -61,7 +61,7 @@ http_interactions: message: '' headers: date: - - Sat, 11 Jan 2025 06:11:14 GMT + - Sat, 11 Jan 2025 06:15:56 GMT content-type: - text/plain;charset=UTF-8 content-length: @@ -87,5 +87,5 @@ http_interactions: body: encoding: UTF-8 string: "{}" - recorded_at: Sat, 11 Jan 2025 06:11:14 GMT + recorded_at: Sat, 11 Jan 2025 06:15:56 GMT recorded_with: VCR 6.3.1 diff --git a/spec/support/cassettes/cloud/fetch-dashboard-default-system.yml b/spec/support/cassettes/cloud/fetch-dashboard-v1-default-system.yml similarity index 78% rename from spec/support/cassettes/cloud/fetch-dashboard-default-system.yml rename to spec/support/cassettes/cloud/fetch-dashboard-v1-default-system.yml index f79bbbf..2e779ca 100644 --- a/spec/support/cassettes/cloud/fetch-dashboard-default-system.yml +++ b/spec/support/cassettes/cloud/fetch-dashboard-v1-default-system.yml @@ -17,7 +17,7 @@ http_interactions: message: '' headers: date: - - Sat, 11 Jan 2025 06:11:11 GMT + - Sat, 11 Jan 2025 06:15:51 GMT content-type: - application/json transfer-encoding: @@ -43,7 +43,7 @@ http_interactions: body: encoding: UTF-8 string: '{"token":"","refreshToken":""}' - recorded_at: Sat, 11 Jan 2025 06:11:11 GMT + recorded_at: Sat, 11 Jan 2025 06:15:51 GMT - request: method: get uri: https://app-gateway.prod.senec.dev/v1/senec/systems @@ -61,7 +61,7 @@ http_interactions: message: '' headers: date: - - Sat, 11 Jan 2025 06:11:11 GMT + - Sat, 11 Jan 2025 06:15:51 GMT content-type: - application/json transfer-encoding: @@ -87,7 +87,7 @@ http_interactions: body: encoding: UTF-8 string: '[{"id":"","steuereinheitnummer":"","gehaeusenummer":"","strasse":"","hausnummer":"","postleitzahl":"","ort":"","laendercode":"DE","zeitzone":"Europe/Berlin","wallboxIds":["1"],"systemType":"V3"}]' - recorded_at: Sat, 11 Jan 2025 06:11:11 GMT + recorded_at: Sat, 11 Jan 2025 06:15:51 GMT - request: method: get uri: https://app-gateway.prod.senec.dev/v1/senec/systems @@ -105,7 +105,7 @@ http_interactions: message: '' headers: date: - - Sat, 11 Jan 2025 06:11:11 GMT + - Sat, 11 Jan 2025 06:15:52 GMT content-type: - application/json transfer-encoding: @@ -131,7 +131,7 @@ http_interactions: body: encoding: UTF-8 string: '[{"id":"","steuereinheitnummer":"","gehaeusenummer":"","strasse":"","hausnummer":"","postleitzahl":"","ort":"","laendercode":"DE","zeitzone":"Europe/Berlin","wallboxIds":["1"],"systemType":"V3"}]' - recorded_at: Sat, 11 Jan 2025 06:11:11 GMT + recorded_at: Sat, 11 Jan 2025 06:15:52 GMT - request: method: get uri: https://app-gateway.prod.senec.dev/v1/senec/systems//dashboard @@ -149,7 +149,7 @@ http_interactions: message: '' headers: date: - - Sat, 11 Jan 2025 06:11:12 GMT + - Sat, 11 Jan 2025 06:15:53 GMT content-type: - application/json transfer-encoding: @@ -174,6 +174,6 @@ http_interactions: - DENY body: encoding: UTF-8 - string: '{"aktuell":{"stromerzeugung":{"wert":0.01,"einheit":"W"},"stromverbrauch":{"wert":1050.0,"einheit":"W"},"netzeinspeisung":{"wert":0.01,"einheit":"W"},"netzbezug":{"wert":1054.688,"einheit":"W"},"speicherbeladung":{"wert":0.01,"einheit":"W"},"speicherentnahme":{"wert":11.719,"einheit":"W"},"speicherfuellstand":{"wert":1.0e-05,"einheit":"%"},"autarkie":{"wert":1.0e-05,"einheit":"%"},"wallbox":{"wert":0.01,"einheit":"W"}},"heute":{"stromerzeugung":{"wert":3.90625,"einheit":"Wh"},"stromverbrauch":{"wert":8430.0,"einheit":"Wh"},"netzeinspeisung":{"wert":0.0,"einheit":"Wh"},"netzbezug":{"wert":8334.9609375,"einheit":"Wh"},"speicherbeladung":{"wert":0.0,"einheit":"Wh"},"speicherentnahme":{"wert":99.609375,"einheit":"Wh"},"speicherfuellstand":{"wert":0.0,"einheit":"%"},"autarkie":{"wert":1.17,"einheit":"%"},"wallbox":{"wert":0.0,"einheit":"Wh"}},"zeitstempel":"2025-01-11T06:09:57Z","electricVehicleConnected":false}' - recorded_at: Sat, 11 Jan 2025 06:11:12 GMT + string: '{"aktuell":{"stromerzeugung":{"wert":0.01,"einheit":"W"},"stromverbrauch":{"wert":1040.0,"einheit":"W"},"netzeinspeisung":{"wert":0.01,"einheit":"W"},"netzbezug":{"wert":1024.421,"einheit":"W"},"speicherbeladung":{"wert":0.01,"einheit":"W"},"speicherentnahme":{"wert":11.641,"einheit":"W"},"speicherfuellstand":{"wert":1.0e-05,"einheit":"%"},"autarkie":{"wert":2.22,"einheit":"%"},"wallbox":{"wert":0.01,"einheit":"W"}},"heute":{"stromerzeugung":{"wert":3.90625,"einheit":"Wh"},"stromverbrauch":{"wert":8520.0,"einheit":"Wh"},"netzeinspeisung":{"wert":0.0,"einheit":"Wh"},"netzbezug":{"wert":8420.8984375,"einheit":"Wh"},"speicherbeladung":{"wert":0.0,"einheit":"Wh"},"speicherentnahme":{"wert":100.5859375,"einheit":"Wh"},"speicherfuellstand":{"wert":0.0,"einheit":"%"},"autarkie":{"wert":1.18,"einheit":"%"},"wallbox":{"wert":0.0,"einheit":"Wh"}},"zeitstempel":"2025-01-11T06:14:59Z","electricVehicleConnected":false}' + recorded_at: Sat, 11 Jan 2025 06:15:53 GMT recorded_with: VCR 6.3.1 diff --git a/spec/support/cassettes/cloud/fetch-dashboard-specific-system.yml b/spec/support/cassettes/cloud/fetch-dashboard-v1-specific-system.yml similarity index 66% rename from spec/support/cassettes/cloud/fetch-dashboard-specific-system.yml rename to spec/support/cassettes/cloud/fetch-dashboard-v1-specific-system.yml index db8111e..bb057a1 100644 --- a/spec/support/cassettes/cloud/fetch-dashboard-specific-system.yml +++ b/spec/support/cassettes/cloud/fetch-dashboard-v1-specific-system.yml @@ -17,7 +17,7 @@ http_interactions: message: '' headers: date: - - Sat, 11 Jan 2025 06:11:12 GMT + - Sat, 11 Jan 2025 06:15:54 GMT content-type: - application/json transfer-encoding: @@ -43,7 +43,7 @@ http_interactions: body: encoding: UTF-8 string: '{"token":"","refreshToken":""}' - recorded_at: Sat, 11 Jan 2025 06:11:12 GMT + recorded_at: Sat, 11 Jan 2025 06:15:54 GMT - request: method: get uri: https://app-gateway.prod.senec.dev/v1/senec/systems//dashboard @@ -61,7 +61,7 @@ http_interactions: message: '' headers: date: - - Sat, 11 Jan 2025 06:11:13 GMT + - Sat, 11 Jan 2025 06:15:55 GMT content-type: - application/json transfer-encoding: @@ -86,6 +86,6 @@ http_interactions: - DENY body: encoding: UTF-8 - string: '{"aktuell":{"stromerzeugung":{"wert":0.01,"einheit":"W"},"stromverbrauch":{"wert":1050.0,"einheit":"W"},"netzeinspeisung":{"wert":0.01,"einheit":"W"},"netzbezug":{"wert":1054.688,"einheit":"W"},"speicherbeladung":{"wert":0.01,"einheit":"W"},"speicherentnahme":{"wert":11.719,"einheit":"W"},"speicherfuellstand":{"wert":1.0e-05,"einheit":"%"},"autarkie":{"wert":1.0e-05,"einheit":"%"},"wallbox":{"wert":0.01,"einheit":"W"}},"heute":{"stromerzeugung":{"wert":3.90625,"einheit":"Wh"},"stromverbrauch":{"wert":8430.0,"einheit":"Wh"},"netzeinspeisung":{"wert":0.0,"einheit":"Wh"},"netzbezug":{"wert":8334.9609375,"einheit":"Wh"},"speicherbeladung":{"wert":0.0,"einheit":"Wh"},"speicherentnahme":{"wert":99.609375,"einheit":"Wh"},"speicherfuellstand":{"wert":0.0,"einheit":"%"},"autarkie":{"wert":1.17,"einheit":"%"},"wallbox":{"wert":0.0,"einheit":"Wh"}},"zeitstempel":"2025-01-11T06:09:57Z","electricVehicleConnected":false}' - recorded_at: Sat, 11 Jan 2025 06:11:13 GMT + string: '{"aktuell":{"stromerzeugung":{"wert":0.01,"einheit":"W"},"stromverbrauch":{"wert":1040.0,"einheit":"W"},"netzeinspeisung":{"wert":0.01,"einheit":"W"},"netzbezug":{"wert":1024.421,"einheit":"W"},"speicherbeladung":{"wert":0.01,"einheit":"W"},"speicherentnahme":{"wert":11.641,"einheit":"W"},"speicherfuellstand":{"wert":1.0e-05,"einheit":"%"},"autarkie":{"wert":2.22,"einheit":"%"},"wallbox":{"wert":0.01,"einheit":"W"}},"heute":{"stromerzeugung":{"wert":3.90625,"einheit":"Wh"},"stromverbrauch":{"wert":8520.0,"einheit":"Wh"},"netzeinspeisung":{"wert":0.0,"einheit":"Wh"},"netzbezug":{"wert":8420.8984375,"einheit":"Wh"},"speicherbeladung":{"wert":0.0,"einheit":"Wh"},"speicherentnahme":{"wert":100.5859375,"einheit":"Wh"},"speicherfuellstand":{"wert":0.0,"einheit":"%"},"autarkie":{"wert":1.18,"einheit":"%"},"wallbox":{"wert":0.0,"einheit":"Wh"}},"zeitstempel":"2025-01-11T06:14:59Z","electricVehicleConnected":false}' + recorded_at: Sat, 11 Jan 2025 06:15:55 GMT recorded_with: VCR 6.3.1 diff --git a/spec/support/cassettes/cloud/fetch-dashboard-v2-default-system.yml b/spec/support/cassettes/cloud/fetch-dashboard-v2-default-system.yml new file mode 100644 index 0000000..ba59ff6 --- /dev/null +++ b/spec/support/cassettes/cloud/fetch-dashboard-v2-default-system.yml @@ -0,0 +1,179 @@ +--- +http_interactions: +- request: + method: post + uri: https://app-gateway.prod.senec.dev/v1/senec/login + body: + encoding: UTF-8 + string: '{"username":"","password":""}' + headers: + User-Agent: + - Faraday v2.12.2 + Content-Type: + - application/json + response: + status: + code: 200 + message: '' + headers: + date: + - Sat, 11 Jan 2025 06:15:53 GMT + content-type: + - application/json + transfer-encoding: + - chunked + connection: + - keep-alive + vary: + - Origin, Access-Control-Request-Method, Access-Control-Request-Headers + x-content-type-options: + - nosniff + x-xss-protection: + - 1; mode=block + cache-control: + - no-cache, no-store, max-age=0, must-revalidate + pragma: + - no-cache + expires: + - '0' + strict-transport-security: + - max-age=31536000; includeSubDomains + x-frame-options: + - DENY + body: + encoding: UTF-8 + string: '{"token":"","refreshToken":""}' + recorded_at: Sat, 11 Jan 2025 06:15:53 GMT +- request: + method: get + uri: https://app-gateway.prod.senec.dev/v1/senec/systems + body: + encoding: US-ASCII + string: '' + headers: + User-Agent: + - Faraday v2.12.2 + Authorization: + - "" + response: + status: + code: 200 + message: '' + headers: + date: + - Sat, 11 Jan 2025 06:15:53 GMT + content-type: + - application/json + transfer-encoding: + - chunked + connection: + - keep-alive + vary: + - Origin, Access-Control-Request-Method, Access-Control-Request-Headers + x-content-type-options: + - nosniff + x-xss-protection: + - 1; mode=block + cache-control: + - no-cache, no-store, max-age=0, must-revalidate + pragma: + - no-cache + expires: + - '0' + strict-transport-security: + - max-age=31536000; includeSubDomains + x-frame-options: + - DENY + body: + encoding: UTF-8 + string: '[{"id":"","steuereinheitnummer":"","gehaeusenummer":"","strasse":"","hausnummer":"","postleitzahl":"","ort":"","laendercode":"DE","zeitzone":"Europe/Berlin","wallboxIds":["1"],"systemType":"V3"}]' + recorded_at: Sat, 11 Jan 2025 06:15:53 GMT +- request: + method: get + uri: https://app-gateway.prod.senec.dev/v1/senec/systems + body: + encoding: US-ASCII + string: '' + headers: + User-Agent: + - Faraday v2.12.2 + Authorization: + - "" + response: + status: + code: 200 + message: '' + headers: + date: + - Sat, 11 Jan 2025 06:15:53 GMT + content-type: + - application/json + transfer-encoding: + - chunked + connection: + - keep-alive + vary: + - Origin, Access-Control-Request-Method, Access-Control-Request-Headers + x-content-type-options: + - nosniff + x-xss-protection: + - 1; mode=block + cache-control: + - no-cache, no-store, max-age=0, must-revalidate + pragma: + - no-cache + expires: + - '0' + strict-transport-security: + - max-age=31536000; includeSubDomains + x-frame-options: + - DENY + body: + encoding: UTF-8 + string: '[{"id":"","steuereinheitnummer":"","gehaeusenummer":"","strasse":"","hausnummer":"","postleitzahl":"","ort":"","laendercode":"DE","zeitzone":"Europe/Berlin","wallboxIds":["1"],"systemType":"V3"}]' + recorded_at: Sat, 11 Jan 2025 06:15:53 GMT +- request: + method: get + uri: https://app-gateway.prod.senec.dev/v2/senec/systems//dashboard + body: + encoding: US-ASCII + string: '' + headers: + User-Agent: + - Faraday v2.12.2 + Authorization: + - "" + response: + status: + code: 200 + message: '' + headers: + date: + - Sat, 11 Jan 2025 06:15:54 GMT + content-type: + - application/json + transfer-encoding: + - chunked + connection: + - keep-alive + vary: + - Origin, Access-Control-Request-Method, Access-Control-Request-Headers + x-content-type-options: + - nosniff + x-xss-protection: + - 1; mode=block + cache-control: + - no-cache, no-store, max-age=0, must-revalidate + pragma: + - no-cache + expires: + - '0' + strict-transport-security: + - max-age=31536000; includeSubDomains + x-frame-options: + - DENY + body: + encoding: UTF-8 + string: '{"currently":{"powerGenerationInW":1.0e-05,"powerConsumptionInW":1047.7,"gridFeedInInW":1.0e-05,"gridDrawInW":1024.4205298,"batteryChargeInW":1.0e-05,"batteryDischargeInW":11.6411423841,"batteryLevelInPercent":1.0e-05,"selfSufficiencyInPercent":2.22,"wallboxInW":1.0e-05},"today":{"powerGenerationInWh":3.90625,"powerConsumptionInWh":8521.48,"gridFeedInInWh":0.0,"gridDrawInWh":8420.8984375,"batteryChargeInWh":0.0,"batteryDischargeInWh":100.5859375,"batteryLevelInPercent":1.0e-05,"selfSufficiencyInPercent":1.18,"wallboxInWh":0.0},"timestamp":"2025-01-11T06:14:59Z","electricVehicleConnected":false}' + recorded_at: Sat, 11 Jan 2025 06:15:54 GMT +recorded_with: VCR 6.3.1 diff --git a/spec/support/cassettes/cloud/fetch-dashboard-v2-specific-system.yml b/spec/support/cassettes/cloud/fetch-dashboard-v2-specific-system.yml new file mode 100644 index 0000000..783962c --- /dev/null +++ b/spec/support/cassettes/cloud/fetch-dashboard-v2-specific-system.yml @@ -0,0 +1,91 @@ +--- +http_interactions: +- request: + method: post + uri: https://app-gateway.prod.senec.dev/v1/senec/login + body: + encoding: UTF-8 + string: '{"username":"","password":""}' + headers: + User-Agent: + - Faraday v2.12.2 + Content-Type: + - application/json + response: + status: + code: 200 + message: '' + headers: + date: + - Sat, 11 Jan 2025 06:38:29 GMT + content-type: + - application/json + transfer-encoding: + - chunked + connection: + - keep-alive + vary: + - Origin, Access-Control-Request-Method, Access-Control-Request-Headers + x-content-type-options: + - nosniff + x-xss-protection: + - 1; mode=block + cache-control: + - no-cache, no-store, max-age=0, must-revalidate + pragma: + - no-cache + expires: + - '0' + strict-transport-security: + - max-age=31536000; includeSubDomains + x-frame-options: + - DENY + body: + encoding: UTF-8 + string: '{"token":"","refreshToken":""}' + recorded_at: Sat, 11 Jan 2025 06:38:29 GMT +- request: + method: get + uri: https://app-gateway.prod.senec.dev/v2/senec/systems//dashboard + body: + encoding: US-ASCII + string: '' + headers: + User-Agent: + - Faraday v2.12.2 + Authorization: + - "" + response: + status: + code: 200 + message: '' + headers: + date: + - Sat, 11 Jan 2025 06:38:29 GMT + content-type: + - application/json + transfer-encoding: + - chunked + connection: + - keep-alive + vary: + - Origin, Access-Control-Request-Method, Access-Control-Request-Headers + x-content-type-options: + - nosniff + x-xss-protection: + - 1; mode=block + cache-control: + - no-cache, no-store, max-age=0, must-revalidate + pragma: + - no-cache + expires: + - '0' + strict-transport-security: + - max-age=31536000; includeSubDomains + x-frame-options: + - DENY + body: + encoding: UTF-8 + string: '{"currently":{"powerGenerationInW":1.0e-05,"powerConsumptionInW":1164.11,"gridFeedInInW":1.0e-05,"gridDrawInW":1164.11423841,"batteryChargeInW":1.0e-05,"batteryDischargeInW":17.46171357616,"batteryLevelInPercent":1.0e-05,"selfSufficiencyInPercent":1.0e-05,"wallboxInW":1.0e-05},"today":{"powerGenerationInWh":3.90625,"powerConsumptionInWh":8902.34,"gridFeedInInWh":0.0,"gridDrawInWh":8796.875,"batteryChargeInWh":0.0,"batteryDischargeInWh":105.46875,"batteryLevelInPercent":1.0e-05,"selfSufficiencyInPercent":1.18,"wallboxInWh":0.0},"timestamp":"2025-01-11T06:35:05Z","electricVehicleConnected":false}' + recorded_at: Sat, 11 Jan 2025 06:38:29 GMT +recorded_with: VCR 6.3.1