-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
[smappee] Smappee Binding initial contribution #2815
Conversation
Corrected Attenuation Factor calculation in this case. Removed initial started delay Signed-off-by: Niko Tanghe <ntanghe@gmail.com>
Signed-off-by: Niko Tanghe <ntanghe@gmail.com>
Signed-off-by: Niko Tanghe <ntanghe@gmail.com>
Signed-off-by: Niko Tanghe <ntanghe@gmail.com>
… into Smappee Signed-off-by: Niko Tanghe <ntanghe@gmail.com>
This pull request has been mentioned on openHAB Community. There might be relevant details there: |
This pull request has been mentioned on openHAB Community. There might be relevant details there: |
Just some general comment as a start to get the code approved. You might know all of the following, but just to help you further:
|
Thx! Two hints for the above description
and one question: Do you have sample config files you can add here? |
This binding does not need to detect your smappee device in your network, since it will contact the online API to get it's readings. It is a 2.0 binding, so everything can be configured through the openhab UI. |
It can, but it must also be possible to configure it textually. |
Changed thing name Signed-off-by: Niko Tanghe <ntanghe@gmail.com>
Changed thing name Signed-off-by: Niko Tanghe <ntanghe@gmail.com>
Signed-off-by: Niko Tanghe <ntanghe@gmail.com>
Signed-off-by: Niko Tanghe <ntanghe@gmail.com>
Signed-off-by: Niko Tanghe <ntanghe@gmail.com>
This pull request has been mentioned on openHAB Community. There might be relevant details there: |
Signed-off-by: Niko Tanghe <ntanghe@gmail.com>
@@ -0,0 +1,7 @@ | |||
eclipse.preferences.version=1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This file should not be commited.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
file removed
@@ -0,0 +1,15 @@ | |||
# binding |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove this file if you don't add localization. It's an example template file
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
file removed
<label>Client Id</label> | ||
<description>The Smappee Api Oauth client id (obtain by mail from smappee support)</description> | ||
<advanced>false</advanced> | ||
<required>true</required> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use required as parameter element or as tag. Here both are used, which is a bit of an overkill
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
node required removed
http://www.eclipse.org/legal/epl-v10.html | ||
|
||
--> | ||
<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0" immediate="true" name="binding.smappee"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Preferable use the @component annotation on ThingHandlerFactory.Then you can remove this file and add a .gitignore
to this map (OSGI-INF) with content: *.xml
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@component used and removed xml config file
|
||
### Configuration in PaperUi | ||
|
||
Following settings must be configured in order to make your seneye binding work : |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
smappee instead of seneye
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok
consumption.solar = consumption.solar * 12; | ||
} | ||
|
||
logger.debug("smappee'{}' read", new Object[] { this.serviceLocationId }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no need to do new Object, just pass the value directly as argument.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok
} | ||
|
||
public boolean isInitialized() { | ||
return isInitialized; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
boolean variable should be called initialized the action(method) is called isInitialized.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok
|
||
String accessTokenToInclude = GetAccessToken(); | ||
if (accessTokenToInclude.isEmpty()) { | ||
logger.error("Could not get access token"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If this error log a bug or a problem with the external service? If it's not a bug it should not log to error. Same question for the other log to errors in this file.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
refactored code and logged errors like this :
warn -> external service fails (there is something wrong getting an access/refresh token)
error -> bug while parsing the response from smappee api
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thank you for the review :-)
|
||
this.gson = new Gson(); | ||
|
||
this.isInitialized = false; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The default is false so no initialization to false is not needed.
|
||
logger.debug("Initialize Network handler."); | ||
smappeeService = new SmappeeService(param_client_id, param_client_secret, param_username, param_password, | ||
param_serviceLocationName, polltime); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see both polltime
and refreshInterval
used for what seems to be the same thing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
changed RefreshInterval to pollTime (it's the same)
Signed-off-by: Niko Tanghe <ntanghe@gmail.com>
You need to (re)add the map |
Signed-off-by: Niko Tanghe <ntanghe@gmail.com>
Signed-off-by: Niko Tanghe <ntanghe@gmail.com>
It looks like you added your other binding for seneye in the last commit (openhab/openhab2-addons@690b8e3) to this pull request. I guess that was not intended? Also when you merge the master into your branch you need to do a |
Ok that went wrong 🤕 but it's reverted now. I wanted to push to my fork, but ended up force pushing to this pull request... I did make some changes to this code. I've moved to the new build system and also replaced authentication with OAuth2 that is part of openHAB. There is still be some work to do, and I haven't tested anything as I don't have any of these devices. So if someone is willing to pick this up that person can start with my branch. https://github.com/Hilbrand/openhab-addons/tree/smappee I'll leave it there, but have not time to continue working on it. But i think it might be a good starting point. |
Closing this pr for now due to long time not activity. I still have a branch with the improvements (e.g. new build system/OAuth2 support) that I will also keep in case someone wants to continue work on this binding. |
Signed-off-by: Niko Tanghe ntanghe@gmail.com
Introduction
The Smappee energy monitor monitors how much power your appliances consume and how much you gain from your solar power system in realtime. It can automatically detect the appliances based on their energy consumption pattern. Smappee also offers a water and a gas sensor consumption monitor.
Both the Energy monitor and the Solar energy monitor can be used. These can be bought online in the [smappee webshop] (http://www.smappee.com/be_en/eshop/monitors.html).
The smappee supports clamps for 3 phase and 1 phase systems and there is a separate circuit clamp for your solar system. Installation manuals can be found on their support page
Supported Things
This binding provides one bridge thing type : 'smappee'. There should be only one smappee device installed in your home.
This thing act like a bridge and represents your smappee monitor device and should be configured first. Once configured, this will autodetect all other smappee things.
Detected things:
Discovery
The smappee thing must be configured manually. Appliances, actuators and the sensors are autodetected.
Smappee thing configuration
As described on their [support page] (https://support.smappee.com/hc/en-us/articles/202153935-Where-can-I-find-the-API-documentation-), you need to email [support@smappee.com] (mailto:support@smappee.com) to get a client ID and a client secret to access the API. In that mail you need to provide them:
Following settings must be configured in order to make your smappee binding work:
Smappee Bridge
Appliance Thing
Actuator Thing
Sensor Thing
Channels
The following channels are supported:
Smappee Bridge
Appliance Thing
Actuator Thing
Sensor Thing
Full Example
A manual setup through a
things/smappee.things
file could look like this:A manual configuration through a
demo.items
file could look like this:The sitemap could look like this:
Testing
Questions ? Remarks ?
Leave a message on the forum topic https://community.openhab.org/t/smappee-binding/35670