Monday, April 06, 2020

Free Heating from your Solax Inverter!

Free Heating from your Solar Panels? Yes Please!

This neat little hack takes (near) real-time statistics data from your Solax Inverter over the network at home, performs a little simple subtraction and works out if you have enough exported energy to run a Fan Heater.

You can probably use a different inverter, provided it has a web API that gives you enough data to do the simple calculation. You will also be able to us a different smart-plug to the HS100 provided there is a script/binary to use for local control of it on your home network.

Stuff you need:

[WARNING] This script will randomly start and stop a high current electrical heating appliance in your home, please use common sense, and do not leave the heater set to run unattended when you cannot verify that it is operating safely. I accept no responsibility for any damage caused by the use of the following scripts!
  • A Solax Inverter which supports network real-time data feed

If you have a Solax inverter, plug its network connection into your home network, it should pick up an IP Address from your router.  Do a curl to http://inverter_ip/api/realTimeData.htm and see if you get a load of data back. If you do and it looks like the below example, you may be able to use this script 'as is'


{"method":"uploadsn","version":"Solax_SI_CH_2nd_20170906_DE01","type":"AL_SE","SN":"XXXXXXXX","Data":[5.8,4.1,282.4,289.7,9.6,247.8,2348,30,9.0,4757.3,1340,1637,1187,50.69,9.67,490,13,91,0.0,699.4,,,,,,,,,,,,,,,,,,,,,,0.00,0.00,,,,,,,,50.06,,,0.0,0.0,0,0.00,0,0,0,0.00,0,9,0,0,0.00,0,9],"Status":"2"}

  • A Raspberry Pi - Any model will do , connected to the network 8-)
  • TPLink HS100/HS110 Smart Socket
Other brands will also work, so long as you have a script or binary to turn it on and off from you Pi. Please verify that the smart socket can handle the load from any appliance you connect to it before attempting this!

Scripts
I used the following scripts to set this up. If you have the same inverter and smart-socket, they should work straight off the bat. For other setups, you will need to substitute and edit accordingly.

HS100/110 control

Download George Georgovassilis' excellent little script, from  https://github.com/ggeorgovassilis/linuxscripts and check its working for your socket

./hs100.sh -i mysocket

Find out the IP Address of your smart socket from your router DHCP leases, and place a hosts file entry on your Pi with a friendly name. Or you can just use the IP above if you want instead.

autofan.py

This script will check the inverter data feed once, and decide if there is less than 200 watts being drawn from the grid, (e.g you are exporting more than you're using, with a buffer of 200w draw being allowed). If this is the case, then it turns the smart-socket on.

#!/usr/bin/python

import hashlib
import requests
import os
import time

from xml.etree.ElementTree import XML

url = "http://192.168.1.121/api/realTimeData.htm"
r = requests.get(url)
p = r.text.split(",")
print("Generation: {}".format(int(p[15])+int(p[16])))
print("Grid      : {}".format(p[14]))
l = (int(p[15])+int(p[16]))-int(p[14])
print("House Load: {}".format(l))

if(int(p[14])>-200):
        print "on"
        os.system('./hs100.sh -i heater on')
else:
        print "off"
        os.system('./hs100.sh -i heater off')



Launching the script every 30 seconds

cron can't run things as quickly as every 30 seconds, hence you can do this using a service in linux. The standard pi distros support this, you need to create 2 files in /etc/systemd/system:

/etc/systemd/system/autofan.timer

[Unit]
Description=run the autofan every 30 sec
[Timer]
OnBootSec=30
OnUnitActiveSec=30
AccuracySec=1ms
[Install]
WantedBy=timers.target

/etc/systemd/system/autofan.service

[Unit]
Description=AutoFan
[Service]
ExecStart=/usr/bin/python /solaxmon/auto-fan.py

When you're done, you'll need to register the service, and start it:

systemctl enable autofan.timer
systemctl start autofan



Thursday, October 17, 2013

HELP! - Rescue my Intel RAID


Just had to post this one, after a narrow escape:

LESSON: ALWAYS BACK UP YOUR DATA BEFORE UPDATING BIOS FIRMWARE!

While diagnosing some sleep/wake issues on an ASUS P8H77-I motherboard, I was forced to update the BIOS. While this is pretty easy on the Asus boards, Be aware that sometimes a BIOS update can wipe the Intel RAID controller configuration!

Looking at the RAID management screen in the BIOS it was obvious that two of the 4 RAID-5 disks had somehow been marked as 'non-RAID' and therefore were not members of the set anymore.

All may not be lost however, if you encounter this, and you know your RAID disks are good - in other words they were ok before the update, then you could try this:

http://www.overclock.net/t/478557/howto-recover-intel-raid-non-member-disk-error

Essentially:
- Boot into the RAID config (CTRL-I on my board)
- DELETE the RAID configuration [just wipes the RAID sig on the disks]
- CREATE a NEW RAID configuration of EXACTLY THE SAME SETTINGS as before
- Reboot
Windows will still not recognise the partition I discovered but you can recover this using TESTDISK:
http://www.cgsecurity.org/wiki/TestDisk_Step_By_Step

- Download TestDisk
- Start it up, and let it scan for partitions
- you should see your missing volume within seconds.
- Stop the scan (unless you have more AWOL volumes)
- Write the partition signature
- Reboot again.

Data was restored 8-)

More details here:
http://forums.anandtech.com/archive/index.php/t-2226542.html

Remember:
ALWAYS BACK UP YOUR DATA BEFORE UPDATING BIOS FIRMWARE!

[Your experience may vary from the above, but I felt it was worth posting that this worked flawlessly for me]

Thursday, June 03, 2010

Using SCVMM Console on a foreign Domain

Microsoft designed windows AD Domains to put security boundaries around organisations, and enable structured administration of them. There are some times when you wish that your machine could be a member of more than one domain, but that is just not possible without setting up AD domain trusts etc.

My home lab is a good example - My laptop is on my employer's domain where other people in other countries are the administrators, and my virtual machines are on another where I am the evil overlord.

While it would be cool to link them all together, it's far too complicated and frankly I dont want my employer's IT department tinkering with my lab machines, and they wont be setting up any employer-employee domain trusts anytime soon.

I wanted to manage my virtual machines from my laptop, without changing it from the configuration I had, here's how I managed to get it working for System Center Virtual Machine Manager, and Hyper-V Administation tools:

My lab looks like this:

SCVMM R2 on a Hyper-V VM Win2k8 box, in it's own domain (its a DC actually as well, but that doesnt matter), and  a Laptop client running Win7 x64 in a different domain (no relationship between them)

•Login to client PC as your normal domain user account
•Install SCVMM console from media as usual.
•create an account on the SCVMM servers' domain with the same username and password as your client, make yourself a domain admin for good measure (you may not need this step, but all home labs need lots of domain admins!)
•Make SCVMMDomain\youraccount a SCVMM admin in the SCVMM console on the server.
•Get hold of John Howard's HVRemote script and run on both client and server to enable anonymous dcom (cscript hvremote.wsf /AnonDCOM:grant ) _ WARNING: You are opening up your DCOM security here, be aware of this and read-up if you are concerned.

•Each time, just before you launch the console on the client Establish a secure connection from client to server: (non admin command prompt on client) :

net use \\scvmmserver\ipc$ /user:scvmmdomain\youruser

(note that if you've setup correctly you shouldnt be asked for a pw)

Now launch SCVMM console, and connect to server

Boom.

(worked for me, your mileage may vary, if you cannot get this to work, follow John's blog details for remote Hyper-V admin console access from your client to the server - I had this working first, then added SCVMM console afterwards) I seem to get remote consoles and everything to my VM's as well, with the occasional disconnect - but hey.

BTW, unless an app is coded specifically to close all sessions and re-authenticate against the server or to 'get' the domain it's connecting to from the client (e.g ad domain tools) this trick should work for most apps like this that 'assume' (quite rightly) that everything is on the same AD domain, or a trusted domain.

Wednesday, June 02, 2010

Hyper-V Remote Management without Domains?

If you have a home lab system, and dont run a 'real' AD domain, Hyper-V's remote admin tools can be un-cooperative.


Until I discovered John Howard's Hyper-V Remote Management Configuration Utility that can fix all those annoying security issues that prevent two machines that dont have a domain from managing each other.

8-)

Monday, March 22, 2010

Twitter controlled lights?

Just in case you though I'd gone away, here's a little hack to enable you to use Twitter to send commands to your BBSB (Bye Bye Standby) Online Controller.
This is a software hack, involving no Arduino's or soldering(!)
In this post, I use the Linksys NSLU2 Linux based NAS appliance, but I'm sure any Linux machine will happily play along with this, provided you've isntalled Perl.
Once you're set up ( see instructions on this link), you simply DM (Direct Message) your controller using Twitter - and hey presto!
DM mycontroller lounge lights on
Enjoy.
(Usual policy of shoddy coding applies of course)
UPDATE: Due to changing ISP, the links in the PDF are not valid - use these instead:
 
UPDATE: Twitter has stopped allowing basic Authentication, so these scripts will not work without modification - if you do update them please let me know 8-)




Friday, January 15, 2010

Putting your watts on the web (Part 2) for CC128 users!

Just a quick update on the CurrentCost interfacing to the NSLU2. I posted earlier, thanks to manutitou over at pachube.com, he's figured out how to force the NSLU2 serial port to the higher default baud rate of 57600 that is needed for the CC128 CurrentCost.

He tells me that this is working for him: (take a look at his feed)

stty -F /dev/ttyUSB0 speed 57600 raw cs8
57600
stty < /dev/ttyUSB0
speed 57600 baud; line = 0; min = 1; time = 0; -brkint -icrnl -imaxbel -opost -isig -icanon

Nice one. Update your scripts if you used mine, or your own version accordingly and enjoy.

Friday, December 04, 2009

HomeEasy Update - Dave's Bedroom Light Controller

Strap yourselves down, it's my biggest load of waffle ever....

There's been quite a bit of activity over on the HomeEasy pages on Arduino.cc, and several people have mailed me to say that they have made progress with various HomeEasy related Arduino Projects.



Hi to David Edmunson, for posting his latest project for an alarm clock, (above) - nicely done - like the interface, clearly, unlike me - you can code in CSS (!) .

What am I up to?, and why have I been neglecting my blog?

Well, the day job is getting in the way again, but I do have *three* projects on the go that I will post updates for shortly - here's where I'm at:

BBSB RF Only Repeater

This is a really easy to build Arduino + TX + RX circuit that just does a dumb repeater job within our house - this is great as it now means that our BBSB messages get repeated all over the house and none of our devices miss a beat (mostly) - I will probably also extend this to repeat HomeEasy messages as well, as we now have a mixture of devices.

This is all built, and working just fine - I discovered that a couple of 15cm lengths of wire make far better antennas then expensive 433mhz stubby antennas purchased because they looked cool.

PIC Based BBSB 'Water Detector'

A couple of years ago, I came in from work one afternoon, only to find it was 'Raining' in our downstairs loo! - Our shower pump in the bathroom above had sprung a minor leak, and flooded the upstairs bathroom. Ever since then we've had a nifty little Velleman 'Water Alarm' wired up to a sensor under the bath where all the plumbing bits are. This works great, and makes a rude noise if the area under there gets wet.

(blurrycam pic , sorry)

This isnt very 2009 though, so it was high time it was empowered a bit. - a peeping alarm in an empty house is no use to anyone!

This little project is based around the PIC 12F675 microcontroller - which is less than £2 at Maplins, I ported the BBSB transmit code that works on the Arduino into the little PIC, resulting in a little 'module' or 'bug' that can send a BBSB ON or OFF code when an input changes status (high-low, low-high etc). I also built a little battery monitor into it so that it sends a signal every few days just to say 'Hi' to the house and confirm its still working! - I managed after a bit of fiddling to build this up with NO PCB, as the 8 pin chip makes a reasonable cowboy construction bed to solder the other components to ...yee-ha.

I dont have the PDF write up for this one done yet, but will post it with code etc as soon as I get around to it. - we also have a small battery drain problem currently Houston - or it has crashed, because it stopped calling in about a week after being installed. ahem! - so perhaps not quite ready for the primetime!

Yale Alarm Integration

This is more a not-even-half-baked-idea but appears to be a go-er.

We've had a Wireless Alarm for some time in our house, which works really well - I do however miss two things - 1) being able to arm/disarm it via the internet, and 2) being able to catch events from all the system's detectors around our house too and act on them.



Internet Alarm Arm/Disarm

The Yale protocol is not published anywhere, and so far my attempts to reverse engineer it have failed I'm assuming it's a code-rolling type system (like a car key fob, so unlikely to be easy to decode) - (I think Yale would also be happy about this too), but what is possible is to interface to the Alarm system via two of it's most commonly available components - a) the Keyfob Remote, and b) the Bell-box - both of which can be learned into the alarm system (even a 2nd bell-box) - The Bell Box itself can actually function as a stand-alone alarm controller on the cheaper Yale system , so in itself it's packed with circuitry and certainly knows if the alarm is ON or OFF.

I bought an extra bell-box from Ebay and learned it to our system, I binned the housing we can re-house it in a smaller box with the 'duino later), amputated the deafening siren (not needed!) and shorted the tamper switch closed (no thanks) - I was left with a little board that I could connect to the Arduino.

My prototype Arduino project monitors the status of the Alarm currently - this is possible because the 3 LED's on the Yale Alarm box have a 'flash' sequence that is different for arming, and dis-arming - by responding to these two different combinations of events, you can tell if the alarm was just armed, or disarmed - I will probably just send a HE or BBSB message via the Arduino when this happens, which will allow the rest of the house to respond to Arm/Disarm events - primarily enabling security schedules , and, more importantly, turning down the heating! -- This isnt really all that smart, as clearly if the Arduino powers-up it wont know whether it's On, or Off - some more probing around the circuit board for the bell-box unit may reveal more. There is definatley a pin somewhere for 'Siren going off' as well, so this should be not too hard to track down either.

As you might have worked out by now, the easy way to arm/disarm the Alarm using the Arduino interface is to connect some output pins from the trusty 'duino across the keyfob buttons for arm/disarm - again very nasty - but also very secure - provided you shut the remote in a box somewhere the entire unit can remain wireless with the Arduino onboard also - especially if you are using 433mhz messages to HomeEasy/BBSB when events occur. - I wouldnt recommend allowing the insecure protocols like this to actually 'do' stuff like disarm the alarm however, for obvious reasons - I will probably do this 'some other way' using cabling inside the house.

So - unfinished masterpiece currently, but perhaps more progress over Xmas on that one - if you have any ideas on this one, or circuit diagrams(!!!!) let me know - of if you just want to hack-along on this project, I'll set up a wiki or something.

Thats it for now.

Sunday, October 04, 2009

HomeEasy Meets Arduino - HomeEasy Automatic Protocol

After several late nights on this one, I've finally cracked it.
Thanks to Barnaby and Peter's postings on Arduino.cc I've managed to build an Arduino sketch that will send On/Off signals to a HomeEasy HE302 socket via a little 433 mhz transmitter.

This code takes a HE device code (6 digits) and sends an on signal, then an Off signal.

Code is here, If you want to build this, you just need a little Arduino board, and the 433mhz transmitter I talk about in earlier posts.
Now, go forth and build my friends 8-)

Saturday, September 26, 2009

BBSB Meets Arduino (Part 3) Home Easy to BBSB Repeater

Thanks to some sample code found here, I've churned out a handly little HomeEasy to ByeByeStandby RF Repeater.
This little project will pick up selected HomeEasy Advanced Protocol devices (like the HE300 Remote and HE303 PIR) and translate them into any ByeByeStandby device code you want.
Thanks to Barnaby and Peter here, and several hacking types, here. You will need a similar 433mhz Transmitter and Receiver to my previous posts, as well as that little £12 Arduino board that you bought and havent used yet 8-)
Enjoy.


Monday, September 21, 2009

Putting your Watts on the Web..

Several people have blogged about their solution to publishing their electricity usage online. Here's our solution: Using a CurrentCost Classic, a cool little Linksys NSLU2 (Unslung), and Pachube, the excellent cloud based sensor monitoring service.



Quite a few folks are activley monitoring using this hardware solution, but I think this solution gets the 'quick and dirty' award, as very little else is needed, the data is collected and posted using a little shell script, with no need for perl, ruby or other such stuff.
  • We got the older CurrentCost Classic as the serial data comes out a little slower (9600baud) than the newer, shiny CC128 model, which suited hooking it up to stuff that cant swallow the data rate of the newer model.
  • Get the CurrentCost USB cable as well, it has a USB/Serial converter built in , which you'll need unless you already have a separate one (CurrentCost serial port is 5v RS232, so hooking it up to a serial port directly will get you nothing or magic smoke 8-( )
  • Unsling your NSLU2 so you can telnet/SSH into it and run stuff. (see links above)
  • Hook your CurrentCost to the spare USB port on the NSLU2 (it should also work on a hub btw, but the device below may be different to mine.)
  • run dmesg and look for the device ID of the serial port that is detected - ours was /dev/ttyUSB0
  • Try this filthy script out - you'll need to edit it, to replace: YOUR_PACHUBE_API_KEY with your actual Key from your pachube account, and also your YOUR_FEED_ID in this file to get it to work. - I just have two integer values, one for watts, one for temp on this feed.
  • Two little scripts are provided get-watts , and get-temp which should just echo the data from the CurrentCost to the console, as well as update-pachube which does the biz to the pachube service.

Footnotes: You may need to do some ipkg install magic on the NSLU2, you need grep, sed, cut and curl I forget which ones are in the slugos already.

The NSLU2 is a great platform for this type of stuff, the power consumption is less than 3w according to our killawatt, with processing power to spare, for ..... more stuff in the near future 8-)

Enjoy.

UPDATE: An abusive co-worker who is attempting to follow my vague and inaccurate posting has reminded me that there are two missing steps in this post:

  • You need to install some extra packages on your slug, I *think* these are:
  1. picocom - 1.4-1 - A minimal dumb-terminal emulation program. (you will want this to see what is happening on the com port from the current cost)
  2. libcurl - 7.19.5-1 (you need curl for the pachube posting)
  3. coreutils - 7.4-1 -(I think coreuils has cut in it, among other utilities)

(e.g # ipkg install picocom; ipkg install libcurl; ipkg install coreutils)

  • You need to install the PL2303 kernel module so the USB-To-Serial cable is recognised. (following http://www.nslu2-linux.org/wiki/Peripherals/USB2Serial worked for my official currentcost cable) - after doing this check with dmesg for the name of the serial port to point to for your data.

Further abusive comments welcome from anyone, if this is still not correct 8-/ - my apologies.

Friday, September 11, 2009

Hyper-V RDP Issues on Windows 2008? - Disable yer Large Send Offload.

Nasty one this - Hyper-V on Windows 2008 R2 just wouldnt give a stable network connection for remote desktop to Guests, and the host sometimes.



I spent hours searching for a solution on the net, fiddling with Netsh, MTU sizes, switches and NIC drivers, until I spotted this blog entry. Turn off the Large Send Offload setting on the NIC. POW Fixed. Thanks to Daniel Petri. No reboot required.

Friday, June 19, 2009

BBSB Meets Arduino (Part 2)

Ok, So a better BBSB Repeater project would be able to do everything the previous post refers to, AND be able to recieve BBSB codes and send them to the BBSB Controller - unfortunatley this requires some interrupt driven Arduino magic, which I havent been able to get working - so , as the king of unfinished masterpieces - here is an RF->Network only repeater version.

You need to connect your compatible RF Receiver to pin 4.

On my unit , component side -

pin 1 = 5v
pin 2 = GND
pin 3 = Antenna (or nothing!)
pin 4 = GND
pin 5 = GND
pin 6 = not connected
pin 7 = rx data out (arduino pin 4)
pin 8 = 5v

Updated documentation is er.. not written yet. 8-) - as always refer to the receiver datasheet before wiring things up 8-), and also note that I was unable to complete testing this because my BBSB controller is not connecting to the BBSB mothership tonight 8-(


Comments etc here please: http://www.byebyestandby.com/forum/viewtopic.php?f=6&t=371

Mart.