Good friends. I am looking for a way to print several values from a .sh script to an HA sensor.
I am doing it in the following way:
1.sh
#!/bin/bash
#!/usr/bin/bash
#set -x # allow debug output
MESSAGE="Text 1"
export MESSAGE
/_comandos/b.sh
MESSAGE="Text 2"
export MESSAGE
/_comandos/b.sh
MESSAGE="Text 3"
export MESSAGE
/_comandos/b.sh
MESSAGE="Text 4"
export MESSAGE
/_comandos/b.sh
2.sh
#!/bin/bash
#!/usr/bin/bash
#set -x # allow debug output
echo "$MESSAGE"
The problem is that all the text of the script is printed on the sensor, it does not update the data, delete it and create a new one. Is there any way to fix this?
In this case, shouldn’t I just print the Text 4? Instead it prints all the values, it doesn’t “clean” the previous value of the variable.
I don’t know if it’s the best way to do what I want to do. What I have given you is just an example. I want to run a shell that unmounts a hard drive on my system, and while it’s unmounting it, I want an HA sensor to go through the status and at the end print a “disconnected” value to capture that value with an automation and disconnect it from power with a smart plug. Let’s see if you can tell me a more accurate solution than mine, or solve the example that I have exposed. Thank you very much !!