forked from dougiteixeira/proxmoxve
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ef4b436
commit c8f0257
Showing
1 changed file
with
41 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
# Send CPU temperature information to Home Assistant | ||
|
||
This has nothing to do with this integration, it's just one of several possible ways to publish your CPU temperature to Home Assistant. | ||
|
||
You should use this as an example and adjust to your use case. | ||
|
||
*There will be no support for issues with this alternative.* | ||
|
||
### Install `xsensors` | ||
`apt-get install xsensors` | ||
|
||
### Create script in your server Proxmox: | ||
`nano /usr/temp_ha_post` | ||
|
||
``` | ||
#! /bin/bash | ||
url1=http://10.10.10.xxx:8123/api/states/sensor.proxmox_temperatura | ||
token1=xxxxx | ||
i=1 | ||
sensors | grep -e "°C" | while read line; do | ||
temp=$(echo $line | awk -F "+" '{ print $2 }' | awk -F "." '{ print $1 }'); | ||
url1a=$url1'_'$i; | ||
curl -X POST -H "Authorization: Bearer $token1" -H 'Content-type: application/json' --data "{\"state\":\"$temp\",\"attributes\": {\"friendly_name\":\"Temperatura Proxmox\",\"icon\":\"mdi:cpu-64-bit\",\"state_class\":\"measurement\",\"unit_of_measurement\":\"°C\",\"device_class\":\"temperature\"}}" $url1a; | ||
done | ||
``` | ||
|
||
#### Give the file execute permission: | ||
`chmod +x /usr/temp_ha_post` | ||
|
||
#### Test the script (see if there are errors and if the entity was created in Home Assistant): | ||
`/usr/temp_ha_post` | ||
|
||
### Configure a cron schedule (CRON): | ||
`crontab -e` | ||
|
||
#### Add after the last line of the file: | ||
`*/1 * * * * /usr/temp_ha_post` | ||
|
||
#### Restart the cron service: | ||
`services cron restart` |