Welcome to Smart Home Forum by FIBARO
Dear Guest,
as you can notice parts of Smart Home Forum by FIBARO is not available for you. You have to register in order to view all content and post in our community. Don't worry! Registration is a simple free process that requires minimal information for you to sign up. Become a part of of Smart Home Forum by FIBARO by creating an account.
As a member you can:
- Start new topics and reply to others
- Follow topics and users to get email updates
- Get your own profile page and make new friends
- Send personal messages
- ... and learn a lot about our system!
Regards,
Smart Home Forum by FIBARO Team
Question
JcBorgs 52
Anyone that can give some assistance with coding WebSockets in a QA??
Trying to build a really simple QA to collect data from my “Tibber Pulse”. The intention is to capture live energy consumption and put the code in a Energy Meter QA. In the Tibber iPhone app I get updated values every 10’s second from my Tibber Pulse and to get similar in a Fibaro HC3 QA would be ideal.
Have never worked with WebSockets in the past so have no clue to how to do this…. But as a general concept it looks doable, but my attempt so far have only failed.
General simple idea is to create a QA (Energy Meter type) with WebSocket code that listens to data from my “Tibber Pulse” and simply store the data received to the QA with self:updateProperty("value", TibberDataRecieved).
There are some information in regards to WebSockets on the Tibber development pages:
Please login or register to see this link.
Please login or register to see this link.
Subscriptions
GraphQL Subscriptions is the mechanism that is used for streaming data. It is basically a layer built on top of standard web sockets. A client starts a subscription by issuing a subscription query:
Please login or register to see this code.
The server will then push results conforming to this query over the socket that is kept open between client and server.
GraphQL Subscriptions Endpoint
Please login or register to see this code.
Subscribing to data
While queries and mutations are typically handled over HTTP some data are better suited to handled as streams over a persistent connection (web socket). Subscriptions follows the same semantics as queries and mutations - the shape of what is returned/sent from the server is determined by the client when invoking the api:
Please login or register to see this code.
Since subscriptions are handled over web sockets they can be a bit more challenging to handle from the client’s perspective. Many GraphQL client libraries provide good abstractions for this though. Note that the maximum number of open websockets is limited to two.
Streaming live data from Tibber Pulse
Python example to get live streaming data from your Tibber Pulse over GraphQl. This also works for any other type of smart energy meter supported by Tibber, such as Watty. Requires ‘Python GraphQL Client’ package: pip install python-graphql-client
Please login or register to see this code.
Tibber GraphiQL example from (
Please login or register to see this link.
)Please login or register to see this code.
Added more information
17 answers to this question
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.