Giter VIP home page Giter VIP logo

Comments (17)

larpo avatar larpo commented on July 30, 2024 2

I'm surprised and disappointed to find out the power consumption information is not part of the API. I was hoping to feed the power usage information into grafana for closer inspection, but no luck I guess :(

from switchbotapi.

masterlog80 avatar masterlog80 commented on July 30, 2024 2

@Minsheng Partially correct in my opinion.
As far as I know, the API can provide the electricCurrent (Current), voltage(Voltage), weight(Power), etc. but not the Energy which is available in the App along with its History (not sure how long those data are stored). Obviously it's possible to constantly (e.g. every 1 min for high resolution) get weight(Power) and time, put those a DB and calculate the Energy along a timeframe, but it needs more effort than making a single call per day to get the Energy, or better its history.
I am wondering if it's possible to capture the packets and see which API is used by the App to get those. 🤔

Examples:

EDIT: connection by App and API server seems using TLS resulting on encrypted data (including the API call to get Energy along with its History), so I am not sure if it's possible to retrieve those details easily.

from switchbotapi.

kmikage avatar kmikage commented on July 30, 2024 1

I think so too.
In the app, displayed power consumption(W), voltage(V), and current(A).
I want to get the same data with API.

from switchbotapi.

meramsey avatar meramsey commented on July 30, 2024 1

this is unfortunate if not planning to be added would have expected this to be available considering they clearly are capturing/storing the information. not making it available seems odd considering how useful it would be to get combined home or room total kWh used vs having to calculate it manually from reviewing the app per device and tally it up.

from switchbotapi.

kganjoo avatar kganjoo commented on July 30, 2024 1

@masterlog80 , @maxlingenfelter , I don't think so that the API returns a power factor. I am using a switcbot plug mini US, and I dont see power-factor being returned in the response.

HERE IS MY SAMPLE RESPONSE
{ "statusCode": 100, "body": { "deviceId": "A0764E357656", "deviceType": "Plug Mini (US)", "hubDeviceId": "A0764E357656", "power": "off", "voltage": 123.1, "weight": 0, "electricityOfDay": 20, "electricCurrent": 0, "version": "V1.5-1.5" }, "message": "success" }

from switchbotapi.

anoff avatar anoff commented on July 30, 2024

I am also interested in this functionality.
Is there any other way of obtaining these readings directly from the device? e.g. direct access point to the plug in WiFi, while being paired in WiFi setup mode, BLE (not sure if the plug has BT..)

from switchbotapi.

idaitoshi avatar idaitoshi commented on July 30, 2024

I think so too.
I want to check the operating status of the device by power consumption, so I want to get the power consumption.

from switchbotapi.

himawari2021 avatar himawari2021 commented on July 30, 2024

I am interested in getting information about consumption too.
I want to know if an appliance is on or off which has only "toggle button" for power on/off.

from switchbotapi.

cosura avatar cosura commented on July 30, 2024

Is the management team making the API private due to concerns about concentrated access to the system?

from switchbotapi.

Minsheng avatar Minsheng commented on July 30, 2024

Sorry guys, this feature will not be added for SwitchBot Plug. If you happen to have purchased Plug Mini (US) / Plug Mini (JP), u can get the data through the API.

from switchbotapi.

larpo avatar larpo commented on July 30, 2024

@masterlog80 Based on the documentation, weight should be exactly what you are looking for, but for whatever reason it seems to return power instead. Not to mention the API returns also a 10x value for the electricCurrent...
image

from switchbotapi.

masterlog80 avatar masterlog80 commented on July 30, 2024

@larpo To better clarify, the weight is indeed the instant power (not the daily one as mentioned in the documentation which at this point seems to be wrong). However, the power is considered an instant value and measured in W (Watt), while the energy is expressed in a specific time frame like KWh (KW per hours).
However on my side all the parameters shown (e.g. electricCurrent, voltage, etc.) are correct and legit.
What I am looking for is the energy and its History (in order to eventually calculate the costs) which indeed can be retrieved from the cloud (the App can do that), but the target API and its output are not available in the documentation.

from switchbotapi.

maxlingenfelter avatar maxlingenfelter commented on July 30, 2024

@larpo & @masterlog80 given the voltage and current you should be able to track power usage over time and get a "energy"
over whatever time frame you want.

Ex:
power = voltage x current = 120V x 5A

If you integrate this API into a home automation software like home assistant you could track the cumulative power usage over an hour and then make a cumulative sum over a day and then you have that day's KWh usage.

from switchbotapi.

masterlog80 avatar masterlog80 commented on July 30, 2024

@maxlingenfelter
that's actually not correct. To calculate the power on AC, you need to consider also the power factor which is not a static or fixed value. The point here is to get the Energy and its History trough the API, in the easiest way as possible.

from switchbotapi.

maxlingenfelter avatar maxlingenfelter commented on July 30, 2024

@masterlog80 , you are right about considering the power factor for accurate power calculations on AC circuits. I apologize for not explicitly mentioning that earlier.

To track power usage over time and calculate energy (KWh) accurately, the formula is:

Real Power (kW) = Apparent Power (VA) × Power Factor
where:

Apparent Power (VA) = Voltage (V) × Current (A)

Since the power factor can vary over time due to different loads, continuously monitoring the power factor and using its real-time value in energy calculations is essential. By doing this and integrating the API into home automation software like Home Assistant, you can track cumulative power usage over time, accounting for fluctuations in the power factor, and obtain a more precise representation of energy consumption in KWh for any desired time frame.

While dedicated energy meters with power factor measurements can provide more accurate results, the API-based approach is still valuable for many monitoring scenarios, as long as the dynamic nature of the power factor is taken into consideration.

from switchbotapi.

masterlog80 avatar masterlog80 commented on July 30, 2024

I wasn't sure that the power factor can be retrieved by API, I need to check that. However, thanks for your update.

I would suggest you providing some instructions to integrated this into automation software (e.g. Home Assistant, etc.) to get the values required as for not developers this can be pretty troublesome.

Regards,

from switchbotapi.

maxlingenfelter avatar maxlingenfelter commented on July 30, 2024

@kganjoo no it does not, that's the whole point of the back-and-forth @masterlog80 where having.

from switchbotapi.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.