I’m having trouble with my automation:
I want to save the value of my sensor in a csv data after an automation was triggert:
switch is working. sensor value showing in card on the dashboard is working as well.
Is there any other solution or is this the right way to do it?
Thank you for your help
To my knowledge, Home Assistant doesn’t have a native file.write service call. Is the example you posted pseudo-code or are you using a custom integration that provides file.write?
So I’m not that familiar with yaml. The file.write I saw on a python script.
So doing it with the notify.[string] is there also a chance to check conditions first with the value of the sensor and writing the given message into the csv?
Or is the better way to get it done in a python script?
I know that this is an automation.
Is hard to get information because of the versions/date of home assistant. there are always small changes and those have an big affect to all.
So the conditions in my code are superfluous since I’m checking the state of the sensor in both the trigger condition and the action. So the entity state: 'on' is not necessary/faulty.
So first I want to set the state of the entity sensor.0x000 to a new variable sensor_value to have the opportunity to multiply it by 3. The result is a new var called multiplied_value, which is checked by conditions.
Any syntax error occur because of the The curly braces are not set right?
One more addition: if you want to write to a CSV-file (Comma-Separated Values) you have to add commas to the message string.
This is shown in my example:
The message string starts with a comma because each line starts with a time stamp (as defined in my notify example).
The contents of the CSV could with my example be like this:
If you need another separator you can of course replace the comma with that sign.
You only have to ensure that this character is not used anywhere else in the data.
Thank you thats perfect.
I looked up the immediate if (iff) on the home assistant homepage. That confused me at the beginning. But I understand it now and it makes it much clearer.
I looked up at the HA homepage and was trapped with this entry then:
action:
service: notify.notify
data:
message: "The sun is {% if is_state('sun.sun', 'above_horizon') %}up{% else %}down{% endif %}!"
So could it be as well a way to get there or is it just to complicated/not the right way to do this.
So the only additional entry I need is in my configuration.yaml
last question:
is there any opportunity to get ‘FEHLERHAFT’ in bold to highlight it in the csv or even colourize it?
Like in the markdown card you have ** TEXT ** to bold it.
is it possible to send the message via persistent notification in the same automation if the battery status is faulty. (FEHLERHAFT).
Or even to a card without using HACS, card mod…
I found that with persistent notification you can use as a notify but you can’t dismiss it.
But it should only be triggert by condition if the battery is faulty during the automation.
And I know it always shows notification even if the message is empty.