Vibekodade ihop ett HomeyScript för att uppdatera SOC på min EV som inte har appstöd hos Tibber.
Skapa ett homey script med nedan kod och fyll i username/password/homeID och VehicleID.
Blockquote
// HomeyScript: push_soc_to_tibber
//
// Pushes the Zeekr battery level (State of Charge) to Tibber.
// Mirrors the Home Assistant tibber_soc_updater custom integration.
//
// Setup:
// 1. Fill in TIBBER_EMAIL, TIBBER_PASSWORD, TIBBER_VEHICLE_ID, TIBBER_HOME_ID below.
// 2. Create this as a HomeyScript in the Homey app.
// 3. Create a flow:
// Trigger: Battery level changed
// Condition: Battery level is greater than 0
// Action: Run HomeyScript “push_soc_to_tibber”
// At the moment Tibber has 83% SOC while actual is 87%
const TIBBER_EMAIL = ‘e-mail’; // ← fill in
const TIBBER_PASSWORD = ‘password’; // ← fill in
const TIBBER_VEHICLE_ID = ’ '; ← fill in Can be extracted from https://app.tibber.com/
const TIBBER_HOME_ID = ’ '; ← fill in Can be extracted from https://app.tibber.com/
const TIBBER_LOGIN_URL = ‘https://app.tibber.com/login.credentials’;
const TIBBER_GQL_URL = ‘https://app.tibber.com/v4/gql’;
const GQL_HEADERS = {
‘Accept-Language’: ‘en’,
‘x-tibber-new-ui’: ‘true’,
‘User-Agent’: ‘Tibber/25.20.0 (versionCode:2520004 Dalvik/2.1.0 (Linux; U; Android 10; Android SDK built for x86_64 Build/QSR1.211112.011))’,
‘Content-Type’: ‘application/json’,
‘Accept’: ‘application/graphql-response+json, application/json’,
‘Origin’: ‘https://app.tibber.com’,
‘Referer’: ‘https://app.tibber.com/’,
};
// SOC comes from the flow tag (args is a plain string); fall back to 78 for manual test runs
const batteryLevel = (args !== undefined && args !== null && args !== ‘’) ? parseInt(args, 10) : 78;
const loginRes = await fetch(TIBBER_LOGIN_URL, {
method: ‘POST’,
headers: { ‘Content-Type’: ‘application/x-www-form-urlencoded’ },
body:email=${encodeURIComponent(TIBBER_EMAIL)}&password=${encodeURIComponent(TIBBER_PASSWORD)},
});
if (!loginRes.ok) throw new Error(Tibber login failed: ${loginRes.status});
const { token } = await loginRes.json();
if (!token) throw new Error(‘Tibber login returned no token’);
const mutation =mutation SetVehicleSettings($vehicleId: String!, $homeId: String!, $settings: [SettingsItemInput!]) { me { setVehicleSettings(id: $vehicleId, homeId: $homeId, settings: $settings) { __typename } } };
const gqlRes = await fetch(TIBBER_GQL_URL, {
method: ‘POST’,
headers: { …GQL_HEADERS, Authorization:Bearer ${token}},
body: JSON.stringify({
query: mutation,
variables: {
vehicleId: TIBBER_VEHICLE_ID,
homeId: TIBBER_HOME_ID,
settings: [{ key: ‘offline.vehicle.batteryLevel’, value: batteryLevel }],
},
}),
});
if (!gqlRes.ok) throw new Error(Tibber mutation failed: ${gqlRes.status});
const gqlData = await gqlRes.json();
if (gqlData.errors) throw new Error(Tibber GraphQL error: ${JSON.stringify(gqlData.errors)});
returnPushed SOC ${batteryLevel}% to Tibber;
Ladda ner och installera Homey Script App.
Skapa ett flow där Action triggers är att SOC ändras på din bil.
Lägg därefter till att Homey Script skall köra ovan script med SOC som input.
//M