{"id":13576645,"url":"https://github.com/stefanes/PSTibber","last_synced_at":"2025-04-05T08:32:37.430Z","repository":{"id":58734287,"uuid":"532508071","full_name":"stefanes/PSTibber","owner":"stefanes","description":"PowerShell module for accessing the Tibber GraphQL API","archived":false,"fork":false,"pushed_at":"2024-01-15T09:13:40.000Z","size":577,"stargazers_count":7,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2024-11-05T13:41:02.423Z","etag":null,"topics":["powershell","tibber","tibberlive","tibberpulse"],"latest_commit_sha":null,"homepage":"https://www.powershellgallery.com/packages/PSTibber","language":"PowerShell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/stefanes.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2022-09-04T10:34:19.000Z","updated_at":"2024-03-18T07:38:41.000Z","dependencies_parsed_at":"2023-11-12T22:22:43.389Z","dependency_job_id":"1f1a7780-8d11-4175-9e55-745d87a452d4","html_url":"https://github.com/stefanes/PSTibber","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stefanes%2FPSTibber","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stefanes%2FPSTibber/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stefanes%2FPSTibber/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/stefanes%2FPSTibber/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/stefanes","download_url":"https://codeload.github.com/stefanes/PSTibber/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247311875,"owners_count":20918339,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["powershell","tibber","tibberlive","tibberpulse"],"created_at":"2024-08-01T15:01:12.364Z","updated_at":"2025-04-05T08:32:37.044Z","avatar_url":"https://github.com/stefanes.png","language":"PowerShell","funding_links":[],"categories":["powershell"],"sub_categories":[],"readme":"# PSTibber\n\nPowerShell module for accessing the Tibber GraphQL API: \u003chttps://developer.tibber.com/docs/overview\u003e\n\n[![Latest version](https://img.shields.io/powershellgallery/v/PSTibber?style=flat\u0026color=blue\u0026label=Latest%20version)](https://www.powershellgallery.com/packages/PSTibber) [![Download count](https://img.shields.io/powershellgallery/dt/PSTibber?style=flat\u0026color=green\u0026label=Download%20count)](https://www.powershellgallery.com/packages/PSTibber)\n\n\u003e _:heavy_check_mark: See [CHANGELOG.md](CHANGELOG.md) for what's new!_\n\n![Grafana](docs/resources/grafana.png)\n\n_See [here](https://github.com/stefanes/tibber-pulse) for an example of this module in action..._\n\n## Installation\n\nUsing the [latest version of PowerShellGet](https://www.powershellgallery.com/packages/PowerShellGet):\n\n```powershell\nInstall-Module -Name PSTibber -Repository PSGallery -Scope CurrentUser -Force -PassThru\nImport-Module -Name PSTibber -Force -PassThru\n```\n\nOr if you already have the module installed, update to the latest version:\n\n```powershell\nUpdate-Module -Name PSTibber\nImport-Module -Name PSTibber -Force -PassThru\n```\n\n## Authentication\n\n\u003e **Note**\n\u003e\n\u003e To access the API you first must have a Tibber account (you can [sign up for Tibber](https://tibber.com/se/invite/gqpkcwrn) using the invitation code `gqpkcwrn` to get a **€50/500 kr bonus** for use in the [Tibber Store](https://tibber.com/se/store)).\n\nA _Personal Access Token_ can be generated here: \u003chttps://developer.tibber.com/settings/access-token\u003e\n\nTo authenticate, pass the generated access token using the [`-PersonalAccessToken`](docs/functions/Invoke-TibberQuery.md#-personalaccesstoken) parameter with each call or set the `TIBBER_ACCESS_TOKEN` environment variable:\n\n```powershell\n$env:TIBBER_ACCESS_TOKEN = \"\u003cyour access token\u003e\"\n```\n\n## User agent\n\n\u003e **Note**\n\u003e\n\u003e Please set a user agent so Tibber can better track different client implementations.\n\nTo set a user agent, pass the string using the [`-UserAgent`](docs/functions/Invoke-TibberQuery.md#-useragent) parameter with each call or set the `TIBBER_USER_AGENT` environment variable:\n\n```powershell\n$env:TIBBER_USER_AGENT = 'stefanes.tibber-pulse/0.1.0'\n```\n\n## Usage\n\n\u003e _:heavy_check_mark: See [here](docs/graphql-ws.md) for how to use this module with your Tibber Pulse/Watty._\n\nUse `Get-Command -Module PSTibber` for a list of functions provided by this module. See the help associated with each function using the `Get-Help` command, e.g. `Get-Help Get-TibberUser -Detailed`, and the documentation available [in `docs`](docs/functions/) for more details:\n\n- [`Connect-TibberWebSocket`](docs/functions/Connect-TibberWebSocket.md)\n- [`Disconnect-TibberWebSocket`](docs/functions/Disconnect-TibberWebSocket.md)\n- [`Get-TibberConsumption`](docs/functions/Get-TibberConsumption.md)\n- [`Get-TibberHome`](docs/functions/Get-TibberHome.md)\n- [`Get-TibberPriceInfo`](docs/functions/Get-TibberPriceInfo.md)\n- [`Get-TibberProduction`](docs/functions/Get-TibberProduction.md)\n- [`Get-TibberUser`](docs/functions/Get-TibberUser.md)\n- [`Invoke-TibberQuery`](docs/functions/Invoke-TibberQuery.md)\n- [`Read-TibberWebSocket`](docs/functions/Read-TibberWebSocket.md)\n- [`Register-TibberLiveMeasurementSubscription`](docs/functions/Register-TibberLiveMeasurementSubscription.md)\n- [`Unregister-TibberLiveMeasurementSubscription`](docs/functions/Unregister-TibberLiveMeasurementSubscription.md)\n\nIf there is no function available for what you are trying to do, you can always use the [`Invoke-TibberQuery`](docs/functions/Invoke-TibberQuery.md) function with a valid GraphQL query:\n\n```powershell\n$query = @\"\n{\n  viewer {\n    homes {\n      id\n      consumption(resolution: HOURLY, last: 1) {\n        nodes {\n          to\n          consumption\n          cost\n        }\n      }\n      currentSubscription {\n        priceInfo {\n          tomorrow {\n            startsAt\n            total\n            level\n          }\n        }\n      }\n    }\n  }\n}\n\"@\n$response = Invoke-TibberQuery -Query $query\n$response.viewer.homes[0]\n```\n\n_Note: You can construct your GraphQL queries using the [Tibber API explorer](https://developer.tibber.com/explorer)._\n\n### Examples\n\n#### Get logged-in user details\n\n```powershell\n$response = Get-TibberUser\nWrite-Host \"$($response.name) \u003c$($response.login)\u003e with user Id $($response.userId)\"\n```\n\n#### Get home Id\n\n```powershell\n$response = Get-TibberHome\n($response | Where-Object { $_.appNickname -eq 'Vitahuset' }).id | Tee-Object -Variable homeId\n```\n\n#### Check if your home has a _Tibber Pulse_ or _Watty_ registered\n\n```powershell\n$response = Get-TibberHome -IncludeFeatures -Id $homeId\nWrite-Host \"Your home, $($response.appNickname), has real-time consumption $(\n    if ([bool]::Parse($response.features.realTimeConsumptionEnabled)) {\n        'enabled!'\n    }\n    else {\n        'disabled...'\n    }\n    )\"\n```\n\n#### Get the size of your main fuse\n\n```powershell\n(Get-TibberHome -Id $homeId).mainFuseSize\n```\n\n#### Get time of maximum energy price\n\n```powershell\n$response = Get-TibberPriceInfo -Last 10\n$maxPrice = $response | Sort-Object -Property total -Descending | Select-Object -First 1\nWrite-Host \"Max energy price, $($maxPrice.total) $($maxPrice.currency), starting at $(([DateTime]$maxPrice.startsAt).ToString('yyyy-MM-dd HH:mm')) [$($maxPrice.level)]\"\n```\n\n#### Get today's and tomorrow's energy prices\n\n```powershell\n$response = Get-TibberPriceInfo -IncludeToday -IncludeTomorrow\nWrite-Host \"Today's and tomorrow's energy prices: $($response | Out-String)\"\n```\n\n#### Get time of maximum power consumption\n\n```powershell\n$response = Get-TibberConsumption -Last 10\n$maxCons = $response | Sort-Object -Property consumption -Descending | Select-Object -First 1\nWrite-Host \"Max power consumption $($maxCons.cost) $($maxCons.currency) ($($maxCons.consumption) $($maxCons.consumptionUnit) at $($maxCons.unitPrice)): $(([DateTime]$maxCons.from).ToString('HH:mm')) - $(([DateTime]$maxCons.to).ToString('HH:mm on yyyy-MM-dd'))\"\n```\n\n#### Get time of maximum power production\n\n```powershell\n$response = Get-TibberProduction -Last 10\n$maxProd = $response | Sort-Object -Property production -Descending | Select-Object -First 1\nWrite-Host \"Max power production $($maxProd.profit) $($maxProd.currency) ($($maxProd.production) $($maxProd.productionUnit) at $($maxProd.unitPrice)): $(([DateTime]$maxProd.from).ToString('HH:mm')) - $(([DateTime]$maxProd.to).ToString('HH:mm on yyyy-MM-dd'))\"\n```\n\n#### Send push notifications\n\n```powershell\n$response = Send-PushNotification -Title 'Hello' -Message 'World!' -ScreenToOpen CONSUMPTION\nWrite-Host \"Sent push notification to $($response.pushedToNumberOfDevices) device(s)\"\n```\n\n### The response cache\n\nThe response from all `Get` functions are cached by default, this means that the next time you call the same function with the same parameters the result stored in the cache will be returned with **no new request sent to the GraphQL endpoint**. Use `-Force` to force a refresh of any cached results:\n\n```powershell\nPS\u003e Get-TibberUser -Verbose\nVERBOSE: Invoking web request: POST https://api.tibber.com/v1-beta/gql [User agent = PSTibber/0.6.1 stefanes.tibber-pulse/0.1.0]\nVERBOSE: POST with 68-byte payload\nVERBOSE: received 178-byte response of content type application/json\n\nUser Id                              User\n-------                              ----\ndcc2355e-6f55-45c2-beb9-274241fe450c Arya Stark \u003carya@winterfell.com\u003e\n\nPS\u003e Get-TibberUser -Verbose\nVERBOSE: From cache: b0c06ad71d17d320d1bbada3a930f6e6174e222b\n\nUser Id                              User\n-------                              ----\ndcc2355e-6f55-45c2-beb9-274241fe450c Arya Stark \u003carya@winterfell.com\u003e\n\nPS\u003e Get-TibberUser -Force -Verbose\nVERBOSE: Invoking web request: POST https://api.tibber.com/v1-beta/gql [User agent = PSTibber/0.6.1 stefanes.tibber-pulse/0.1.0]\nVERBOSE: POST with 68-byte payload\nVERBOSE: received 178-byte response of content type application/json\n\nUser Id                              User\n-------                              ----\ndcc2355e-6f55-45c2-beb9-274241fe450c Arya Stark \u003carya@winterfell.com\u003e\n```\n\n_Note: The entire cache can be cleared by re-importing the module, `Import-Module -Name PSTibber -Force -PassThru`._\n\n### Debugging\n\nTo view the GraphQL query sent in the requests, add the `-Debug` switch to the command. To also include the response, add the `-DebugResponse` switch.\n\nExample:\n\n```powershell\nPS\u003e Get-TibberUser -Debug -DebugResponse\nDEBUG: GraphQL query: { \"query\": \"{ viewer{ login,userId,name,accountType,websocketSubscriptionUrl,__typename }}\" }\nDEBUG: Response: 200 OK\nDEBUG: Response content: {\"data\":{\"viewer\":{\"login\":\"arya@winterfell.com\",\"userId\":\"dcc2355e-6f55-45c2-beb9-274241fe450c\",\"name\":\"Arya Stark\",\"accountType\":[\"tibber\",\"customer\"],\"websocketSubscriptionUrl\":\"wss://websocket-api.tibber.com/v1-beta/gql/subscriptions\",\"__typename\":\"Viewer\"}}}\n\nDEBUG: Cache entry [b0c06ad71d17d320d1bbada3a930f6e6174e222b]: @{viewer=}\n\nUser Id                              User\n-------                              ----\ndcc2355e-6f55-45c2-beb9-274241fe450c Arya Stark \u003carya@winterfell.com\u003e\n```\n\n## Tibber Pulse/Watty (live measurement data)\n\nThe live measurement data, generated by e.g. _[Tibber Pulse](https://tibber.com/se/store/produkt/pulse)_ or _[Watty](https://tibber.com/se/store/produkt/watty-tibber)_, is served as a GraphQL subscription. See [here](docs/graphql-ws.md) for details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstefanes%2FPSTibber","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fstefanes%2FPSTibber","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fstefanes%2FPSTibber/lists"}