I’m trying to create an XML formatted file with some static XML data and sensor data from some temperature sensors in my system and have this automated to run every hour or so. I’m testing to see if the Notify File platform would work for this. So far so good but the file created has 2 header lines inserted by Notify. Is there any way to suppress that header because it messes up my XML format? Or, perhaps Notify File just isn’t the right technique.
Here’s the header I’d like to suppress:
Home Assistant notifications (Log started: 2023-02-27T19:44:48.683610+00:00)
--------------------------------------------------------------------------------
No replies must not be doable.
As a work around or solution I created a windows batch file to remove the 2 lines, move a copy to another directory and delete the original so a new file is created the next time. the automation runs every 10 minutes and windows scheduled task runs the batch file every 10 minutes. Life is good.
Here’s the batch file in case there’s someone else out there that runs into this.
@echo off
set from=\\HOMEASSISTANT\config\www\XML_tags.htx
set temp=\\HOMEASSISTANT\config\www\temp.htx
set to=C:\WeatherLink\Corrales\Templates\XML_tags.htx
if not exist %from% goto end
more +2 %from% >%temp%
move /y %temp% %to%
del %from%
exit /b 1
:end
exit /b -1
I found a better way instead of the Windows batch file and a scheduled task to remove the Notify header lines that get inserted.
HA can execute Linux Shell commands. So, I’m using HA Notify File Platform to write the htx file, and Linux commands to copy the file minus the 1st 2 lines and then delete the file preventing notify from just appending to it.
FYI… The HTX file is used by my Weatherlink program to create an XML file containing weather data from my weather sensors. Anyway, it’s a long story why I’m doing what I’m doing so here is just the Shell commands I ended up using.
The Linux sed command seen below copies the source file starting at line 3 to the end.