Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to get the current power of the solar production (or current consumption) ? #28

Closed
BugRaptor opened this issue Jun 13, 2018 · 7 comments

Comments

@BugRaptor
Copy link

BugRaptor commented Jun 13, 2018

I'm a bit confused with the interface of the Smappy Python Wrapper. I do not need the energy produced (or consumed) between two past time stamps but I need to monitor the current solar production power (or the current electrical consumption power) like displayed on the main screen of the Smappee Smartphone App.
How to simply get theses values with the Smappy Python Wrapper ?

@martintamke
Copy link

martintamke commented Jun 13, 2018

Is the command to get the Solar Production documented in the Smappee API or elsewhere?
immediately I couldnt find it in the api description: https://smappee.atlassian.net/wiki/spaces/DEVAPI/pages/8552473/API+Methods
However I do not have solar panels linked to my smappee, so maybe yours can spit out the infos, when you run some REST commands towards the device via the smappy python interface..

@JrtPec
Copy link
Contributor

JrtPec commented Jun 13, 2018

Hi, the Smappy package has two kinds of clients: The first is Smappy, which implements all API calls described on https://smappee.atlassian.net/wiki/display/DEVAPI/API+Methods. The second is LocalSmappy, which connects directly to your smappee via your LAN.

The Smappy client doesn't have the methods you are looking for. It is only suited for historical and "nearly real time" data, so I guess you will always have a delay of a few minutes when using it.
The LocalSmappy client has methods called report_instantaneous_values, load_instantaneous and active_power, which are probably what you need.

A third approach could be to check out the new MQTT functionality, see #27

@BugRaptor
Copy link
Author

BugRaptor commented Jun 13, 2018

@JrtPec Thank you. I did not find any info about the LocalSmappy client you are talking about. Do you mean another python wrapper for the Smappee API connecting directly to my Smappee device via my LAN ? (I do not need to access it from outside). Is it available here on GitHub ?
On the other hand, the MQTT message based protocol and it's dispatching broker might be interesting too if available from a python package.
I just intend to write a python app on a Raspberry Pi, monitoring my solar produced electrical power to switch on and off my swimming pool heat pump that legally has to be only powered by locally produced solar energy.
So the simplest available python client library allowing to get the current solar power measured by my Smappee device will be the best. Any advice on that concern greatly appreciated. Thank you again.

Edit: Ooops ! I just understand you were talking about your separate client class LocalSmappee in your smappy.py package !
I understand you don't have a wrapper class available for the MQTT protocol right now. True ? Your LocalSmappee class should do the job. I'll check it.

@JrtPec
Copy link
Contributor

JrtPec commented Jun 13, 2018

You got it!
The LocalSmappee client hasn't been documented yet, that's why it may be hard to find. There is an issue open for that: #13.

We don't have anything for the MQTT yet, its existence was only brought to my attention 2 days ago.

@BugRaptor
Copy link
Author

Sorry, I'm new to python. Could you give me a sample code how to use the LocalSmappee client, to logon and get all the instantanate data from my Smappee device ?

@JrtPec
Copy link
Contributor

JrtPec commented Jun 16, 2018

I have updated the Readme, so now it has some documentation about LocalSmappee.

Here's a sample you could try:

import smappy
client = smappy.LocalSmappee(ip='192.168.0.50')  # fill in the IP of your Smappee
client.logon(password='admin')  # enter your password, default is 'admin'

report = client.report_instantaneous_values()
print(report)

instantaneous = client.load_instantaneous()
print(instantaneous)

disclaimer: I do not have a Smappee in my own local network, so I haven't tested this part of the code.

@BugRaptor
Copy link
Author

BugRaptor commented Jun 16, 2018

Thank you. Actually I finally had found by myself : Here is my code to measure the current solar power. It works fine:

import smappy

ls = smappy.LocalSmappee(ip='192.168.1.120')
ls.logon(password='admin')
smappeeData = ls.load_instantaneous()
solarPowerInWatts = 0.0
for itemDict in smappeeData:
    key = itemDict.get('key')
    if key in ['phase3ActivePower','phase4ActivePower','phase5ActivePower']:
        value = itemDict.get('value')
        phasePowerInWatts = float(value) / 1000
        solarPowerInWatts += phasePowerInWatts
print(solarPowerInWatts)

@JrtPec JrtPec closed this as completed Jun 17, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants