Mise à zéro de "CounterToday"

Posez ici vos questions d'utilisation, de configuration de DomoticZ, de bugs, de conseils sur le logiciel lui même dans son utilisation et son paramétrage.
Des forums spécifiques sont ouverts ci-dessous pour regrouper les différents sujets.
Doudy
Messages : 457
Inscription : 07 mai 2016, 17:23

Mise à zéro de "CounterToday"

Message par Doudy »

Hello,

Comment faire pour mettre à zéro l'affichage de "CounterToday"
Donnée erronée !
Image

Code : Tout sélectionner

{
"ActTime": 1660639859,
"AstrTwilightEnd": "23:21",
"AstrTwilightStart": "04:17",
"CivTwilightEnd": "21:40",
"CivTwilightStart": "05:58",
"DayLength": "14:29",
"NautTwilightEnd": "22:26",
"NautTwilightStart": "05:12",
"ServerTime": "2022-08-16 10:50:59",
"SunAtSouth": "13:49",
"Sunrise": "06:34",
"Sunset": "21:04",
"app_version": "2022.1",
"result": [
{
"AddjMulti": 1.0,
"AddjMulti2": 1.0,
"AddjValue": 0.0,
"AddjValue2": 0.0,
"BatteryLevel": 255,
"CounterToday": "-21753.611 kWh",
"CustomImage": 0,
"Data": "0.000 kWh",
"Description": "",
"EnergyMeterMode": "",
"Favorite": 0,
"HardwareDisabled": false,
"HardwareID": 3,
"HardwareName": "Virtuel",
"HardwareType": "Dummy (Does nothing, use for virtual switches only)",
"HardwareTypeVal": 15,
"HaveTimeout": true,
"ID": "00082497",
"LastUpdate": "2022-08-12 16:20:04",
"Name": "Virtual Solar",
"Notifications": "false",
"PlanID": "0",
"PlanIDs": [
0
],
"Protected": false,
"ShowNotifications": true,
"SignalLevel": "-",
"SubType": "kWh",
"SwitchTypeVal": 0,
"Timers": "false",
"Type": "General",
"TypeImg": "current",
"Unit": 1,
"Usage": "0 Watt",
"Used": 1,
"XOffset": "0",
"YOffset": "0",
"idx": "497"
}
],
"status": "OK",
"title": "Devices"
}
Merci
;)
RaspberryPi - RFLink - Zwave - WH2600
Domoticz : 2020.2 | Dashticz : V3.12 Master | dzvents : 3.0.2 | Python : 3.7.3
adv
Messages : 580
Inscription : 02 févr. 2016, 13:54
Contact :

Re: Mise à zéro de "CounterToday"

Message par adv »

Dans les logs, t'as quoi ? Une courbe ?

Si oui tu dois pouvoir faire un maj + clic pour supprimer les points erronés.

A+
Raspberry pi 3 - Domoticz 2024.4 | Piface v.2 + Téléinfo + RFXtrx433E
sondes Oregon | motorisations Somfy Yslo Flex 2 RTS
prises chacon, wifi | Sonoff easyESP, Tasmota, Espurna | ParadoxMG5050
Doudy
Messages : 457
Inscription : 07 mai 2016, 17:23

Re: Mise à zéro de "CounterToday"

Message par Doudy »

Dans le log les données ont l'air de s'afficher correctement.
Image
Ici le log produit dans le prg python avec les print ()

Code : Tout sélectionner

pi@raspberrypi-185:~ $ python /home/pi/domoticz/scripts/python/read_SBFSpot_db.py
[(u'2022-08-16 16:05:00', 684, 21759375), (u'2022-08-16 16:00:00', 768, 21759318), (u'2022-08-16 15:55:00', 996, 21759254), (u'2022-08-16 15:50:00', 780, 21759171), (u'2022-08-16 15:45:00', 768, 21759106), (u'2022-08-16 15:40:00', 744, 21759042), (u'2022-08-16 15:35:00', 612, 21758980), (u'2022-08-16 15:30:00', 588, 21758929), (u'2022-08-16 15:25:00', 552, 21758880), (u'2022-08-16 15:20:00', 552, 21758834), (u'2022-08-16 15:15:00', 732, 21758788), (u'2022-08-16 15:10:00', 912, 21758727), (u'2022-08-16 15:05:00', 816, 21758651), (u'2022-08-16 15:00:00', 1140, 21758583), (u'2022-08-16 14:55:00', 1332, 21758488), (u'2022-08-16 14:50:00', 1128, 21758377), (u'2022-08-16 14:45:00', 1032, 21758283), (u'2022-08-16 14:40:00', 1188, 21758197), (u'2022-08-16 14:35:00', 1284, 21758098), (u'2022-08-16 14:30:00', 1344, 21757991)]
('append', u'2022-08-16 16:15:09', u'2022-08-16 16:05:00', 0, 684, 21759375)
('append', u'2022-08-16 16:15:09', u'2022-08-16 16:00:00', 0, 768, 21759318)
('append', u'2022-08-16 16:15:09', u'2022-08-16 15:55:00', 0, 996, 21759254)
('append', u'2022-08-16 16:15:09', u'2022-08-16 15:50:00', 0, 780, 21759171)
('append', u'2022-08-16 16:15:09', u'2022-08-16 15:45:00', 0, 768, 21759106)
('append', u'2022-08-16 16:15:09', u'2022-08-16 15:40:00', 0, 744, 21759042)
('append', u'2022-08-16 16:15:09', u'2022-08-16 15:35:00', 0, 612, 21758980)
('append', u'2022-08-16 16:15:09', u'2022-08-16 15:30:00', 0, 588, 21758929)
('append', u'2022-08-16 16:15:09', u'2022-08-16 15:25:00', 0, 552, 21758880)
('append', u'2022-08-16 16:15:09', u'2022-08-16 15:20:00', 0, 552, 21758834)
('append', u'2022-08-16 16:15:09', u'2022-08-16 15:15:00', 0, 732, 21758788)
('append', u'2022-08-16 16:15:09', u'2022-08-16 15:10:00', 0, 912, 21758727)
('append', u'2022-08-16 16:15:09', u'2022-08-16 15:05:00', 0, 816, 21758651)
('append', u'2022-08-16 16:15:09', u'2022-08-16 15:00:00', 0, 1140, 21758583)
('append', u'2022-08-16 16:15:09', u'2022-08-16 14:55:00', 0, 1332, 21758488)
('append', u'2022-08-16 16:15:09', u'2022-08-16 14:50:00', 0, 1128, 21758377)
('append', u'2022-08-16 16:15:09', u'2022-08-16 14:45:00', 0, 1032, 21758283)
('append', u'2022-08-16 16:15:09', u'2022-08-16 14:40:00', 0, 1188, 21758197)
('append', u'2022-08-16 16:15:09', u'2022-08-16 14:35:00', 0, 1284, 21758098)
Je pense que c'est une ancienne donnée lorsque j'ai lancé ce script python la première fois !
Mais comment la supprimer ?
RaspberryPi - RFLink - Zwave - WH2600
Domoticz : 2020.2 | Dashticz : V3.12 Master | dzvents : 3.0.2 | Python : 3.7.3
Keros
Messages : 6638
Inscription : 23 juil. 2019, 20:57

Re: Mise à zéro de "CounterToday"

Message par Keros »

Normalement, la valeur Today se remet à zéro à minuit puis s'incrémente au fil de la journée.

Tu peux nous expliquer comment les données sont envoyées dans ce widget ? C'est un script ?
Comment bien utiliser le forum : Poser une question, Mettre un script, un fichier, une image ou des logs
Mes petits guides : Débuter en programmation, Le débogage, Le choix de matériel, Les sauvegardes
Ma présentation - Mes Tutos
Doudy
Messages : 457
Inscription : 07 mai 2016, 17:23

Re: Mise à zéro de "CounterToday"

Message par Doudy »

Hello,
Oui c'est via un script python (IDX = 497)

Code : Tout sélectionner

#!/usr/bin/python
# -*- coding: utf-8 -*-

# https://www.domoticz.com/forum/viewtopic.php?p=291773&hilit=conn+%3D+connect#p291773

from sqlite3 import connect
from datetime import datetime

## Obtenir les 20 dernières lignes du fichier du jour pour les dernières lecture de la production solaire.
## Obtenir plus de 1 en cas de mauvaise connexion Bluetooth

conn = connect('/home/pi/smadata/SBFspot.db')
curs = conn.cursor()

curs.execute("select Timestamp, Power, TotalYield from vwDayData ORDER BY Timestamp DESC LIMIT 20")
rows1=curs.fetchall()
print(rows1)

curs.close
conn.close

conn = connect('/home/pi/domoticz/domoticz.db')
curs = conn.cursor()

## Obtenir la dernière lecture ajoutée à domoticz
curs.execute("select Date from Meter ORDER BY Date DESC LIMIT 1")
rows2=curs.fetchall()
if len(rows2)==0: #check there is some data in Meter table
	now=datetime.now()
	DT=now.strftime("%d/%m/%Y %H:%M:%S")
else:
## Obtenir le dernier horodatage ajouté à domoticz
	# print(rows2)
	DT =rows2[0][0]

	a=0 ## variable pour l'indicateur d'ajout de la date - 0=ajouter, 1=ne pas ajouter
for n in range (19) :

	if DT !=rows1[n][0] and a== 0: ## append data
		print("append", DT, rows1[n][0],a, rows1[n][1], rows1[n][2])
		val=rows1[n][1]
		tot =rows1[n][2]
		params = (500,val*10,tot,rows1[n][0])
		curs.execute("INSERT INTO Meter(DeviceRowID,Usage,Value,Date) VALUES (?,?, ?,?)", params)
		conn.commit()
	elif DT==row1[n][0] and a==0 : ## set 'dont append'flag
		print("set flag", DT, rows1[n][0],a)
		a=1
	else :
		print ("Ne rien faire", DT, row1[n][0],a)

curs.close()
conn.close()
Je retrouve cette valeur dans les data :

Code : Tout sélectionner

 python /home/pi/domoticz/scripts/python/read_SBFSpot_db.py
[(u'2022-08-17 09:20:00', 216, 21761554), (u'2022-08-17 09:15:00', 168, 21761536), (u'2022-08-17 09:10:00', 120, 21761522), (u'2022-08-17 09:05:00', 72, 21761512), (u'2022-08-17 09:00:00', 84, 21761506), (u'2022-08-17 08:55:00', 96, 21761499), (u'2022-08-17 08:50:00', 84, 21761491), (u'2022-08-17 08:45:00', 84, 21761484), (u'2022-08-17 08:40:00', 72, 21761477), (u'2022-08-17 08:35:00', 60, 21761471), (u'2022-08-17 08:30:00', 36, 21761466), (u'2022-08-17 08:25:00', 48, 21761463), (u'2022-08-17 08:20:00', 60, 21761459), (u'2022-08-17 08:15:00', 48, 21761454), (u'2022-08-17 08:10:00', 0, 21761450), (u'2022-08-17 08:05:00', 0, 21761450), (u'2022-08-17 08:00:00', 0, 21761450), (u'2022-08-17 07:55:00', 0, 21761450), (u'2022-08-17 07:50:00', 12, 21761450), (u'2022-08-17 07:45:00', 0, 21761449)]
('append', u'2022-08-17 09:30:07', u'2022-08-17 09:20:00', 0, 216, 21761554)
('append', u'2022-08-17 09:30:07', u'2022-08-17 09:15:00', 0, 168, 21761536)
('append', u'2022-08-17 09:30:07', u'2022-08-17 09:10:00', 0, 120, 21761522)
('append', u'2022-08-17 09:30:07', u'2022-08-17 09:05:00', 0, 72, 21761512)
('append', u'2022-08-17 09:30:07', u'2022-08-17 09:00:00', 0, 84, 21761506)
('append', u'2022-08-17 09:30:07', u'2022-08-17 08:55:00', 0, 96, 21761499)
('append', u'2022-08-17 09:30:07', u'2022-08-17 08:50:00', 0, 84, 21761491)
('append', u'2022-08-17 09:30:07', u'2022-08-17 08:45:00', 0, 84, 21761484)
('append', u'2022-08-17 09:30:07', u'2022-08-17 08:40:00', 0, 72, 21761477)
('append', u'2022-08-17 09:30:07', u'2022-08-17 08:35:00', 0, 60, 21761471)
('append', u'2022-08-17 09:30:07', u'2022-08-17 08:30:00', 0, 36, 21761466)
('append', u'2022-08-17 09:30:07', u'2022-08-17 08:25:00', 0, 48, 21761463)
('append', u'2022-08-17 09:30:07', u'2022-08-17 08:20:00', 0, 60, 21761459)
('append', u'2022-08-17 09:30:07', u'2022-08-17 08:15:00', 0, 48, 21761454)
('append', u'2022-08-17 09:30:07', u'2022-08-17 08:10:00', 0, 0, 21761450)
('append', u'2022-08-17 09:30:07', u'2022-08-17 08:05:00', 0, 0, 21761450)
('append', u'2022-08-17 09:30:07', u'2022-08-17 08:00:00', 0, 0, 21761450)
('append', u'2022-08-17 09:30:07', u'2022-08-17 07:55:00', 0, 0, 21761450)
('append', u'2022-08-17 09:30:07', u'2022-08-17 07:50:00', 0, 12, 21761450)
mais pas en négatif !
;)
RaspberryPi - RFLink - Zwave - WH2600
Domoticz : 2020.2 | Dashticz : V3.12 Master | dzvents : 3.0.2 | Python : 3.7.3
Répondre