Influxdb graph Sonoff TH Tasmota mqtt 2.4 no data, always gives value 0

Hi,
I have a problem with graph and Sonoff TH with firm Tasmota and mqtt 2.4. Everything works (switch, temperature reading) but it doesn’t create a graph, it always appears in value 0. I have more graphics and with other sensors (Xiaomi) and they work perfectly. I have also tried in Habpanel and it shows me the same thing. Before writing, I’ve been looking for a solution but everything I’ve tried has not worked for me.Thank you very much for your help!:slight_smile:

Hardware: Raspberry PI 3B
OS: openHABian v1.4.1
Java Runtime Environment: openjdk version “1.8.0_152”
OpenJDK Runtime Environment (Zulu Embedded 8.25.0.76-linux-aarch32hf) (build 1.8 .0_152-b76)
OpenJDK Client VM (Zulu Embedded 8.25.0.76-linux-aarch32hf) (build 25.152-b76, m ixed mode, Evaluation)
openHAB version: openHAB 2
I can't get graph temperature from Sonoff TH, always gives value 0

**Thing configuration related to the issue**
 Thing topic sonofftempplacsolar "Temperatura placa solar" @ "Terrado" {
    Channels:
        Type string : reachable "Estado"            [ stateTopic="tele/sonofftempplacsolar/LWT" ]
        Type switch : power     "Está"                [ stateTopic="stat/sonofftempplacsolarPOWER", commandTopic="cmnd/sonofftempplacsolar//POWER" ]
        Type number : rssi      "Potencia señal wifi" [ stateTopic="tele/sonofftempplacsolar/STATE", transformationPattern="JSONPATH:$.Wifi.RSSI" ]
        Type string : temperature "Temperatura"       [ stateTopic="tele/sonofftempplacsolar/SENSOR", transformationPattern="JSONPATH:$.DS18B20.Temperature" ]

**Items configuration related to the issue**
// Temperatura placa solar terrado
String TemperaturaPlacaSolar_Estado_Reachable "Estado[%s]" <contactable> (Home, SF_SegundaPlanta, SF_Terrado, SF_PlacaSolar, SF_RelesTerrado) { channel="mqtt:topic:681400fe:sonofftempplacsolar:reachable" }
Switch TemperaturaPlacaSolar_Est_Power "Está[MAP(sonoffmotor.map):%s]" (Home, SF_SegundaPlanta, SF_Terrado, SF_PlacaSolar, SF_RelesTerrado) [ "Switchable" ] { channel="mqtt:topic:681400fe:sonofftempplacsolar:power" }       
Number TemperaturaPlacaSolar_PotenciaSeAlWifi "Potencia señal wifi [%d %%]" (Home, SF_SegundaPlanta, SF_Terrado, SF_PlacaSolar, SF_RelesTerrado) { channel="mqtt:topic:681400fe:sonofftempplacsolar:rssi" }
String TemperaturaPlacaSolar_Temperatura_Temperature "Temperatura[%s °C]" <temp> (Home, SF_SegundaPlanta, SF_Terrado,SF_PlacaSolar, SF_SensoresTemperaturaTerrado)  { channel="mqtt:topic:681400fe:sonofftempplacsolar:temperature" }

Sitemap configuration related to the issue 
Frame label="Relé placa solar temperatura"
                Switch item=TemperaturaPlacaSolar_Est_Power label="Está[]"
                Text item=TemperaturaPlacaSolar_Estado_Reachable label="Conexión[%s]"
                Text item=TemperaturaPlacaSolar_PotenciaSeAlWifi label="Potencia señal wifi[%d %%]" icon="qualityofservice"
Frame label="Gráfica diaria" {
                Chart item=TemperaturaPlacaSolar_Temperatura_Temperature icon="temperature" label="Temp Chart" refresh=60000 period=D service="influxdb"

Influxdb.persist file related to the issue
Strategies
{
everyMinute : "0 * * * * ?"
every2Minutes : "0 */2 * ? * *"
everyHour : "0 0 * * * ?"
everyDay : "0 0 0 * * ?"
}

Items {
TemperaturaPlacaSolar_Temperatura_Temperature: strategy = everyUpdate, everyMinute, restoreOnStartup
}
´´´
It's giving me the temperature but graph is alway in 0:
![Temperature|664x500](upload://35rhG2JNU994yZawXA0EGg2oYiM.jpeg)

Do the items get the correct value and the problem is just in influxdb/grafana?

If the items already get the wrong value (see events.log) we can irgnore inflixdb/grafana for the moment and concentrate why the mqtt binding reads the wrong values.

Are the values correct in the web interface of the tasmota device?.

1 Like

Could you please post your

influxdb.cfg, influxdb.persist files

and your items?

The rest of the items get the correct value. It’s only this item. I have also a problem with grafana, it’s appear at my Openhab Web Panel but doesn’t connect. Influxdb works well with graphs.

Of course!!!

influxdb.cfg:
url=http://192.168.1.50:8086
user=openhabian
password=/@1834ArB*
db=openhab_db
retentionPolicy=autogen

influxdb.persist
Strategies
{
everyMinute : "0 * * * * ?"
every2Minutes : "0 */2 * ? * *"
everyHour : "0 0 * * * ?"
everyDay : "0 0 0 * * ?"
}

Items {
SensorTHPTerrado_Temperature: strategy = every2Minutes, restoreOnStartup
SensorTHPTerrado_Humidity: strategy = every2Minutes, restoreOnStartup
SensorTHPTerrado_Pressure: strategy = every2Minutes, restoreOnStartup
EnchufeDespachoJuanma_ProvidedPower: strategy = every2Minutes, restoreOnStartup
EnchufeCalderaPatioDeLuces_ProvidedPower: strategy = every2Minutes, restoreOnStartup
BaOAlmacN_ProvidedPower: strategy = every2Minutes, restoreOnStartup
MotorPuertaAlmacN_Power_Power: strategy = every2Minutes, restoreOnStartup
CMaraAlmacN_Power_Power: strategy = every2Minutes, restoreOnStartup
CMaraPuertaPrincipal_Power_Power: strategy = every2Minutes, restoreOnStartup
MesaAlmacN_Power_Power: strategy = every2Minutes, restoreOnStartup
PuertaAlmacN_isOpen: strategy = every2Minutes, restoreOnStartup
AperturaVentanaAlmacenHojaDerecha_isOpen: strategy = every2Minutes, restoreOnStartup
AperturaVentanaAlmacenHojaIzquierda_isOpen: strategy = every2Minutes, restoreOnStartup
EnchufeJuanmaDormitorio_ProvidedPower: strategy = every2Minutes, restoreOnStartup
EnchufeNatyDormitorio_ProvidedPower: strategy = every2Minutes, restoreOnStartup
EnchufeONTFibra_ProvidedPower: strategy = every2Minutes, restoreOnStartup
EnchufeNASSynology_ProvidedPower: strategy = every2Minutes, restoreOnStartup
EnchufeRouterAsus_ProvidedPower: strategy = every2Minutes, restoreOnStartup
EnchufeBaOPrincipal_ProvidedPower: strategy = every2Minutes, restoreOnStartup
EnchufeBaOInvitados_ProvidedPower: strategy = every2Minutes, restoreOnStartup
CMarasTerradoYPatio_ProvidedPower: strategy = every2Minutes, restoreOnStartup
TemperaturaPlacaSolar_Temperatura_Temperature: strategy = everyUpdate, everyMinute, restoreOnStartup
}

reboot … try again … clean cache … reboot … try again :slight_smile:

I have rebooted 5/6 times but I didn’t clean cache. So I’m going to clean cache:)

This temperature item … is a string not a number? Could that be different from
your other working items?

I’m going to try like a number after the start of the system because I have just cleaned cache.

I think, its a string. And that could be the problem.
Could you put this text item (!) on your sitemap and make a screenshot? Or are there any log entrys about this item?

I think that after restart my sd card has failed. I have this in the log:

2019-04-04 22:44:48.382 [SEVERE] [org.apache.karaf.main.Main] - Could not launch framework

java.lang.RuntimeException: Error initializing storage.

	at org.eclipse.osgi.internal.framework.EquinoxContainer.<init>(EquinoxContainer.java:70)

	at org.eclipse.osgi.launch.Equinox.<init>(Equinox.java:31)

	at org.eclipse.osgi.launch.EquinoxFactory.newFramework(EquinoxFactory.java:24)

	at org.apache.karaf.main.Main.launch(Main.java:256)

	at org.apache.karaf.main.Main.main(Main.java:178)

Caused by: java.io.FileNotFoundException: /var/lib/openhab2/cache/org.eclipse.osgi/.manager/.fileTableLock (Permission denied)

	at java.io.RandomAccessFile.open0(Native Method)

	at java.io.RandomAccessFile.open(RandomAccessFile.java:316)

	at java.io.RandomAccessFile.<init>(RandomAccessFile.java:243)

	at org.eclipse.osgi.internal.location.Locker_JavaNio.lock(Locker_JavaNio.java:36)

	at org.eclipse.osgi.storagemanager.StorageManager.lock(StorageManager.java:388)

	at org.eclipse.osgi.storagemanager.StorageManager.open(StorageManager.java:701)

	at org.eclipse.osgi.storage.Storage.getChildStorageManager(Storage.java:1776)

	at org.eclipse.osgi.storage.Storage.getInfoInputStream(Storage.java:1793)

	at org.eclipse.osgi.storage.Storage.<init>(Storage.java:132)

	at org.eclipse.osgi.storage.Storage.createStorage(Storage.java:85)

	at org.eclipse.osgi.internal.framework.EquinoxContainer.<init>(EquinoxContainer.java:68)

	... 4 more
´´´

Oooh nooo.
You have a backup of your files?
Good time to go to sleep …

I don’t have. Yes, I think that it’s a goog time for go to sleep and try tomorrow. I will update tomorrow the state of my card:(

Finally, I was able to restart and put the system right. I have changed “string” to “number” and I have obtained readings in the graph but I also have the following in the log:

2019-04-04 23:36:00.185 [ERROR] [org.influxdb.impl.BatchProcessor    ] - Batch could not be sent. Data will be lost

java.lang.RuntimeException: {"error":"partial write: field type conflict: input field \"value\" on measurement \"TemperaturaPlacaSolar_Temperatura_Temperature\" is type float, already exists as type string dropped=1"}

	at org.influxdb.impl.InfluxDBErrorHandler.handleError(InfluxDBErrorHandler.java:19) ~[234:org.openhab.persistence.influxdb:1.13.0]

	at retrofit.RestAdapter$RestHandler.invoke(RestAdapter.java:242) ~[234:org.openhab.persistence.influxdb:1.13.0]

	at org.influxdb.impl.$Proxy149.writePoints(Unknown Source) ~[234:org.openhab.persistence.influxdb:1.13.0]

	at org.influxdb.impl.InfluxDBImpl.write(InfluxDBImpl.java:151) ~[234:org.openhab.persistence.influxdb:1.13.0]

	at org.influxdb.impl.BatchProcessor.write(BatchProcessor.java:171) [234:org.openhab.persistence.influxdb:1.13.0]

	at org.influxdb.impl.BatchProcessor$1.run(BatchProcessor.java:144) [234:org.openhab.persistence.influxdb:1.13.0]

	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) [?:?]

	at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:308) [?:?]

	at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(ScheduledThreadPoolExecutor.java:180) [?:?]

	at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:294) [?:?]

	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [?:?]

	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [?:?]

	at java.lang.Thread.run(Thread.java:748) [?:?]

I think the mqtt message is a string. To confirm that, please change back your item to a string (like in your first post) and put it on an sitemap and show it here.

If it is a string, then it has to converted. This will the next step then.

Glad you could restart your system: just a restart?

1 Like

I think i ran into the same problem:

Setup: incoming MQTT String with this (number or text?): 23.00
To recreacte your problem, i assumed it is a string and persisted this string with influxdb an tried to visualize it with grafana. No success.

Then i tried to convert this string to a number with these items and rule:

String temperaturstring_room1 "room1 [%s]" { channel="mqtt:topic:mosquitto:esp_things:mqttstring_esp_room1_temperatur" }
Number Temperatur_room1 "room1 temp [%.1f]" <temperature> ( gTemperatur ) 
rule "ESP MQTT string convert to number"
when
    Item temperaturstring_room1 received update
then
    var Number temp = Float::parseFloat(temperaturstring_room1.state.toString)
    Temperatur_room1.postUpdate(temp) 
end

(First i tried it with parseInt … so success.) (Also cleaned the cache an rebooted the system).

This was the result:

Log Report

This text will be hidden

 [ERROR] [org.influxdb.impl.BatchProcessor    ] - Batch could not be sent. Data will be lost

java.lang.RuntimeException: {"error":"partial write: field type conflict: input field \"value\" on measurement \"Temperatur_room1\" is type float, already exists as type string dropped=1"}

	at org.influxdb.impl.InfluxDBErrorHandler.handleError(InfluxDBErrorHandler.java:19) ~[230:org.openhab.persistence.influxdb:1.13.0]

	at retrofit.RestAdapter$RestHandler.invoke(RestAdapter.java:242) ~[230:org.openhab.persistence.influxdb:1.13.0]

	at org.influxdb.impl.$Proxy161.writePoints(Unknown Source) ~[230:org.openhab.persistence.influxdb:1.13.0]

	at org.influxdb.impl.InfluxDBImpl.write(InfluxDBImpl.java:151) ~[230:org.openhab.persistence.influxdb:1.13.0]

	at org.influxdb.impl.BatchProcessor.write(BatchProcessor.java:171) [230:org.openhab.persistence.influxdb:1.13.0]

	at org.influxdb.impl.BatchProcessor$1.run(BatchProcessor.java:144) [230:org.openhab.persistence.influxdb:1.13.0]

	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) [?:?]

	at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:308) [?:?]

	at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(ScheduledThreadPoolExecutor.java:180) [?:?]

	at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:294) [?:?]

	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [?:?]

	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [?:?]

	at java.lang.Thread.run(Thread.java:748) [?:?]

Next approach: perhaps it is a influxdb problem? Perhaps it does not like the format change? I changed (rename) the item name (simply put a “_new” at the end of the item name) and … looks like it works … grafana shows up the correct values. ? :slight_smile:

this is my working rule:

rule "ESP-MQTT string convert to number"
when
    Item temperaturstring_room1 received update
then
          Temperatur_room1_new.postUpdate(Float::parseFloat(temperaturstring_room1.state.toString))
end

Back to your problem: i have never actually seen or read your value, because you have not posted a screenshot. Perhaps your string/number/value (whatever) has a comma seperator like 23.00 or 23,00 and that causes the trouble?

1 Like

Hi Richard. First of all, thank you very much for everything. In the end I was able to resuscitate the microsd card. After cleaning the cache there were problems with permissions but in the end I could solve it, or so I think :slight_smile: I have to install Amanda and create a backup. If I put the item and and the thing type with number I get data in the graph but I get the error that I put before. If I put both as string the error disappears but I get data in the graph. I attached a capture but I think I did not do it well. I’m going to try again. The temperature is shown in the sitemap and habpanel as XX.XºC.
I’m going to test how you did it to see if it works for me.
I must also say that influxdb apparently works well for me but grafana appears in the browser inside the openhab panel but when I click on it, it tells me that it can not connect. Could that be the problem?

Your database has previously recorded an Item by that name as a String. Now it’s trying to put Number data, doesn’t fit in the string-shaped box.
Find out how to delete the old Influxdb table, so that it can start out as number.

1 Like

Hi to everyone.
In the end, I have achieved it in the following way:
First of all I deleted the item from influxdb.persist.
The first thing was to change the topic in the sonoff th.


After doing it, I went to my file things and changed the topic and in the channel I wrote number.

Thing topic templacsolarsonoff "Temperatura agua placa solar" @ "Terrado" {
    Channels:
Type number : temperature "Temperatura"       [ stateTopic="tele/templacsolarsonoff/SENSOR", transformationPattern="JSONPATH:$.DS18B20.Temperature" ]
  }

Then, I went to my file items and changed the name of the item for another.

// Temperatura placa solar terrado
Number TemperaturaAguaPlacaSolar_Temperatura_Temperature "Temperatura[%s °C]" <temp> (Home, SF_SegundaPlanta, SF_Terrado,SF_PlacaSolar, SF_SensoresTemperaturaTerrado)  { channel="mqtt:topic:XXXXXXXX:templacsolarsonoff:temperature" }

Finally, I wrote the new name in the sitemap and it seems to be working.

Group item=SF_SensoresTemperaturaTerrado
{
Frame label="Gráfica diaria" {
                Chart item=TemperaturaAguaPlacaSolar_Temperatura_Temperature icon="temperature" label="Temp Chart" refresh=60000 period=D service="influxdb"
                }
            }

When I changed the item and I wrote in influxdb.cfg an error appeared in the log that has not been reproduced anymore (I guess it would be for the previous item).
Now it works and even takes me the color scales that I wrote.


The only thing left for me to resolve is the theme of Grafana. It appears in the Openhab dashboard but when I click it it does not connect me.


I could only connect once when I installed everything but after that I could not and I tried to reinstall everything and nothing several times.
It may be that something has happened to me but I have been reviewing everything and following all the proposals of the community but something escapes me. If anyone knew something, I would appreciate it.
I would like to thank the attention and concern of christoph_wempe, rrichard
“Richard” and rossko57.
Thank you so much for everything.

Hi @frifru!

cool! :slight_smile:

I have no direct answer to this problem, but perhaps you don’t need this dashboard link often? I think the goal is, to put your hard earned graphics on your sitemap: See “Showing diagrams in your openHAB sitemap” in https://community.openhab.org/t/influxdb-grafana-persistence-and-graphing from @ThomDietrich

In short: every diagramm on your grafana website offers a “share” option:

grafik

With this link (watch out: direct image rendering), it is possible to integrate the diagramm in the sitemap (Image refresh=60000 url=" … "). In this link itself, it is possible to configure the time range and viewing options.
Sadly, the rendering of the image is slow. I don’t know why, perhaps someone has a tip to increase the loading time of grafana charts.

Good day! :slight_smile: