Hi all,
I have a non-smart meter on a remote location which I manually read out every few weeks. Like the title says, I would like to manually enter data into a virtual energy device so I can roughly track how much energy I am using.
I understand this won't be precise, but all I really care about is the difference between the current reading and the previous one. A nice graph would also be great!
I also already have data from the last few months in a Excel spreadsheet, if possible I want to enter it in the sensor to already have some data to work with.
I looked for the function in multiple energy-like sensors, but could not find a manual option. Does this option even exist, and if not, how else can I achieve my goals? Would it be possible to use it in a script with the API?-
Manually enter energy data
Moderator: leecollings
-
- Posts: 630
- Joined: Saturday 21 September 2019 17:55
- Target OS: Raspberry Pi / ODroid
- Domoticz version: 2024.1
- Location: The Netherlands
- Contact:
Re: Manually enter energy data
I am not aware of domoticz having any possibility for extensive manual input, so if I were you, I would write a very small python program to either read a csv file or ask for manual input data and then store that onto a domoticz device.
The way to get data onto a device, or into the domoticz dbase, is via json calls (not via sql statements). From the python program you can easily make and activate those json calls and as result get your data onto a device.
Have a look at this page: https://www.domoticz.com/wiki/Domoticz_API/JSON_URL%27s
So all you need to do is choose your device, set it up, and know a bit of python.
Below are some bits and pieces out of a larger python program (this extract was not tested) to show you how to update a text device.
It imports the required modules
It sets some global variables
It defines the update function
It calls the update function with a test
The way to get data onto a device, or into the domoticz dbase, is via json calls (not via sql statements). From the python program you can easily make and activate those json calls and as result get your data onto a device.
Have a look at this page: https://www.domoticz.com/wiki/Domoticz_API/JSON_URL%27s
So all you need to do is choose your device, set it up, and know a bit of python.
Below are some bits and pieces out of a larger python program (this extract was not tested) to show you how to update a text device.
It imports the required modules
It sets some global variables
It defines the update function
It calls the update function with a test
Code: Select all
import requests
import json
import urllib.parse
## Domoticz server
domoticzIP="127.0.0.1" # internal IP address of the Domoticz server. This assumes domoticz is run on the same system as this program (if not, use the external IP address).
domoticzPort="8080" # Domoticz port
# all communication with domoticz devices/database is with JSON calls (like domoticz itself is doing)
baseJSON="http://"+domoticzIP+":"+domoticzPort+"/json.htm?" # the base string for any JSON call.
def setTextDevice(textIDX,displayText):
# update the value of a text device and adds an entry to the device log file
try:
if len(displayText)<=200:
urlText=urllib.parse.quote(displayText)
apiCall="type=command¶m=udevice&idx="+str(textIDX)+"&nvalue=0&svalue="+urlText
response=requests.get(baseJSON+apiCall)
responseResult=str(response.json()["status"])
if responseResult=="ERR":
raise Exception
else:
responseResult=True
else:
print("ERROR: displayText too long (max 200 characters).")
raise Exception
except:
print("ERROR: failed to update text device with IDX ",textIDX)
print("Response was : ",response.json())
responseResult=False
return responseResult
setTextDevice(textdeviceIDX,"this is a test") ## replace textdeviceIDX by the IDX number of your device
- FireWizard
- Posts: 1770
- Joined: Tuesday 25 December 2018 12:11
- Target OS: Raspberry Pi / ODroid
- Domoticz version: Beta
- Location: Voorthuizen (NL)
- Contact:
Re: Manually enter energy data
Hi @phenix56,
As I know you have MQTT and Node-Red running, you could also use these tools.
You can simple use an Inject node and publish the value to a virtual sensor of your choice.
It is even possible to read directly your Excel sheet.
See: https://flows.nodered.org/node/node-red ... adsheet-in
The biggest issue is how to send a date/time (which is in the past) to the database.
It is possible to send it directly to a sqlite3 database from Node Red, but you have to stop Domoticz in that case. This is probably not what you want.
So any other idea?
Regards
As I know you have MQTT and Node-Red running, you could also use these tools.
You can simple use an Inject node and publish the value to a virtual sensor of your choice.
It is even possible to read directly your Excel sheet.
See: https://flows.nodered.org/node/node-red ... adsheet-in
The biggest issue is how to send a date/time (which is in the past) to the database.
It is possible to send it directly to a sqlite3 database from Node Red, but you have to stop Domoticz in that case. This is probably not what you want.
So any other idea?
Regards
- waltervl
- Posts: 5396
- Joined: Monday 28 January 2019 18:48
- Target OS: Linux
- Domoticz version: 2024.7
- Location: NL
- Contact:
Re: Manually enter energy data
I have the same situation and I use a simple excel sheet to create an json.html api link that puts the value into Domoticz.
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
-
- Posts: 100
- Joined: Thursday 03 November 2016 10:12
- Target OS: Raspberry Pi / ODroid
- Domoticz version:
- Contact:
Re: Manually enter energy data
Hi, I assume that it is not possible to give also the date as input for the manual entered data points...
If we import data from an XLS or JSON, I would like that the data point is set in the past on the domoticz device to be able to input historical data... Is this possible?
If we import data from an XLS or JSON, I would like that the data point is set in the past on the domoticz device to be able to input historical data... Is this possible?
- waltervl
- Posts: 5396
- Joined: Monday 28 January 2019 18:48
- Target OS: Linux
- Domoticz version: 2024.7
- Location: NL
- Contact:
Re: Manually enter energy data
It is possible, see https://www.domoticz.com/wiki/Domoticz_ ... n_counters
But I only could get this working on a managed counter, not on a normal counter.
But I only could get this working on a managed counter, not on a normal counter.
Domoticz running on Udoo X86 (on Ubuntu)
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
Devices/plugins: ZigbeeforDomoticz (with Xiaomi, Ikea, Tuya devices), Nefit Easy, Midea Airco, Omnik Solar, Goodwe Solar
Who is online
Users browsing this forum: No registered users and 0 guests