Also be aware that a thumb drive is also flash and will also wear out with repeated writes over time.
Sure. Iām not worried about that, as long as my SD card is not getting hammered at the same rate.
Backup: I wanted to automate the copying of backups from /srv/openhab2-userdata/backups to a shared Windows folder (itās not a NAS but itāll be available often enough to serve my purposes). Because Windows disables the unsafe smb1 protocol now, I needed to add:
client max protocol = SMB3
to /etc/samba/smb.conf right under the line that says:
workgroup = WORKGROUP
This fixes the āprotocol negotiation failedā error. I worked out the command line to copy all the backups from the backups folder to the share, suppressing prompts, and using a credentials file to store the user name and password:
smbclient -A=/usr/local/etc/credentials_file //WindowsPC/shared_dir -c "prompt; recurse; lcd /srv/openhab2-userdata/backups; mput *"
I used a special, very restricted backup user that I created on Windows. I then created a backup user on Linux that is the only user that can read the credentials file, and created a bash script to execute the above command line. I then used visudo to allow my normal user to execute this script under the backup user without a password. I can then run a command like this:
sudo -u mybackupuser /path/to/backup/script
Remaining for another day: automate the creation of the backups themselves, and then run both the backup and copy automatically at regular intervals.
I finally managed to get control of the ventilation flow rate using a dimmer. The js script I was using as a transformation had a bug or two.
Iād also forgotten to attach the transformation map to the Modbus control item. It seems that you can control the bypass without switching to Modbus control, oddly, but not the ventilation flow rate.
I managed to set up a daily backup and copy it to a network drive by running the two relevant scripts in cron jobs. I realised that I need to use the root crontab to run both, the backup because it requires root, and the copy because it has to run under a different user.
Iāve swapped the hard drive for a USB stick to hold the logs. I got an ultra-slimline stick because cramming four USB devices into the four ports of the RPi is tricky. The Enocean and Z-Wave adapters are bulky and barely fit.
Iāll probably move the backups to the USB stick too, to avoid more SD card wear and tear.
Using this backup command you can specify the location of the backup file:
openhab-cli backup --full /my/alternative/backupdir/openhab2-backup-$(date +"%y_%m_%d-%H_%M_%S").zip
Now it would be nice to also relocate the tmp dir to the USB stick.
I think Iāll skip moving the tmp dir. Reading around, it sounds like a recipe for trouble.
I finally got around to make a couple of clones of the SD card using Win32 Disk Imager. I tested the first copy I made and it seemed to boot up OK, but my (one and only) rule didnāt load. It turns out that the ālockā tab had been moved down on the card - so quite how any copy was made at all, I donāt know. With this fixed, and running W32DI as admin just in case, I made two copies and tested them without problems.
At some point Iāll look into Amanda.
After beating my head against the wall for about an hour, I managed to filter out some garbage from openhab.log using this super-useful thread: openHAB - Filtering event logs. This is my filter:
log4j2.appender.out.filter.stuff.type = Filters
log4j2.appender.out.filter.stuff.Modbus1stConnectionRefused.type = RegexFilter
log4j2.appender.out.filter.stuff.Modbus1stConnectionRefused.regex = .*connect try 1/3 error.*
log4j2.appender.out.filter.stuff.Modbus1stConnectionRefused.onMatch = DENY
log4j2.appender.out.filter.stuff.Modbus1stConnectionRefused.onMismatch = NEUTRAL
Until I did it this way - which is intended to allow for multiple expressions to be added in sequence - I couldnāt get the filter to work. Doing it the other way:
log4j2.appender.out.filter.Modbus1stConnectionRefused.type = RegexFilter
log4j2.appender.out.filter.Modbus1stConnectionRefused.regex = .*connect try 1/3 error.*
log4j2.appender.out.filter.Modbus1stConnectionRefused.onMatch = DENY
log4j2.appender.out.filter.Modbus1stConnectionRefused.onMismatch = NEUTRAL
resulted in nothing appearing in the log at all.
I note Richās comment about filtering, but I continuously get this line in the log:
2020-06-12 02:07:29.649 [ERROR] [ing.ModbusSlaveConnectionFactoryImpl] - connect try 1/3 error: Connection refused (Connection refused). Connection TCPMasterConnection@128737e[socket=Socket[unconnected]]. Endpoint ModbusTCPSlaveEndpoint@1c0cb5b[address=192.168.0.100,port=502]
and itās 95% of the content.
Now I can move on to more productive things.
Of course, you might try to fix the underlying problem.
Iāll hazard a guess you are hitting your Modbus device too often with disconnect/reconnects.
Try holding the TCP connection open longer, try increasing time between reconnects
Modbus binding default settings should be considered āget you startedā, not optimal for any given setup.
I could, of course, try to fix the underlying problem. The thought had crossed my mind. . Still, one thing at a time.
I tried augmenting the time the connection is held open to 10 seconds, and putting 5 seconds between reconnects, but it doesnāt seem to make any difference. 99.9% of the time, connect 1/3 fails, but the rest succeed. Iāll have a look at the tutorial and see if anything pops out.
In fact, even if I up the time to keep the connection open to a minute, and put 5 seconds between reconnects, I just get the error every minute+5 seconds.
Well, it is your slave actively rejecting the connection (as opposed to a no-response timeout etc.)
They can often be buggy, we have I think seen one before that never tidily closes a connection. Similar symptoms - always fails the next connection attempt, which prompts it to tidy up and succeed on the retry.
Unless there is anything you can change or update at the slave end, just tolerate it (the retry I presume always works)
Up the connection hold to hours, and reduce time between to a second or less (as we know it will always fail first time, thereās no point waiting)
Personally Iād tolerate the logging as well at that frequency, for fear of hiding real problems.
My reasoning is that, if thereās a real problem, there will be more failures after the first. So I prefer to remove that noise from the log.
Iām looking at my RTS blinds and awnings. Itās beginning to look as if thereās no way to recover the IDs being used by the Zipabox to pair with them, which means Iāll have to turn off the power to each one of the other (eight) blinds and awnings whilst pairing each of the nine with the RFXCom transmitter, which implies an all-or-nothing switchover from one controller to the other. I hope this isnāt the case, because far from being to play with the blinds and awnings to test them, Iād have to wait right until the end to move them. Iām wondering whether I could figure them out by trial and error - whether theyāll be easily guessable.
Unfortunately it looks as if, even if you could obtain the unit code/ID for each blind/awning, the RFXCom transmitter refuses to work with a code/ID that it hasnāt stored as a āremoteā, which means you have to pair the device anew from the RFXCom using the āprogramā commandā¦ which means picking a new code/ID combination.
@marcel_erkel set me right. Apparently you can pair the same blinds multiple times with different remotes/controllers, and each pairing has different codes. I figured out the symlink stuff (to ensure the rfxcom has a consistent device identifier on each reboot) - read the tutorial! - and successfully added one of my blinds to openHab. I can now control it from both home automation systems. The ID.UnitCode that you need to put in the shutter thing configuration uses the decimal ID, not the hex ID. This tripped me up at first (although itās in the tutorial!). You can see it in the rfxmngr output window, or just do the conversion on a calculator.
Oh, thereās also some confusion about whether you need to cut the power to all other blinds and awnings before pairing one with rfxcom - you donāt, at least not with the Telis remote I have. You select the right one, and press the button on the back. Doesnāt interfere with the others at all.
Added all 4 blinds and 5 awnings to OH.