logo elektroda
logo elektroda
X
logo elektroda

Transmission of readings + calculations to the virtual sensor.

ojciec81 1086 9
Best answers LABEL_AI_GENERATED

How can I pass sensor readings and calculated values to a virtual sensor in Domoticz?

In Domoticz, create a virtual sensor and use a dzVents script in Events to relay the measured values and calculations into that sensor [#19976674] The thread’s example goal was to compute PV surplus as energy sent to the grid × 0.8 minus energy taken from the grid over a 24-month period, and to update the virtual sensor from the script [#19974857][#19976674] You may need to experiment with the exact target sensor type used for the virtual sensor [#19976674]
AI summary based on the discussion. May contain errors.
ADVERTISEMENT
Treść została przetłumaczona polish » english Zobacz oryginalną wersję tematu
  • #1 19885919
    ojciec81
    Level 10  
    Posts: 55
    Rate: 24
    Hello

    I need the data from a sensor that measures, for example, the generated energy from photovoltaic panels to be passed along with the calculations to another virtual sensor.



    Please make a suggestion.

    THANK YOU
  • ADVERTISEMENT
  • #2 19886006
    gkwiatkowski
    CCTV and Stationary Alarms specialist
    Posts: 4681
    Help: 650
    Rate: 1230
    You need to use a data relay. )


    What is the data interface from the measuring sensor?
    What is the transmission method? Wired or wireless?
    What is a virtual sensor?
  • ADVERTISEMENT
  • #3 19952923
    ojciec81
    Level 10  
    Posts: 55
    Rate: 24
    Thanks for your reply. Sorry I'm only writing back now.
    Can you hint more about the data relay.
    The sensors are virtual and the transmission is waterless.

    What do you have in mind?
    gkwiatkowski wrote:
    What is the data interface from the measuring sensor?
    .
  • #4 19952979
    gkwiatkowski
    CCTV and Stationary Alarms specialist
    Posts: 4681
    Help: 650
    Rate: 1230
    ojciec81 wrote:
    Thanks for your reply. Sorry that I am only writing back now.
    Can you hint more about the data relay.
    The sensors are virtual and the transmission is waterless.

    What do you have in mind?
    gkwiatkowski wrote:
    What is the data interface from the measuring sensor?
    .

    Describe in more detail what is meant by a virtual sensor.
  • #5 19974310
    xury
    Automation specialist
    Posts: 7083
    Help: 878
    Rate: 1497
    Essential question what sensor what system? Fairies on the electrode have a ban :)
  • #6 19974857
    ojciec81
    Level 10  
    Posts: 55
    Rate: 24
    The system is Domoticz.

    In general, my idea is to create a script that calculates how much energy from photovoltaic production remains to be used.

    Energy sent to the grid x 0.8 - energy taken from the grid, over a period of 24 months.

    Transmission of readings + calculations to the virtual sensor. .

    Transmission of readings + calculations to the virtual sensor. .
  • ADVERTISEMENT
  • Virtual sensor dzVents script for grid storage calculation

    #7 19976674
    xury
    Automation specialist
    Posts: 7083
    Help: 878
    Rate: 1497
    You create a virtual sensor and dzvents script in events. You'll find a link to an example in my signature.

    Added after 9 [hours] 34 [minutes]: .

    While this won't be in a two-year period, it should work
    Code: Lua
    Log in, to see the code
    .
    I am not sure of the sensor chosen for the stock. I was writing quickly without checking. You'll have to experiment for yourself
  • ADVERTISEMENT
  • #8 19982871
    ojciec81
    Level 10  
    Posts: 55
    Rate: 24
    Thank you very much
    I will check it out today.
  • #9 19986935
    ojciec81
    Level 10  
    Posts: 55
    Rate: 24
    Hello

    After entering the code I received this error :

    2022-04-20 18:12:18.368 Error: dzVents: Error: (3.1.8) .../pi/domoticz/scripts/dzVents/generated_scripts/E_Mag.lua:9: attempt to perform arithmetic on a table value
    2022-04-20 18:12:19.299 Error: dzVents: Error: (3.1.8) An error occurred when calling event handler E_Mag
  • Table value used in arithmetic on Fronius device reading

    #10 20183816
    ojciec81
    Level 10  
    Posts: 55
    Rate: 24
    Please advise what is causing the error
    
    return {
    
    	return {
    
    	on = {
    	    devices = {'Fronius - TO_GRID'}
    	    },
    	
    	execute = function(domoticz, item)
    	    
    	    local togrid = (domoticz.devices('Fronius - TO_GRID')*0.8)  -- do sieci *0.8
    		local fromgrid = tonumber(domoticz.devices('Fronius - FROM_GRID'))  -- z sieci
    	    local storage = fromgid-togrid
    	    local licznik = tonumber(domoticz.devices('Mag').state)  -- utworzyć wirtualny czujnik rfx meter counter o nazwie w apostrofach  np. 'Magazyn'
    	    local ecounter = domoticz.devices('Mag') 
    	    licznik.updateCounter(storage.WhTotal)
    	    
    	end
    	
    }

    error:

    pi/domoticz/scripts/dzVents/generated_scripts/E_Mag.lua:10: attempt to perform arithmetic on a table value

Topic summary

LABEL_AI_GENERATED
The discussion revolves around transmitting data from a sensor measuring energy generated by photovoltaic panels to a virtual sensor within the Domoticz system. Users inquire about the implementation of a data relay and the specifics of virtual sensors. A script is proposed to calculate the energy balance based on the energy sent to and taken from the grid, with examples provided for coding in dzVents. Errors encountered during script execution are also addressed, focusing on arithmetic operations involving device states and ensuring proper data types are used.
AI summary based on the discussion. May contain errors.
ADVERTISEMENT