Smappee Support?

Use this forum to discuss possible implementation of a new feature before opening a ticket.
A developer shall edit the topic title with "[xxx]" where xxx is the id of the accompanying tracker id.
Duplicate posts about the same id. +1 posts are not allowed.
mcduarte2000
Posts: 36
Joined: Friday 17 July 2015 5:12
Target OS: Raspberry Pi
Domoticz version:
Contact:

Re: Smappee Support?

Post by mcduarte2000 » Tuesday 18 August 2015 22:26

simonrg wrote:Ok so your house has 3 phase supply, I guess you are not in the UK where almost all domestic properties have single phase supply.
No, I have 1 phase, but I can split it in 3 different circuits, each serving a group of devices.

3 phases - "three phase"
3 single phases/circuits - "three single phases"
simonrg wrote:I guess obviously if you remove 2/3rds of the devices by putting them onto 2 new phases then Smappee has a better chance of identifying any appliance without overlap. My problem appears to be that all my devices are energy efficient and vary their power depending on demand, so ceramic hub, oven and microwave all look identical to Smappee.
Yeap. But if they are in different electrical circuits it could help. They use different circuit breakers right?
simonrg wrote:In terms of Domoticz then Domoticz will detect when Smappee tries to turn a plug on or off and you can assign these to Domoticz switches, which can then be used in scripts.
You are using the RFXtrx to detect the commands Smappee sends to the plugs? But why not send the commands directly from Domoticz to Smappee? Smappee API supports turning on and off the actuators.

https://smappee.atlassian.net/wiki/disp ... ctuator+ON
simonrg wrote:IWhere does your screenshot come from?
From the "Smappee monitor" - 192.your.smappee.ip/smappee.html

simonrg
Posts: 1071
Joined: Tuesday 16 July 2013 22:54
Target OS: Raspberry Pi
Domoticz version: 3.8807
Location: North East England
Contact:

Re: Smappee Support?

Post by simonrg » Tuesday 18 August 2015 22:54

mcduarte2000 wrote:I have 1 phase, but I can split it in 3 different circuits, each serving a group of devices.
:oops: get it now, I guess I am used to all my circuits being buried in walls, so hadn't thought of picking them out individually.
mcduarte2000 wrote:You are using the RFXtrx to detect the commands Smappee sends to the plugs? But why not send the commands directly from Domoticz to Smappee? Smappee API supports turning on and off the actuators.https://smappee.atlassian.net/wiki/disp ... ctuator+ON
The Smappee API does support turning on and off, but that require authentication, so would not be a rapid as a direct connection, where Domoticz would either be directly turning the plug off without involving Smappee or be sensing what Smappee is doing and recording the change of state.
mcduarte2000 wrote:
simonrg wrote:IWhere does your screenshot come from?
From the "Smappee monitor" - 192.your.smappee.ip/smappee.html
:oops: I didn't know it had this - its a shame its not possible to interact with the Smappee box this way, but only have the api to use.
Raspberry Pi 2 B - 2A@5V PSU - Raspbian + Domoticz + RFXtrx(89), LightwaveRF House(dimmers, sockets, wireless/mood switches), Owl CM113, 4 LaCross Temp / Humidity Sensors, 4 Siemens PIR, Smappee, Solaredge, ESP8266

mcduarte2000
Posts: 36
Joined: Friday 17 July 2015 5:12
Target OS: Raspberry Pi
Domoticz version:
Contact:

Re: Smappee Support?

Post by mcduarte2000 » Tuesday 18 August 2015 23:16

simonrg wrote:its a shame its not possible to interact with the Smappee box this way, but only have the api to use.
Actually you can (at least for the actuators). I remember seeing a comment, before the API, telling someone he could access it directly. They said for him to check the code on the page. ;)

mcduarte2000
Posts: 36
Joined: Friday 17 July 2015 5:12
Target OS: Raspberry Pi
Domoticz version:
Contact:

Re: Smappee Support?

Post by mcduarte2000 » Thursday 20 August 2015 12:27

mcduarte2000 wrote:
simonrg wrote:its a shame its not possible to interact with the Smappee box this way, but only have the api to use.
Actually you can (at least for the actuators). I remember seeing a comment, before the API, telling someone he could access it directly. They said for him to check the code on the page. ;)
Just made a little research, you can reach the local api with the following commands (were gateway is your smappee network IP):

Code: Select all

http://xxx.xxx.xxx.xxx/gateway/apipublic/logon
http://xxx.xxx.xxx.xxx/gateway/apipublic/statisticsPublicReport
http://xxx.xxx.xxx.xxx/gateway/apipublic/reportInstantaneousValues
http://xxx.xxx.xxx.xxx/gateway/apipublic/restartEMeter?action=2 (careful! not sure what it does)
http://xxx.xxx.xxx.xxx/gateway/apipublic/commandControlPublic
The Command Control refers to the actuators! :)

The code to turn on/off the actuators, I guess is:

Code: Select all

function onOffCommandControl(val) {
		
    	   	var url = baseURL + "/commandControlPublic";
			$.ajax(
				{
					 async : true,
					 type:'POST',
					 contentType: 'application/json',
					 url: url,
					 
					 data:"control,controlId="+val.id,
					 
					 dataType: 'json',
					 
					 success: function(data) {  
						console.log("control onOff success");
						setHeader(data.header);
						if (data.errror) setHeaderError(data.error);
						if (data.success) setHeaderSuccess(data.success);
					 },
					
					 error: function(data) {   
						 console.log("config save error");
						 alert("Error, "+data.response);
					 }
				 }
			 ); 
   		}
You can check all the code here:

http://xxx.xxx.xxx.xxx/commandcontrolpublic.html

And here, using this local API, an example using PHP which accesses the data directly:

http://www.loxoneforum.com/2015/07/read ... th-loxone/

simonrg
Posts: 1071
Joined: Tuesday 16 July 2013 22:54
Target OS: Raspberry Pi
Domoticz version: 3.8807
Location: North East England
Contact:

Re: Smappee Support?

Post by simonrg » Thursday 20 August 2015 13:05

mcduarte2000 wrote:Just made a little research, you can reach the local api with the following commands (were gateway is your smappee network IP):
Great, thanks - so as you said before basically the Smappee box has a web server on it and anything the web server lets you do in a browswer you can do programmatically.

It does rather beg the question of why use the Smappee remote servers to get the data if you can get it locally.

In terms of switching and communication between Domoticz and Smappee, then the only way to push information from Smappee to Domoticz, is by switching a plug (real or virtual) in Smappee which Domoticz then detects through RFXCOM and which can then be logged in Domoticz or trigger some action by Domoticz. Domoticz can pull information from Smappee either locally or remotely via http, and switch a switch via http, but as Smappee has no 433MHz recieve capability there is no link possible that way.

The other thing is that the Smappee box is talking to the Smappee servers regularly, so it would be possible to divert the communication via Domoticz and store all the information sent back to the remote servers directly into Domoticz, as has been done with the Solaredge inverters. Obviously things like remote updates to the Smappee box would need to be allowed back to the Smappee box.

I am still curious to get the geolocation working in Smappee on my iPhone as this is a function I have not set up elsewhere.
Raspberry Pi 2 B - 2A@5V PSU - Raspbian + Domoticz + RFXtrx(89), LightwaveRF House(dimmers, sockets, wireless/mood switches), Owl CM113, 4 LaCross Temp / Humidity Sensors, 4 Siemens PIR, Smappee, Solaredge, ESP8266

mcduarte2000
Posts: 36
Joined: Friday 17 July 2015 5:12
Target OS: Raspberry Pi
Domoticz version:
Contact:

Re: Smappee Support?

Post by mcduarte2000 » Thursday 20 August 2015 13:35

simonrg wrote:In terms of switching and communication between Domoticz and Smappee, then the only way to push information from Smappee to Domoticz, is by switching a plug (real or virtual) in Smappee which Domoticz then detects through RFXCOM and which can then be logged in Domoticz or trigger some action by Domoticz. Domoticz can pull information from Smappee either locally or remotely via http, and switch a switch via http, but as Smappee has no 433MHz recieve capability there is no link possible that way.
Yes, we are trying to do different things. To me it will be enough to send an on/off command directly from Domoticz and trust it changed the status correctly (it has been pretty reliable).
simonrg wrote:I am still curious to get the geolocation working in Smappee on my iPhone as this is a function I have not set up elsewhere.
:) When done, I can test. ;)

To others which may be interested (I will update on the Wiki when I have time):

To logon on the Smappee local API with curl:

Code: Select all

curl -H "Content-Type: application/json" -X POST -d "your_password" http://xxx.xxx.xxx.xxx/gateway/apipublic/logon
To turn on the plug with the ID 3 (it takes a second or two):

Code: Select all

curl -H "Content-Type: application/json" -X POST -d "control,controlId=1|3" http://xxx.xxx.xxx.xxx/gateway/apipublic/commandControlPublic
To turn off the plug with the ID 3:

Code: Select all

curl -H "Content-Type: application/json" -X POST -d "control,controlId=0|3" http://xxx.xxx.xxx.xxx/gateway/apipublic/commandControlPublic
To get a list of your plug IDs:

Code: Select all

curl -H "Content-Type: application/json" -X POST -d "load" http://xxx.xxx.xxx.xxx/gateway/apipublic/commandControlPublic

mcduarte2000
Posts: 36
Joined: Friday 17 July 2015 5:12
Target OS: Raspberry Pi
Domoticz version:
Contact:

Re: Smappee Support?

Post by mcduarte2000 » Friday 21 August 2015 13:32

Just added to the Domoticz wiki detailed information on how to control the Smappee plugs from Domoticz using bash scripts:

https://www.domoticz.com/wiki/Smappee#C ... ternal_API

steff2
Posts: 15
Joined: Saturday 13 December 2014 22:20
Target OS: Raspberry Pi
Domoticz version:
Contact:

Re: Smappee Support?

Post by steff2 » Monday 24 August 2015 21:47

Hi,

I have a smapee installed and happy that there is a way to get the readings into domoticz (my thanks for this).

I 'm tryning this on both my Beta domoticz and my Live system (one with tbe stable version one with the beta version).

I don't get values in, but a very big error log.
The variables are used and updated, the getting the data work but they all end up in the error file


This is my lua log

-------------------------------------------
2015-08-24 21:30:01 - Starting Smappee to Domoticz Energy Handler
2015-08-24 21:30:01 - -------------------------------------------
2015-08-24 21:30:01 - SmappeeClientSecret: ******
2015-08-24 21:30:01 - SmappeeClientID: ****
2015-08-24 21:30:01 - SmappeeUsername: *****
2015-08-24 21:30:01 - SmappeePassword: ******
2015-08-24 21:30:01 - DomoticzUsername:
2015-08-24 21:30:01 - DomoticzPassword:
2015-08-24 21:30:01 - DomoticzIP: 192.168.0.15
2015-08-24 21:30:01 - DomoticzPort: 8080
2015-08-24 21:30:01 - SmappeeHousehold: Home
2015-08-24 21:30:01 - SmappeeSolar: Solar1
2015-08-24 21:30:01 - JSON request <http://192.168.0.15:8080/json.htm?type= ... rvariables>
2015-08-24 21:30:01 - Domoticz returned getuservariables after 1 attempts
2015-08-24 21:30:01 - 3
2015-08-24 21:30:01 - SmappeeAccessToken idx 3
2015-08-24 21:30:01 - JSON request <http://192.168.0.15:8080/json.htm?type= ... able&idx=3>
2015-08-24 21:30:01 - Decoded be64ed44-3883-39e4-a6fd-8e2fde56507b
2015-08-24 21:30:01 - JSON request <http://192.168.0.15:8080/json.htm?type= ... rvariables>
2015-08-24 21:30:01 - Domoticz returned getuservariables after 1 attempts
2015-08-24 21:30:01 - 4
2015-08-24 21:30:01 - SmappeeRefreshToken idx 4
2015-08-24 21:30:01 - JSON request <http://192.168.0.15:8080/json.htm?type= ... able&idx=4>
2015-08-24 21:30:01 - Decoded 75d57140-c92e-3d73-b0fe-a39f16abd00b
2015-08-24 21:30:01 - JSON request <http://192.168.0.15:8080/json.htm?type= ... rvariables>
2015-08-24 21:30:01 - Domoticz returned getuservariables after 1 attempts
2015-08-24 21:30:01 - 5
2015-08-24 21:30:01 - SmappeeExpiresAt idx 5
2015-08-24 21:30:01 - JSON request <http://192.168.0.15:8080/json.htm?type= ... able&idx=5>
2015-08-24 21:30:01 - Decoded 1440528606
200
2015-08-24 21:30:02 - Smappee Service Location: 5320
2015-08-24 21:30:02 - JSON request <http://192.168.0.15:8080/json.htm?type= ... rvariables>
2015-08-24 21:30:02 - Domoticz returned getuservariables after 1 attempts
2015-08-24 21:30:02 - 6
2015-08-24 21:30:02 - SmappeeTimeStamp idx 6
2015-08-24 21:30:02 - JSON request <http://192.168.0.15:8080/json.htm?type= ... able&idx=6>
2015-08-24 21:30:02 - Decoded 1
2015-08-24 21:30:02 - Previous Time Stamp 2
2015-08-24 21:30:02 - Current Time Stamp: 1440444602
2015-08-24 21:30:02 - https://app1pub.smappee.net/dev/v1/serv ... 0444602000
2015-08-24 21:30:03 - 200

This is a part of my eroror log

lua: /usr/local/share/lua/5.2/JSON.lua:676: /usr/local/share/lua/5.2/JSON.lua:383: unclosed string at char 8101 of: {
"serviceLocationId": 5320,
"consumptions": [
{
"timestamp": 1439142600000,
"consumption": 65.7,
"solar": 0.0,
"alwaysOn": 481.0
},
...
"timesta
stack traceback:
[C]: in function 'assert'
/usr/local/share/lua/5.2/JSON.lua:676: in function 'decode'
/home/pi/domoticz_smappee/smappee.lua:319: in main chunk
[C]: in ?

any ideas (the error log seems to grow fast ...)

TX,
Stef

simonrg
Posts: 1071
Joined: Tuesday 16 July 2013 22:54
Target OS: Raspberry Pi
Domoticz version: 3.8807
Location: North East England
Contact:

Re: Smappee Support?

Post by simonrg » Monday 24 August 2015 23:18

steff2 wrote:Hi,

I have a smapee installed and happy that there is a way to get the readings into domoticz (my thanks for this).

I 'm tryning this on both my Beta domoticz and my Live system (one with tbe stable version one with the beta version).

I don't get values in, but a very big error log.
The variables are used and updated, the getting the data work but they all end up in the error file


This is my lua log
Spoiler: show
-------------------------------------------
2015-08-24 21:30:01 - Starting Smappee to Domoticz Energy Handler
2015-08-24 21:30:01 - -------------------------------------------
2015-08-24 21:30:01 - SmappeeClientSecret: ******
2015-08-24 21:30:01 - SmappeeClientID: ****
2015-08-24 21:30:01 - SmappeeUsername: *****
2015-08-24 21:30:01 - SmappeePassword: ******
2015-08-24 21:30:01 - DomoticzUsername:
2015-08-24 21:30:01 - DomoticzPassword:
2015-08-24 21:30:01 - DomoticzIP: 192.168.0.15
2015-08-24 21:30:01 - DomoticzPort: 8080
2015-08-24 21:30:01 - SmappeeHousehold: Home
2015-08-24 21:30:01 - SmappeeSolar: Solar1
2015-08-24 21:30:01 - JSON request <http://192.168.0.15:8080/json.htm?type= ... rvariables>
2015-08-24 21:30:01 - Domoticz returned getuservariables after 1 attempts
2015-08-24 21:30:01 - 3
2015-08-24 21:30:01 - SmappeeAccessToken idx 3
2015-08-24 21:30:01 - JSON request <http://192.168.0.15:8080/json.htm?type= ... able&idx=3>
2015-08-24 21:30:01 - Decoded be64ed44-3883-39e4-a6fd-8e2fde56507b
2015-08-24 21:30:01 - JSON request <http://192.168.0.15:8080/json.htm?type= ... rvariables>
2015-08-24 21:30:01 - Domoticz returned getuservariables after 1 attempts
2015-08-24 21:30:01 - 4
2015-08-24 21:30:01 - SmappeeRefreshToken idx 4
2015-08-24 21:30:01 - JSON request <http://192.168.0.15:8080/json.htm?type= ... able&idx=4>
2015-08-24 21:30:01 - Decoded 75d57140-c92e-3d73-b0fe-a39f16abd00b
2015-08-24 21:30:01 - JSON request <http://192.168.0.15:8080/json.htm?type= ... rvariables>
2015-08-24 21:30:01 - Domoticz returned getuservariables after 1 attempts
2015-08-24 21:30:01 - 5
2015-08-24 21:30:01 - SmappeeExpiresAt idx 5
2015-08-24 21:30:01 - JSON request <http://192.168.0.15:8080/json.htm?type= ... able&idx=5>
2015-08-24 21:30:01 - Decoded 1440528606
200
2015-08-24 21:30:02 - Smappee Service Location: 5320
2015-08-24 21:30:02 - JSON request <http://192.168.0.15:8080/json.htm?type= ... rvariables>
2015-08-24 21:30:02 - Domoticz returned getuservariables after 1 attempts
2015-08-24 21:30:02 - 6
2015-08-24 21:30:02 - SmappeeTimeStamp idx 6
2015-08-24 21:30:02 - JSON request <http://192.168.0.15:8080/json.htm?type= ... able&idx=6>
2015-08-24 21:30:02 - Decoded 1
2015-08-24 21:30:02 - Previous Time Stamp 2
2015-08-24 21:30:02 - Current Time Stamp: 1440444602
2015-08-24 21:30:02 - https://app1pub.smappee.net/dev/v1/serv ... 0444602000
2015-08-24 21:30:03 - 200
This is a part of my eroror log
Spoiler: show
lua: /usr/local/share/lua/5.2/JSON.lua:676: /usr/local/share/lua/5.2/JSON.lua:383: unclosed string at char 8101 of: {
"serviceLocationId": 5320,
"consumptions": [
{
"timestamp": 1439142600000,
"consumption": 65.7,
"solar": 0.0,
"alwaysOn": 481.0
},
...
"timesta
stack traceback:
[C]: in function 'assert'
/usr/local/share/lua/5.2/JSON.lua:676: in function 'decode'
/home/pi/domoticz_smappee/smappee.lua:319: in main chunk
[C]: in ?
any ideas (the error log seems to grow fast ...)

TX,
Stef
Steff, it looks like you are not running the latest version, so it looks like it is trying to load all your past energy usage, which not only makes it crash but is unhelpful, as it has to assume you have consumed all the energy in the last 5 minutes.

Ideally replace your current version with the latest version, which corrects this automatically, assuming you have SmappeeTimeStamp set to 1 as detailed in the nstallation instructions, so just set SmappeeTimeStamp to 1 in Domoticz.

The other approach is to do the calculation your self, your previous timestamp is currrently 2 as set in Domoticz, if you change this to something only 300seconds less than the current timestamp, this will just bring in the last 5 minutes data and so not overload the limited buffer. The timestamp displayed is in milliseconds, so you need to divide by 1000 and then substract 300, put this into Domoticz as SmappeeTimeStamp.

Hopefully that should then work.

Simon
Raspberry Pi 2 B - 2A@5V PSU - Raspbian + Domoticz + RFXtrx(89), LightwaveRF House(dimmers, sockets, wireless/mood switches), Owl CM113, 4 LaCross Temp / Humidity Sensors, 4 Siemens PIR, Smappee, Solaredge, ESP8266

steff2
Posts: 15
Joined: Saturday 13 December 2014 22:20
Target OS: Raspberry Pi
Domoticz version:
Contact:

Re: Smappee Support?

Post by steff2 » Monday 24 August 2015 23:59

TX for you help.

I have used the info from the wiki to te letter, I have again downloaded the files from https://github.com/steps39/Domoticz_Smappee and placed them over the current ones with but no differences.

The SmappeeTimeStamp was on 1.

I still have the same errors.

Is the github above the correct location?
should git clone https://github.com/steps39/domoticz_smappee.git not get me the latest version (I installed yesterday)

what other value can I use for SmappeeTimeStamp?

Regards,
Steff

simonrg
Posts: 1071
Joined: Tuesday 16 July 2013 22:54
Target OS: Raspberry Pi
Domoticz version: 3.8807
Location: North East England
Contact:

Re: Smappee Support?

Post by simonrg » Wednesday 26 August 2015 0:19

steff2 wrote:TX for you help.

I have used the info from the wiki to te letter, I have again downloaded the files from https://github.com/steps39/Domoticz_Smappee and placed them over the current ones with but no differences.

The SmappeeTimeStamp was on 1.

I still have the same errors.

Is the github above the correct location?
should git clone https://github.com/steps39/domoticz_smappee.git not get me the latest version (I installed yesterday)

what other value can I use for SmappeeTimeStamp?

Regards,
Steff
If you use the current timestamp in the Domoticz variable, then it should behave itself, so from your previous log, then look at your current log and pick this value:

Code: Select all

2015-08-24 21:30:02 - Current Time Stamp: xxxxxxxxx
After 10 minutes or so it should start to pick up values.

One last thing to check is that your SmappeeTimeStamp variable is of type String not integer.
Raspberry Pi 2 B - 2A@5V PSU - Raspbian + Domoticz + RFXtrx(89), LightwaveRF House(dimmers, sockets, wireless/mood switches), Owl CM113, 4 LaCross Temp / Humidity Sensors, 4 Siemens PIR, Smappee, Solaredge, ESP8266

steff2
Posts: 15
Joined: Saturday 13 December 2014 22:20
Target OS: Raspberry Pi
Domoticz version:
Contact:

Re: Smappee Support?

Post by steff2 » Wednesday 26 August 2015 11:48

TX, that worked.

dagasoft
Posts: 12
Joined: Thursday 03 December 2015 15:11
Target OS: Raspberry Pi
Domoticz version:
Contact:

Re: Smappee Support?

Post by dagasoft » Thursday 03 December 2015 15:28

Hi.

I ordered a Smappee and I'm waiting for it to arrive. I was reading in the thread that mcduarte2000 split power consumption between 3 different circuits using the three clamps. I was thinking about use one clamp in the main phase and then use the other two clamps on two subcircuits (water heater, oven, ...) to monitor separately, but AFAIK it seems that doing it that way Smappee would add subcircuit comsumption clamp to main consumption clamp.

How did you do it? Plug each of the 3 clamps in 3 different circuits that cover all the electrical installation or how? I would like to give use to the two unused clamps to improve accurateness. But maybe this is not needed and only with the main clamp Smappee would detect devices accurately. I think I will have to test, but anyway I would like to know your opinion.

By the way, lots of thanks for the work of how to get Smappee working with Domoticz. I will set it up as soon as it arrives.

P.S: When you use the 3 clamp setup, do you get good readings at Smappee application or is it a mess?

mcduarte2000
Posts: 36
Joined: Friday 17 July 2015 5:12
Target OS: Raspberry Pi
Domoticz version:
Contact:

Re: Smappee Support?

Post by mcduarte2000 » Tuesday 08 December 2015 11:10

dagasoft wrote:Hi.

I ordered a Smappee and I'm waiting for it to arrive. I was reading in the thread that mcduarte2000 split power consumption between 3 different circuits using the three clamps. I was thinking about use one clamp in the main phase and then use the other two clamps on two subcircuits (water heater, oven, ...) to monitor separately, but AFAIK it seems that doing it that way Smappee would add subcircuit comsumption clamp to main consumption clamp.

How did you do it? Plug each of the 3 clamps in 3 different circuits that cover all the electrical installation or how? I would like to give use to the two unused clamps to improve accurateness. But maybe this is not needed and only with the main clamp Smappee would detect devices accurately. I think I will have to test, but anyway I would like to know your opinion.

By the way, lots of thanks for the work of how to get Smappee working with Domoticz. I will set it up as soon as it arrives.

P.S: When you use the 3 clamp setup, do you get good readings at Smappee application or is it a mess?
Hi! I still have not done it, but had received this suggestion from support. Maybe you should contact them and discuss it in more detail. :) And then share with us how things went.

My problem is AC which confuses Smappee when it's on. The oven shouldn't be a problem, water heater also shouldn't be a problem (always the same potence, right?), vitroceramic is.

tomben
Posts: 1
Joined: Monday 08 February 2016 23:07
Target OS: Raspberry Pi
Domoticz version:
Contact:

Re: Smappee Support?

Post by tomben » Monday 08 February 2016 23:14

Hi All,
First of all, thank you for this fine script.
I struggled at first, but finally put the SmappeeTimeStamp as string, something I didn't get it from the docs.
But I kept having errors, and I finally found out that the timestamps were wrong, and indeed, the timezone was not set correctly on my rPi.
I changed it and tadaaa, it works.
For your info, I used this link to correct my timezone for NTP : http://ifzenelse.net/fr/tip/changer-de- ... x-centos-7

Cheers,

Absolut
Posts: 15
Joined: Tuesday 29 March 2016 11:05
Target OS: Raspberry Pi
Domoticz version:
Contact:

Re: Smappee Support?

Post by Absolut » Tuesday 29 March 2016 15:59

Hi,

Has anyone already ordered a Smappee Water & Gas meter?
I received mine last week, and use it to track my water usage.
My goal would be to also integrate it into Domoticz.

Link:
http://www.smappee.com/be_en/gas-and-water-monitor

niceandeasy
Posts: 147
Joined: Thursday 28 January 2016 23:25
Target OS: Raspberry Pi
Domoticz version: 3.8153
Location: NL
Contact:

Re: Smappee Support?

Post by niceandeasy » Thursday 31 March 2016 22:54

I have both: the Smappee electricity unit and the gas & water unit.
It seems that no one created scripting for that, yet. I'm planning to build something that will take all of the usage values directly from the Smappee Electricity meter into Domoticz, without using their cloud services. But for now, the water and gas values are not available in the local API, as far as I know. So, I'm stuck until they are willing to implement or disclose that. (I didn't ask for it, yet, but I will.)

If you have only the water & gas unit, you don't have much to go on. In that case, you need to rely on your smartphone app, occasionally getting the values by bluetooth and forwarding it to the cloud, from which you should be able to retrieve it in Domoticz, using scripting, yet to be developed by someone. I guess.

If you have both, then the electricity unit gets the water & gas values by using 433MHz communication and everything should work much more like real-time. I wasn't able to sniff that 433MHz communication out, yet, by RFXcom/Domoticz. Well, I found an extra rain meter but the numbers don't make sense, so I think that that signal is coming from a neighbor. I'm not even sure if the Smappee water & gas unit is in range of my RFXcom. And testing means that I need to leave the water tap running. Maybe I should just run RFXMgr in undec mode on the laptop, set it next to the water & gas unit, use water and move a magnet over the gas usage sensor. From the log files, I might learn that I just need to move the water & gas unit closer to the RFXcom's usual position, and if not, I can only forward the log files to the RFXcom dev and hope for the best.
But again, if you only have the water & gas unit, it will not send any 433MHz data, because the smartphone app 'knows' that you don't have the receiving electricity measuring unit and it will deem the sending of 433MHz data as a waste of battery power.

Yes, "moving a magnet over the gas usage sensor". Because my house is fitted with a gas meter from the dark ages. I could not find a changing magnetic field yet, and there are no reflective surfaces on the number reels. So I can't sense my gas usage in a practical way with Smappee. And with only water usage values, I now realize that there's cheaper ways to record water usage data in Domoticz. Oh well... maybe I could use that magnetic sensor to record how many times the front door opens per day and per week/month/year. lol

If you plan to buy the Smappee water & gas... the unit comes with an optical sensor and a magnetic sensor. If you ready know that you would need for example two optical sensors and no magnetic sensor for your specific metering equipment, make sure to order an extra optical sensor.

EDIT:
The electriciy meter comes with a DIO pluggable switch. If you have Domoticz with a 433MHz tranceiver, don't even bother to learn that plug to the Smappee. Learn it to Domoticz. That gives you much more control options. And if you want to use specific Smappee 'triggers'/'events' for a switch, you can learn that Smappee signal to Domoticz and use it there. Again, much more flexibility.
And if you don't have a 433MHz-tranceiver for Domoticz, you could (mis)use your Smappee as a simple 433MHz-transmitter and get more 433MHz switches. (I didn't try if I can control dimmers with Smappee. Probably not.)

Absolut
Posts: 15
Joined: Tuesday 29 March 2016 11:05
Target OS: Raspberry Pi
Domoticz version:
Contact:

Re: Smappee Support?

Post by Absolut » Wednesday 06 April 2016 11:11

Thanks for the reply.

Regarding the sniffing of the 433Mhz of the Water&Gas unit I can already disappoint you.
I checked with Smappee support and they confirmed me that they're using an encrypted FSK (proprietary) protocol over 433Mhz, so it's impossible to sniff using an RFXcom.

To answer your question:
Yes I have both the gateway and water&gas-unit, though only using the water with the pulse/magnetic meter, as I don't have gas in my neighborhood.

niceandeasy
Posts: 147
Joined: Thursday 28 January 2016 23:25
Target OS: Raspberry Pi
Domoticz version: 3.8153
Location: NL
Contact:

Re: Smappee Support?

Post by niceandeasy » Wednesday 15 June 2016 22:53

I made a bash script, all by myself. It gets Volts, Amps, Watts & usage, cos-phi values and puts it in Domoticz, every minute.
It's made for a Smappee with one usage pickup coil, so no 3-phase, no solar.
It runs every minute, by crontab, on the Domoticz host. (Raspberry)

Code: Select all

# THIS single script takes Smappee data and puts it in Domoticz dummy sensors
#VERSION 1.1 (changed the AMPS sed line a bit, because sed was off by a backslash just before it, in the smappee output)
#VERSION 1.2 (changed the WH handling, because earlier, it didn't initialize properly, somehow. ...and some minor things...
# uses CURL, for talking http
# uses SED, for sifting out what I need from Smappee's output
# uses BC, for calculating cumulative usage
SMAP=`curl http://smappeeip/gateway/apipublic/reportInstantaneousValues`
ERR=`echo $SMAP|grep -c Couldn`
# 'Couldn' means that curl couldn't do what's needed, for example, when Smappee's network connection is temporarily out
# So if no error, we continue to try to get values from Smappee
# Else, we get the previous values stored in /tmp
if [ $ERR != 1 ]
then
ERR=`echo $SMAP|grep -c error`
# 'error' means that Smappee answered with an error, most likely, not logged in
if [ $ERR == 1 ]; then curl -H "Content-Type: application/json" -X POST -d "admin" http://smappeeip/gateway/apipublic/logon ; SMAP=`curl http://smappeeip/gateway/apipublic/reportInstantaneousValues`; fi
VOLTS=`echo $SMAP |sed -e 's|.*voltage=\(.*\)|\1|' -e 's|\(.\{1,5\}\).*|\1|'`
WATTS=`echo $SMAP |sed -e 's|.* activePower=\(.*\)|\1|' -e 's|\(.\{1,6\}\).*|\1|'`
AMPS=`echo $SMAP |sed -e 's|.*urrent=\(.*\)|\1|' -e 's|\(.\{1,4\}\).*|\1|'`
COSF=`echo $SMAP |sed -e 's|.* cosfi=\(.*\)|\1|' -e 's|\(.\{1,2\}\).*|\1|'`
else
VOLTS=`cat /tmp/volts`
WATTS=`cat /tmp/watts`
AMPS=`cat /tmp/amps`
COSF=`cat /tmp/cosf`
fi
# just in case there's still nothing there...
if [ 1$VOLTS == 1 ]; then let "VOLTS=230"; fi
if [ 1$WATTS == 1 ]; then let "WATTS=460"; fi
if [ 1$AMPS == 1 ]; then let "AMPS=2"; fi
if [ 1$COSF == 1 ]; then let "COSF=1"; fi
# Save this. If Smappee is not in mood at next run, we'll use these instead.
echo $VOLTS >/tmp/volts
echo $WATTS >/tmp/watts
echo $AMPS  >/tmp/amps
echo $COSF  >/tmp/cosf
#Put the voltage, amps and cos phi to Domoticz
curl "http://localhost:8080/json.htm?type=command&param=udevice&idx=372&nvalue=0&svalue="$VOLTS
curl "http://localhost:8080/json.htm?type=command&param=udevice&idx=376&nvalue=0&svalue="$AMPS
curl "http://localhost:8080/json.htm?type=command&param=udevice&idx=377&nvalue=0&svalue="$COSF
# CUM is the cumulative watthour value
# Domoticz wants watthours, so that's why watthour
# To make sure we have a CUM value:
[ -f /tmp/wh ] && echo wh present || echo 0.0001 >/tmp/wh
CUM=`cat /tmp/wh`
# In case there's still no good CUM yet..
if [ 1$CUM == 1 ]; then let "CUM=1"; fi
# By resetting the WH cumulative like this, we might see strange jumps in the kWh usage graphs.
# But if WH fails (/tmp/wh empty), Domoticz also stops showing and registering WATTs and the log fails.
#
#Calc new WattHour value
WH=`echo $WATTS\*0.0166667+$CUM|bc`
echo $WH >/tmp/wh
# the 0.0166667 number is 1/60, meaning, we take 60 measurements per hour, adding to the cumulative.
# Now put the watts and the watthours to Domoticz
CURLURL="http://localhost:8080/json.htm?type=command&param=udevice&idx=371&nvalue=0&svalue="$WATTS";"$WH""
curl $CURLURL
Everywhere where it says smappeeip, the ip-address of your smappee should be entered.
There's a line with "admin", which is the default password for the Smappee. Replace that with your own local Smappee password.
In the json curl statements, replace the IDX values for your own.
If your Domoticz requires authentication, you'll have to add that to the json curl statements.
My /tmp is mounted on RAM, so it won't wear out my SD card.
This script might contain lines that might hurt the eye of the experienced Bash script programmer. I am not an experienced Bash programmer. I'm just happy it runs without errors on my Raspberry.

Use it at your own risk, if you dare. Or use my ideas to improve on your own script.
Good suggestions are very welcome.

An issue with this...
Domoticz does not store the average of every five measurements per 5 minute period in it's log. It only takes the last of the five measurements and stores that in it's log. Suppose that my background usage is 300W and at 18:46 I turn on hi-power electrical equipment (oven, room heater) and I turn it all off at 18:49. At 19:00, Domoticz would have registered that in the Watt / Usage log? Yes and no. The Watt line will not show any peak. However, the usage bars will be registering it.
If I would average it out in my script, then I can send my averaged data to Domoticz once in five minutes. I can even take measurements every five minutes, instead of every minute. Then, for sure, Domoticz won't know about my short electricity usage binges. So, I've chosen to send to Domoticz every minute. That will make the meters on the utility tab more like 'real-time' than it would be with a five minute interval.
The only workaround would be to use different meters for logging and for displaying 'real-time' Watt values and feeding those with optimal feeds at optimal intervals.

EDIT:
The cos phi value should be divided by 100. I forgot that and I was in no mood to:
- add that division
- delete and recreate the custom dummy sensor for it, in order to delete the history, because that transition would look weird, in there.
- put the new idx value in the curl statement.
- losing my history.
I think I'll just put a % in the axis label, to make it mathematically correct.
EDIT:
- Corrected a mistake and put a version number in the code.
- There must be a fault in my error-checking code; the lines that test if a string is empty. ...testing...
EDIT:
- I think I fixed my error, so, new version of the script is pasted, above.
Last edited by niceandeasy on Tuesday 26 July 2016 0:10, edited 2 times in total.

oeble
Posts: 2
Joined: Monday 27 June 2016 12:31
Target OS: Raspberry Pi
Domoticz version: 3.8153
Contact:

Re: Smappee Support?

Post by oeble » Monday 27 June 2016 12:48

Hi ,

Your script almost does the job for me ,
I'm using it on Domoticz running on a Synology NAS and can now read the Smappee values into Domoticz.
I have some smaller issues however , maybe someone can help ?.

When i run the bash script manually i can see the KW values in the tmp(kw) file and they also ad up.
When however i run the script as cronjob the file is empty , and i dont know where the counter gets its values from ( and if they are correct ).

This being said , what type of KWH counter should i use in Domoticz ? , i'm not sure now.

Thanks,

Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests