Temperature from file to dashboard

Hello.
I m need send temperature from file to dashboard
in file.txt i have “Temperature=22.1”
How to send this temperature to dashboard from bash and refresh any 10 sec
Thx

you can send it using python GitHub - myDevicesIoT/Cayenne-MQTT-Python: Python Library for Cayenne MQTT API

yes but where can i put my data :

import cayenne.client
import time

Cayenne authentication info. This should be obtained from the Cayenne Dashboard.

MQTT_USERNAME = “MQTT_USERNAME”
MQTT_PASSWORD = “MQTT_PASSWORD”
MQTT_CLIENT_ID = “MQTT_CLIENT_ID”

The callback for when a message is received from Cayenne.

def on_message(message):
print("message received: " + str(message))

If there is an error processing the message return an error string, otherwise return nothing.

client = cayenne.client.CayenneMQTTClient()
client.on_message = on_message
client.begin(MQTT_USERNAME, MQTT_PASSWORD, MQTT_CLIENT_ID)

For a secure connection use port 8883 when calling client.begin:

client.begin(MQTT_USERNAME, MQTT_PASSWORD, MQTT_CLIENT_ID, port=8883)

i=0
timestamp = 0

while True:
client.loop()

if (time.time() > timestamp + 10):
client.celsiusWrite(1, i)
client.luxWrite(2, i*10)
client.hectoPascalWrite(3, i+800)
timestamp = time.time()
i = i+1

in this code ??

what is your data?

in file.txt i have “Temperature=22.1”
and i need push data (22.1) from file to dashboard temperature sensor
is raspbian

is there a code which reads the temperature or just a random temperature number.

just a random temperature number

Try this code and see if you get the temperature string and then you have to parse the value and add it to cayenne python code.

stringToMatch = 'Add your string'
matchedLine = ' '

f = open("file.txt","r")
for line in f:
        if stringToMatch in line:
                matchedLine = line
                print matchedLine

$ python 1.py
Temperature=22.1

in 1.py

stringToMatch = ‘Temperature=’
matchedLine = ’ ’

f = open(“file.txt”,“r”)
for line in f:
if stringToMatch in line:
matchedLine = line
print matchedLine

now you need to add this code in cayenne code and parse the 22.1 value to be send using client.virtualWrite(1, 22.7)

now i have :
config = ConfigParser.ConfigParser()
config.read(“/home/osmc/temp/temp.txt”)
tempp = config.get(“zmienne”, “var_a”)

while True:
client.loop()

if (time.time() > timestamp + 10):
client.celsiusWrite(1, tempp)
timestamp = time.time()
i = i+1

how to refresh tempp if something is change in file ??? thx

i am not understanding what you are trying to do. you first said you have a random temperature number in file.txt which needs to send to cayenne. Now you are saying you need to know if the something has changed. So is it sensor that will change the temperature value in file.txt?
Anyways, to see if there is a change you need to call the function which reads the file every interval.