Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Possibility to combine or calculated values for MQTT output #12

Open
hubecker opened this issue Nov 14, 2024 · 2 comments
Open

Possibility to combine or calculated values for MQTT output #12

hubecker opened this issue Nov 14, 2024 · 2 comments

Comments

@hubecker
Copy link

I like combine or caclulate some values for MQTT output.
For example values from tibberpulse:

  - source: pulse.currentL1
    topic: TibberPulse/currentL1
  - source: pulse.currentL2
    topic: TibberPulse/currentL2
  - source: pulse.currentL3
    topic: TibberPulse/currentL3

combined into currents like this:

example: [1.2,2.3,-2.1]

  - source:  [<pulse.currentL1>,<currentL2>,<currentL3>]
    topic: openWB/set/counter/0/get/currents 

or
- source: pulse.powerTotal
topic: TibberPulse/powerTotal

  - source: pulse.powerTotal / 1000 kW
    topic: TibberPulse/powerTotal

pulse.powerTotal in W output kW with unit

Another question, can i use type: openmetrics to handle http/https api as output and would it be possible to generalise the tibber-pulse-http as a more common http input to also use for example the tibber api or traccar api or others.

Thanks for our answer and this great broker.

Regards

Hubert

@micw
Copy link
Owner

micw commented Nov 14, 2024

Funny, I have implemented this in a basic fashion a few weeks ago. Have a look into https://github.com/micw/homedatabroker/blob/master/src/main/java/de/wyraz/homedatabroker/source/AggregationSource.java in master.

Here's a config example where I sum my 3 phases:

    - type: aggregation
      id: aggregate
      cron: '*/1 * * * * *'
      metrics:
      - id: gridPowerTotal
        unit: W
        aggregation: sum
        inputMetrics:
        - victron.gridPowerL1
        - victron.gridPowerL2
        - victron.gridPowerL3

Currenly only "sum" is implemented but I can add other aggregations on interest.

Your 2nd example would require some kind of expression parser. Doable (I already implemented a few in my past) but I'd add it only if necessary. For the particular example I'd rather add better support for Units (e.g. if you sum kWh and Wh, conversion could be done automatically).

Openmetrics does support http and https, I use it to feed into victoriametrics.

For a generic http input please create another ticket to collect the ideas. I have the feeling that this could become quite feature-rich :-)

Edit: aggregation also supports to expire input values so that gridPowerTotal will become zero if the inputs are not updated for a particular amount of time.

@hubecker
Copy link
Author

Cool the sum aggregation looks good.
From that it should be easy to add others.
As written i need a string concatenation like this [1.2,2.3,-2.1] to feed my OpenWB MQTT (http and json is also possible)

And as you said this could become quite feature-rich.
This could become a general purpose broker which could handle any kind of Input protokol (HTTP/HTTPS, MQTT, Websocket, ..) and also any kind of Output protokol (HTTP/HTTPS, MQTT, Websocket, ..) or even DBs like influx.
That's my vision when i saw your repository.
By the way i use it already my TibberPulse and partially with my OpenWB Wallbox.

Keep going the good work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants