Smappee Support?
Moderators: leecollings, remb0
-
- Posts: 102
- Joined: Thursday 28 January 2016 22:25
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 3.8153
- Location: NL
- Contact:
Re: Smappee Support?
Thanks, Oeble.
For me, it's also almost working, lol. I was wondering why my script was not gathering data anymore. I think, since my Raspberry rebooted. Now I read your post, I start the script manually, and it started working again. So, I see the same issue as you do. But currently, I don't really have time to look into it. At least, now I know where to look.
I think, the cron user is maybe not the same or not the same rights as the user that I use for CLI login. I'm on Raspberry, so I use user pi. I need to look into it, with my limited Linux knowledge, lol.
For Watts and kWh, I'm using the Domoticz Dummy sensor "Electric (Instant+counter)", which can be added from the Hardware, Dummy, Create virtual sensors. I also added Voltage and Ampere (1 phase), and a Custom sensor for Cos Phi.
EDIT:
I debugged my script. Now it seems to initialize properly. Current script is pasted in my earlier post.
/tmp is a tmpfs partition, which exists in RAM, which is flushed on reboots. My script files are in RAM because I don't want to wear out my SD card by writing every minute. So, frequent reboots will mess up the log stats, unless you reboot just after midnight.
EDIT:
Meh.. still not working properly. Maybe it just doesn't run anymore, because the dummy sensors are going red. I'll reboot the raspi and see how it goes..
For me, it's also almost working, lol. I was wondering why my script was not gathering data anymore. I think, since my Raspberry rebooted. Now I read your post, I start the script manually, and it started working again. So, I see the same issue as you do. But currently, I don't really have time to look into it. At least, now I know where to look.
I think, the cron user is maybe not the same or not the same rights as the user that I use for CLI login. I'm on Raspberry, so I use user pi. I need to look into it, with my limited Linux knowledge, lol.
For Watts and kWh, I'm using the Domoticz Dummy sensor "Electric (Instant+counter)", which can be added from the Hardware, Dummy, Create virtual sensors. I also added Voltage and Ampere (1 phase), and a Custom sensor for Cos Phi.
EDIT:
I debugged my script. Now it seems to initialize properly. Current script is pasted in my earlier post.
/tmp is a tmpfs partition, which exists in RAM, which is flushed on reboots. My script files are in RAM because I don't want to wear out my SD card by writing every minute. So, frequent reboots will mess up the log stats, unless you reboot just after midnight.
EDIT:
Meh.. still not working properly. Maybe it just doesn't run anymore, because the dummy sensors are going red. I'll reboot the raspi and see how it goes..
-
- Posts: 13
- Joined: Tuesday 23 August 2016 11:24
- Target OS: Raspberry Pi / ODroid
- Domoticz version: beta
- Location: Spain
- Contact:
Re: Smappee Support?
Hi everyone,
To ease the development, improvement of the script, I did a refactor of the code, extracted the important variables, worked on a documentation (README.md) and uploaded all to Github. Now I hope it will be easier for every one to start using this script.
niceandeasy, of course all the credit is yours (and is clearly specified in the Github repo). If you have any problem, just tell me and I'll delete the repo, I just wanted to have the initiative to keep this kind of good stuff alive, so thank you for your work
Repo is here: https://github.com/apazga/smappee-domoticz-bash
Best regards,
Abel.
To ease the development, improvement of the script, I did a refactor of the code, extracted the important variables, worked on a documentation (README.md) and uploaded all to Github. Now I hope it will be easier for every one to start using this script.
niceandeasy, of course all the credit is yours (and is clearly specified in the Github repo). If you have any problem, just tell me and I'll delete the repo, I just wanted to have the initiative to keep this kind of good stuff alive, so thank you for your work
Repo is here: https://github.com/apazga/smappee-domoticz-bash
Best regards,
Abel.
-
- Posts: 102
- Joined: Thursday 28 January 2016 22:25
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 3.8153
- Location: NL
- Contact:
Re: Smappee Support?
Hi,
I'm honored. lol. Never thought that my stuff would end up over there at github. Never used it for development. Only for downloading stuff.
So, ... Time to sign up at GitHub. I quickly took a look at the readme and the code. Well done, Abel. Nice job. I already learned some things that were new to me from your work. Thanks. As soon as the weather over here gets a bit more suitable for coding, I'll dive into it. I'll try to put in some new findings which are still test-running at my own Domoticz RPI. And I'll modify my earlier post: I'll replace the code block with the GitHub URL.
This is good. I like the idea that somebody else can now expand it for Smappee 3-phase setup or Smappee solar setup.
Just... I never contributed to GitHub before. If there's something I should know, please share.
EDIT: Meh.. niceandeasy github username already taken..
I'm honored. lol. Never thought that my stuff would end up over there at github. Never used it for development. Only for downloading stuff.
So, ... Time to sign up at GitHub. I quickly took a look at the readme and the code. Well done, Abel. Nice job. I already learned some things that were new to me from your work. Thanks. As soon as the weather over here gets a bit more suitable for coding, I'll dive into it. I'll try to put in some new findings which are still test-running at my own Domoticz RPI. And I'll modify my earlier post: I'll replace the code block with the GitHub URL.
This is good. I like the idea that somebody else can now expand it for Smappee 3-phase setup or Smappee solar setup.
Just... I never contributed to GitHub before. If there's something I should know, please share.
EDIT: Meh.. niceandeasy github username already taken..
-
- Posts: 13
- Joined: Tuesday 23 August 2016 11:24
- Target OS: Raspberry Pi / ODroid
- Domoticz version: beta
- Location: Spain
- Contact:
Re: Smappee Support?
Hi!
Perfect! The best way to start working with Github if you do not usually use "git" in terminal, is using "Github Desktop" official app to clone the repo.
Then the usual way to collaborate in a repo is to fork it (a copy for modifications will be done to your account), clone it to your computer & modify it with your preferred editor in your computer (I use Atom) and then send pull-requests to the repo to suggest merging the improvements/fixes did to the code.
If you are going to do little changes, you can also do it online, using the integrated editor from Github in the the forked repo (in this case, due to is a simple script, it may be an easy way to do it). I suggest you to create, modify, etc. a testing repo in your account to test the functionalities you want from Github, it's free
About the name, don't worry, choose another one and I'll link your profile from the README.md to avoid confusion with that old & inactive "niceandeasy" user from Github.
EDIT: I guess you are growveggies, right?
Anyway in this case, you won't need to fork this repo, because we will be collaborators in the same repo (I'll add your user when you confirm me that your name ) and you will be able to upload modifications without sending a merge request. If you don't want to modify directly the main repo, we can create a test or new feature branch, and after some time/testing, merge it to the main (master) branch.
Perfect! The best way to start working with Github if you do not usually use "git" in terminal, is using "Github Desktop" official app to clone the repo.
Then the usual way to collaborate in a repo is to fork it (a copy for modifications will be done to your account), clone it to your computer & modify it with your preferred editor in your computer (I use Atom) and then send pull-requests to the repo to suggest merging the improvements/fixes did to the code.
If you are going to do little changes, you can also do it online, using the integrated editor from Github in the the forked repo (in this case, due to is a simple script, it may be an easy way to do it). I suggest you to create, modify, etc. a testing repo in your account to test the functionalities you want from Github, it's free
About the name, don't worry, choose another one and I'll link your profile from the README.md to avoid confusion with that old & inactive "niceandeasy" user from Github.
EDIT: I guess you are growveggies, right?
Anyway in this case, you won't need to fork this repo, because we will be collaborators in the same repo (I'll add your user when you confirm me that your name ) and you will be able to upload modifications without sending a merge request. If you don't want to modify directly the main repo, we can create a test or new feature branch, and after some time/testing, merge it to the main (master) branch.
-
- Posts: 13
- Joined: Tuesday 23 August 2016 11:24
- Target OS: Raspberry Pi / ODroid
- Domoticz version: beta
- Location: Spain
- Contact:
Re: Smappee Support?
Hi!
I just added another bash script to add the possibility to list Smappee plugs and then control them from Domoticz:
https://github.com/apazga/smappee-domoticz-bash
I just added another bash script to add the possibility to list Smappee plugs and then control them from Domoticz:
https://github.com/apazga/smappee-domoticz-bash
-
- Posts: 2
- Joined: Friday 27 February 2015 22:57
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: Smappee Support?
Hi,
I started a Smappee/Domoticz connector in Python.
It works outside of domoticz (as a separate daemon) and polls the smappee box for informations. It does NOT need Smappee ClientID/ClientSecret since it directly connects to the Smappee box that lives in your LAN/Wifi, not the the Smappee.com website.
Currently, many things are hardcoded to fit my needs : I installed the smappee box 2 days ago and started writing the plugin only yesterday...
It has the following features :
-polls the Smappee box at configured interval (0.5s in my case) and asks for instantaneous readings
-reads phase0/phase1, the former being the grid consumption, the latter the solar production
-integrate the Energy (Wh) over both counters
-sends the values to domoticz with an other configured interval.
-updaters are running in separate threads, which means that the domoticz update is independent to the smappee reading thread.
You need to create virtual Energy devices in domoticz and set there ids in the code
This is a starting project, and my releasing here is only intended to get your opinions about it. I do not expect anybody to use it "as is" since many (many!) things should be done in a more modular way. This may come later but I won't give any roadmap.
I should try to connect it to a virtual P1 Smart meter instead of an energy counter, but I'm not sure it will perfectly fit my needs and need more investigations.
I will also try to be in touch with Smappee support, since small additions to the smappee firmware could allow big improvements in the script. In particular, my box has 6 CT (current transformers) but if I want the Smappee App to work right, I need to tell him to use only 2 of them (one for the grid consumption, the other one for the solar panel). It would be very interesting to be able to connect the other 4 CTs and get their readings in the JSON API to feed domoticz without lying to Smappe by telling that my electrical setting is tri-phased... (in my electrical setting for example, I have a line dedicated to the electrical heaters, one line for the water-heater, one for the computers, one for the oven, and having a seperate reading for these lines would be a good idea).
It would also be interesting to get the readings without polling the HTTP API : I'm pretty sure the box could periodically send the values to the client, which would dramatically reduce the CPU consumption on the box...
The code is here :
https://github.com/goulou/smappee_domoticz
I started a Smappee/Domoticz connector in Python.
It works outside of domoticz (as a separate daemon) and polls the smappee box for informations. It does NOT need Smappee ClientID/ClientSecret since it directly connects to the Smappee box that lives in your LAN/Wifi, not the the Smappee.com website.
Currently, many things are hardcoded to fit my needs : I installed the smappee box 2 days ago and started writing the plugin only yesterday...
It has the following features :
-polls the Smappee box at configured interval (0.5s in my case) and asks for instantaneous readings
-reads phase0/phase1, the former being the grid consumption, the latter the solar production
-integrate the Energy (Wh) over both counters
-sends the values to domoticz with an other configured interval.
-updaters are running in separate threads, which means that the domoticz update is independent to the smappee reading thread.
You need to create virtual Energy devices in domoticz and set there ids in the code
This is a starting project, and my releasing here is only intended to get your opinions about it. I do not expect anybody to use it "as is" since many (many!) things should be done in a more modular way. This may come later but I won't give any roadmap.
I should try to connect it to a virtual P1 Smart meter instead of an energy counter, but I'm not sure it will perfectly fit my needs and need more investigations.
I will also try to be in touch with Smappee support, since small additions to the smappee firmware could allow big improvements in the script. In particular, my box has 6 CT (current transformers) but if I want the Smappee App to work right, I need to tell him to use only 2 of them (one for the grid consumption, the other one for the solar panel). It would be very interesting to be able to connect the other 4 CTs and get their readings in the JSON API to feed domoticz without lying to Smappe by telling that my electrical setting is tri-phased... (in my electrical setting for example, I have a line dedicated to the electrical heaters, one line for the water-heater, one for the computers, one for the oven, and having a seperate reading for these lines would be a good idea).
It would also be interesting to get the readings without polling the HTTP API : I'm pretty sure the box could periodically send the values to the client, which would dramatically reduce the CPU consumption on the box...
The code is here :
https://github.com/goulou/smappee_domoticz
Re: Smappee Support?
Hello guys,
i'm using the smappee (+gas&water) too and would like to export the data to domoticz. My problem is that my (common german) power connection has 3 phases and all infos i've found are only for one phase. Can someone please explain how to modify the script for a 3 phase usage. Thanks!
Cheers
hellfish
i'm using the smappee (+gas&water) too and would like to export the data to domoticz. My problem is that my (common german) power connection has 3 phases and all infos i've found are only for one phase. Can someone please explain how to modify the script for a 3 phase usage. Thanks!
Cheers
hellfish
Re: Smappee Support?
tomvanswam wrote:Hi,
I posted a script that is able to collect the Smappee usage data from their API.
You can find it here: http://pastebin.com/1Et4n8VP.
Instructions:Have fun with it!Code: Select all
#Move to your domoticz script folder cd domoticz/script/ # Download the script: use wget, or copy/paste from the link into a file called smappee.sh #Make executable sudo chmod ugo+x smappee.sh #Add virtual Energy counter to Domoticz #Change login details to Smappee and Domoticz #And change sensor IDX in script nano smappee.sh #check if you have all the dependancies installed (listed in smappee.sh) #setup the power counter sudo echo "0" > /var/log/smappee.kwh #change Crontab for root sudo crontab -e #add the following line: */5 * * * * /home/pi/domoticz/scripts/smappee.sh # replace /home/pi/ with the folder your domotics install is at #Everything should be ok, and every 5 min the kWh value and Watt value will update
If anything is not working (as expected) don't hesitate to drop me a PM or mail.
I try this method but not work. the only think that i don't know is where i..."Create household and solar energy meters in Domoticz with the names set in the environment variables SmappeeHousehold and SmappeeSolar (even if you only have one meter, you have to create both meters for the script to work).??
- Egregius
- Posts: 2582
- Joined: Thursday 09 April 2015 12:19
- Target OS: Linux
- Domoticz version: v2024.7
- Location: Beitem, BE
- Contact:
Re: Smappee Support?
Never saw this topic before so I created my own smappee support, in PHP of course:
It's executed every 5 seconds so it can act as a big light meter.
Solar and power consumption are stored in apcu cache and in a MySQL database for later analysis. If the consumption is more than 8000W+Current solar power I receive a warning (my electricity net can only handle 40A or 9600W).
Code: Select all
<?php
$smappeeip='192.168.2.177';
$smappee=json_decode(file_get_contents('http://'.$smappeeip.'/gateway/apipublic/reportInstantaneousValues'),true);
if(!empty($smappee['report'])){
preg_match_all("/ activePower=(\\d*.\\d*)/",$smappee['report'],$matches);
if(!empty($matches[1][1])){
$zon=round($matches[1][1],0);
apcu_store('zon',$zon);
if(!empty($matches[1][2])){
$consumption=round($matches[1][2],0);
apcu_store('consumption',$consumption);
$timestamp=strftime("%Y-%m-%d %H:%M:%S",time);
$query="INSERT INTO `smappee` (`timestamp`,`consumption`) VALUES ('$timestamp','$consumption');";
$db=new mysqli('server','user','pass','db');if($db->connect_errno>0)die('Unable to connect to database [' . $db->connect_error . ']');if(!$result=$db->query($query))die('There was an error running the query ['.$query .' - ' . $db->error . ']');$db->close();
if($consumption>(8000+$zon)){
if(apcu_fetch('notify_power')<time-3600){
apcu_store('notify_power',time);
telegram('Power usage: '.$consumption.' W!',false);
}
}
}
}
}else{
if(shell_exec('curl -H "Content-Type: application/json" -X POST -d "admin" http://'.$smappeeip.'/gateway/apipublic/logon')!='{"success":"Logon successful!","header":"Logon to the monitor portal successful..."}')exit;
}
Solar and power consumption are stored in apcu cache and in a MySQL database for later analysis. If the consumption is more than 8000W+Current solar power I receive a warning (my electricity net can only handle 40A or 9600W).
Re: Smappee Support?
if domoticz have username and password how could i integrate this paramethers?'
thank you.
thank you.
apazga wrote:Hi everyone,
To ease the development, improvement of the script, I did a refactor of the code, extracted the important variables, worked on a documentation (README.md) and uploaded all to Github. Now I hope it will be easier for every one to start using this script.
niceandeasy, of course all the credit is yours (and is clearly specified in the Github repo). If you have any problem, just tell me and I'll delete the repo, I just wanted to have the initiative to keep this kind of good stuff alive, so thank you for your work
Repo is here: https://github.com/apazga/smappee-domoticz-bash
Best regards,
Abel.
Re: Smappee Support?
after updating the operating system of the raspberry the script can no longer control the plugs of the smappe. Can someone update the script?
the error message is {"errorMessage":"The server encountered an unexpected condition which prevented it from fulfilling the request"}.
the error message is {"errorMessage":"The server encountered an unexpected condition which prevented it from fulfilling the request"}.
Who is online
Users browsing this forum: No registered users and 1 guest