MAX!CubeMigrationToFHEM
WORK IN PROGRESS / NOT FINISHED: HowTo Migrate from MAX!Cube to fhem
Summary: This pages describes the steps required to migrate a house installation from MAX!Cube solution (using a Cube and MAX! Software from ELV/EQ-3) to fhem on a Raspberry Pi combined with a CUL. The benefit of such a migration is to gain better logfiles, to get graphs (Desired vs. Actual temperature and Valve position) and more reliable software.
Initial situation
The appartment has 125 sqm and five rooms (child 1, child 2, livingroom, bedroom, working room), one bathroom, a kitchen and a toilette. Each room has one heater below the window, the living room has two heaters. Two rooms require multiple window shutter contacts: bedroom and living room due to the amount of windows. MAX!Cube software is running since a year controlling all heaters, all windows and in combination with one wall thermostat in the living room and one ECO-switch at the main door to bring the full house to ECO mode when leaving.
Desired situation
MAX!Cube software was unstable and the update to v1.3.10 triggered the decision to move to a new setup: keep the MAX system, but control it via fhem. Have the ability to add more sensors, more actors from other brands than MAX (looking for Homematic due to the amount of different sensors and 1-Wire to avoid the unreliable radio transmission). Have the ability to better see what the system is doing (logfiles) and graph it out (diagrams for each room). Get some more flexibility for home-cinema setup, for light controls, etc. Increase the WAF (Women's Acceptance Factor) for the wife who was complaining about the MAX!Cube solution.
Procurement list
While it is possible to use the existing MAX Cube with fhem certain features would not be available. Therefore I decided to go with a Rasperry Pi and a CUL. Here is the shopping list:
- Rasperry Pi from G3 with cooling kit for enhanced reliability ([1])
- 32 GB SDHX Card Class 10 from SANDisk
- CC1101-USB-Lite 868MHz ([2]) with 36cm antenna (+8dBi) for MAX protocol
- 8 Channel 1-Wire Daughterboard without RTC with some sensors for testing ([3])
(Note: The 1-Wire board has not yet arrived and may not fit into the supplied case - but I am too lazy to attach the cooling modules myself).
Installation of Raspberry Pi
Please follow one of the many documentations how to install Linux on your Raspberry Pi - a good starting point would be [4]. I tried to install Raspbian using the advanced method of copying the image directly to the SD-card but it did not worked out well as many perl/python-modules were missing, had to be identified and installed to use fhem.
For my second approach I used the provided image from busware.de, which also includes drivers for their COC daughter board. Available for download here [5]. Unfortunately this has a slightly outdated fhem installation, but works for all other parts. Please note that there is no HDMI output enabled during the first boot. Just use ssh pi@fhem
or ssh pi@<IP-address>
to login and use raspi-config for initial setup of passwords, timezone and disk size. Do not forget to install an ntp-client using apt-get install ntp-client
, an editor of your choice (I selected vim apt-get install vim
) and edit /etc/ntp.conf
to adjust ntpservers and select a country-pool (see [6]).
Upgrade of fhem
Once the initial setup is completed reboot your Raspberry and login into fhem using your web browser at <IP-address>:8083
. Enter the upgrade
command to upgrade your fhem-installation to the latest revision. Use shutdown restart
to start the new code version.
CUL firmware flashing
Login using ssh and become root using su -
or sudo -i
to flash the empty CUL. This only works as root from the directory /opt/fhem
using the command string
dfu-programmer atmega32u4 erase && dfu-programmer atmega32u4 flash ./FHEM/CUL_V3.hex && dfu-programmer atmega32u4 start
If the application dfu-programmer is not installed, install using apt-get install dfu-programmer
.
Migration Preparation
ADD ME
Documentation
If you have not done it before now it's a good start to document your existing MAX!Cube solution. Room for room write each device, the MAX address, location and intended profile into an Excel file. It could look like
Roomname DeviceName DeviceAddress Location WeekDayProfile WeekendProfile Dependencies
where WeekDayProfile and WeekendProfile only make sense for actors like Heaters within the MAX-solution. Dependencies can indicate Window Contacts to Heater actors or Wall Thermostat to Heater actors. Document as well your current heating profile configuration with MAX!Cube.
Make a backup.
Selecting the right time of the year
ADD ME
What do you want to archive
ADD ME
Migration Execution
ADD ME
MAX!Cube Configuration
ADD ME
fhem Configuration
CUL Setup
First step to setup fhem is to define the protocol and adaptor fhem should use. You need one CUL for each protocol (e.g. FS20, Homematic and MAX) as the CUL can listen to the same frequency, but does not understand multiple protocols. The <fhem.cfg> comes pre-installed with some default configuration. At the end add
#### CUL Definition, MAX!Cube define CUL0 CUL /dev/ttyACM0@9600 1234 attr CUL0 rfmode MAX define cm CUL_MAX 123456
and save fhem.cfg. After a reload fhem will start to listen to MAX-commands sent by your still active MAX-Cube.
Find MAX devices
As each MAX device communicates with the MAX!Cube over the time of two-three days, fhem will detect in use MAX-devices like Heaters, Thermostats and WindowsContacts (but not the ECO wall switch) and create alias definitions within the fhem.cfg file. To get all devices including addresses in use let fhem listen for a two-three days while the MAX!Cube is still in use and working.
Identify MAX devices
Login into MAX!Cube using one browser window (or tab) and into fhem using a second browser window (or tab). For each room change the temperature within the MAX!Software to an unsual value (like 27.5), change to the fhem window and identify the change in fhem. This allows you to detect one heater actor by the other.
To identify the Window Contacts just open one window, swap to fhem and see which contact reports an Open status.
Define alias names
Open a third browser window (or tab), login to fhem webpage and select Edit Files, fhem.cfg. You can now add the alias by adding lines like
define MAX_Bathroom_Heating MAX HeatingThermostat 05615b define MAX_Bathroom_WindowSensor MAX ShutterContact 053767
room by room, one by one. Just identify the fhem-name in the "MAX"-room in fhem and adjust the address (last hex-number in the line).
If you already have meaningfull names in the MAX-Software you can try to use the code from this forum post to automaticaly use these as the alias names for all MAX devices.
Understanding the setup
The rooms are still controlled from the MAX!Cube and MAX-software. fhem only listens and has useable names. fhem does not communicate with the devices and it cannot configure devices. However you have useable and human-understandable names instead of hex-codes.
Migration
As MAX!Cube will interfere with CUL (both sending the same protocol on the same frequency) and due to the sending restrictions (1%-rule) we need to
- Remove all rooms in MAX!Cube (which deletes the devices in MAX!Cube)
- Reset all heaters and window contacts to factory settings
- Pair the device to fhem
- Define the week heating program
- Define the connectivity between heater and window sensors
Make a backup of your MAX!Cube configuration in case something goes seriously wrong. Have the family out of the house for 1-2 days while you run around to re-pair devices. While resetting the devices the PI-learned heating curves will be lost and the heaters need to adopt again to your house-specific heating curves.
Re-setting devices
Remove batteries and wait 45 seconds. For
- Heater actors: Press all three buttons at the same time, insert battery until
reS
is displayed. Press Boost for installation menu - Window contacts: Press button while inserting battery and keep pressed until LED is flashing again
- ECO-Wallcontact: Press Eco or AUTO button while inserting battery and keep pressed until LED is flashing again
- Wallthermostats: Go to the menu and select reS fo factory reset
Pairing devices with fhem
Enter set cm pairmode 45
into the command field on top of the fhem page. Initiate the pair sequence on the device by:
- Heater actors: Pressing Boost for about 3 seconds until
30
is displayed - Window contacts: Press button, LED starts flashing. Success is reported by one last long LED signal.
- ECO-Wallcontact: Press one button three seconds, LED starts flashing. Success is reported by one last long LED signal
- Wallthermostat: Press Menu button three seconds until
30
is displayed.
fhem One-Time Device-specific configuration
Certain information about fhem are stored in the fhem.cfg which you can edit using a text editor and ssh or using the webfront. A big other, device-specific part is entered as part of commands into the webfrontend, but not documented and not stored within fhem.cfg. You will end up in a documented, structure information stored in fhem.cfg (like any other UNIX related configuration file in /etc) and a un-documented part which is stored within the devices of your appartment only.
My solution for this was to add the relevant commands into fhem.cfg as comments, so after a multiple month pause on playing with fhem I do still see which commands belonged into which room and what I have done. However if you follow this route is important to understand that changes to these comments will never take place and change your configuration unless you copy and paste them into the command-field and execute your change.
The information stored in devices and not in fhem.cfg are
- Heating weekProfiles - which temperature you want when
- Associations between WindowContacts and Heaters to detect open windows.
Within the fhem forums you find a longer discussion if Windows Sensor really make sense. The statement there is as the Heaters have a Decreasing Temperature sensor they are not. It is hard for me to follow this argumentation as
- The heating water temperature will be impacted when it keep running while windows is open
- The WAF (Women's Acceptance Factor) is lowered as the house should be smart
- You may wish to have open windows longer than 10-15 minutes
- I can document the time of getting fresh air into the rooms (for any discussions with the landlord in a rented appartment)
Window Contacts and Heaters
To connect a window contact with a heater to decrease the temperature they need to be associated to each other:
set MAX_Bedroom_WindowSensor1 associate MAX_Bedroom_Heating set MAX_Bedroom_Heating associate MAX_Bedroom_WindowSensor1
As you can see the associations is called twice for both directions and you need to call both commands for each Window Contact in the room. fhem will ask you in the logfile for each command to press the MAX Window Contact button when you open the Window Contact. If you have (against advice) already configured the graphing you need to disable the graphing to get the command being transmitted.
Open Window Temperature
Configure the desired Open Window temperature for that room using
set MAX_Bedroom_Heating windowOpenTemperature 5.5
You may have to wait a couple of minutes until the command has been transmitted.
Test your room by opening each Window with a Window Contact, the heater should immediately change temperature in both directions.
The Heating Profile
Device-specific configuration also includes the weekProfile, e.g. the desired temperature for each day and each hour. The format is quite simple and starts with an implicit 00:00 (midnight) and ends with an implicit 24:00 (midnight next day). In between desired temperatures are specificed interleaving with hours, seperated by ,s. Temperature is specific in degrees celsius. Example:
17,06:00,21,20:00,17
will set 17 degrees from midnight to 06:00am, 21 degrees 06:00am to 20:00 (8:00pm) and then again 17 degrees until midnight. Such profiles are defined for each day (Mon, Tue, Wed, Thu, Fri, Sat, Sun) and set with the weekProfile command:
set MAX_Child1_Heating weekProfile Mon 17,05:00,19,06:00,22,07:15,19,15:30,21,19:00,19,21:00,17 Tue 17,05:00,19,06:00,22,07:15,19,15:30,21,19:00,19,21:00,17 Wed 17,05:00,19,06:00,22,07:15,19,15:30,21,19:00,19,21:00,17 Thu 17,05:00,19,06:00,22,07:15,19,15:30,21,19:00,19,21:00,17 Fri 17,05:00,19,06:00,22,07:15,19,15:30,21,19:00,19,21:00,17 Sat 17,06:00,21,20:00,17 Sun 17,06:00,21,20:00,17
Do not attempt to break this line into multiple lines for better reading. Just one single long line. Transmission may take a couple of minutes.
Testing and Verifying
ADD ME
Add-Ons
ADD ME
Graphs using 99_UtilsMaxScan.pm
There is a Wiki-articel how to use the [7] MAX-Temperature-Scanner with fhem. At the time of writing this article v1.05a has been published.
Few people have published changes to this version within the forum, which enables the use of ECO wall button and multiple WindowShutter contacts.
If you consider to create graphs for your installation your migration (as outlined above) should 'work stable, e.g.
- week programs for all rooms are active and working
- open windows are detected and the desired temperature is decreased
- you do not face any logfile entries like:
CUL_MAX_SendQueueHandler: Not enough credit! credit10ms is 101, but we need 110. Waiting 9 seconds.
- you do not face any logfile entries like:
CUL_MAX_SendQueueHandler: Missing ack from 020341 for 0f010403123456020341000e18003655
- you do not plan any changes to week programs any time soon.
Do not even think about starting to graph out heaters and rooms while migration is still in progress.
Do download the Scanner Module you need to register and login into the forum. The Scanner Module is attached to the post linked at [8]. Copy this file to /opt/fhem/FHEM
and change ownership to fhem.
(Original Articles: [9] und [10])
ECO-Wallswitch
According to an extensive Google search it is currently not possible to group all Heater actors and send a single command to the group to save communication credits.
A workaround is to define a fhem structure which includes all Heaters, assign it to a new room labelled "House" and add a web control button to fhem:
# Define House to control all Heaters at once define AllHeaters structure MAX_Child2_Heating MAX_Workingroom_Heating MAX_Child1_Heating MAX_Livingroom_THSensor MAX_Bedroom_Heating MAX_Toilette_Heating MAX_Kitchen_Heating MAX_Bathroom_Heating attr AllHeaters room House attr AllHeaters webCmd desiredTemperature
The ECO Wall button has a type PushButton and is easily defined using (you have to update the address of course):
### 9.1 ECO-Wallbutton define MAX_WallButton MAX PushButton 0521c4
To set all heaters into ECO mode until the AUTO mode is pressed on the button or the AUTO mode is called from the webpage use:
define MAX_HouseECOHeating notify MAX_WallButton:(onoff).* { if ("%EVTPART1" eq "0") { Log(3,"Setting ECO-Mode") && fhem("set AllHeaters desiredTemperature eco");;} else { Log(3,"Setting AUTO-Mode") && fhem("set AllHeaters desiredTemperature auto");;}}
(Original discussion: [11])
Planned changes
ADD ME