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

Question: feed values from API to inverter? #15

Open
tobiasehlert opened this issue Jan 14, 2022 · 5 comments
Open

Question: feed values from API to inverter? #15

tobiasehlert opened this issue Jan 14, 2022 · 5 comments

Comments

@tobiasehlert
Copy link

Nice project @nmakel!

I got two questions:

  1. Is it possible to add an "api-device", where you can point to a data source providing measurements similar to the devices you support. And with this I am thinking to parse my providers load-monitor (Tibber Pulse (Swedish page)) and return that data back to this application in a giant JSON file or so. This could of course also be adapted to other providers, if there is some data available, as long as it's correct formatted.
    What you think?

  2. Is it possible to both read modbus over tcp from the inverter (to collect metrics) and feed the inverter with information over tcp (add measurements at the mainfuses) at the same time?

Kind regards,
Tobias

@nmakel
Copy link
Owner

nmakel commented Jan 14, 2022

Nice project @nmakel!

Thanks!

1. Is it possible to add an "api-device", where you can point to a data source providing measurements similar to the devices you support. And with this I am thinking to parse my providers load-monitor ([Tibber Pulse](https://tibber.com/se/store/produkt/pulse) (Swedish page)) and return that data back to this application in a giant JSON file or so. This could of course also be adapted to other providers, if there is some data available, as long as it's correct formatted.
   What you think?

Sure, a script which uses the requests library to grab a JSON object from an API endpoint should be easy to implement. I recommend you have a look at the already implemented devices to get a feel for what needs to be collected.

2. Is it possible to both read modbus over tcp from the inverter (to collect metrics) and feed the inverter with information over tcp (add measurements at the mainfuses) at the same time?

I'm afraid not. The inverter only communicates with meters over the RS485 bus.

@tobiasehlert
Copy link
Author

Sure, a script which uses the requests library to grab a JSON object from an API endpoint should be easy to implement. I recommend you have a look at the already implemented devices to get a feel for what needs to be collected.

Alright awesome! I could write something in go to be able to generate a JSON with those values you have in the other devices.
Would it be easy for you to add an api-device in Python then? I've never written Python 😄

I'm afraid not. The inverter only communicates with meters over the RS485 bus.

Damnit!
But would it go to provide data over RS485 to the inverter but connect to it from another device collecting all metrics over TCP?

@nmakel
Copy link
Owner

nmakel commented Jan 14, 2022

Alright awesome! I could write something in go to be able to generate a JSON with those values you have in the other devices. Would it be easy for you to add an api-device in Python then? I've never written Python smile

It feels like you're overcomplicating things. Given an API you should be able to retrieve its data using a library such as requests. This yields JSON/XML/CSV which should be simple to insert into the dictionary as documented in generic.py.

This method should be trivial to adapt to any existing API or device which speaks HTTP and returns JSON/XML/CSV.

Damnit! But would it go to provide data over RS485 to the inverter but connect to it from another device collecting all metrics over TCP?

I'm currently collecting data from my inverter using solaredge_modbus via Modbus TCP. At the same time I am providing meter values to the inverter over RS485 using this solaredge_meterproxy script. The only limitation is that the inverter's Modbus TCP connection only allows a single connection at a time.

@tobiasehlert
Copy link
Author

It feels like you're overcomplicating things. Given an API you should be able to retrieve its data using a library such as requests. This yields JSON/XML/CSV which should be simple to insert into the dictionary as documented in generic.py.

This method should be trivial to adapt to any existing API or device which speaks HTTP and returns JSON/XML/CSV.

There seems to be a Python library for Tibber (on GitHub) but to get realtime consumption, it's needed to have a graphql subscription. I don't know how to integrate that fully.. but you might want to look?

There is an API explorer on their developer page, where you can get a demo token and then paste following JSON:

subscription {
  liveMeasurement(homeId: "cc83e83e-8cbf-4595-9bf7-c3cf192f7d9c") {
    timestamp
    power
    powerProduction
    powerFactor
    voltagePhase1
    voltagePhase2
    voltagePhase3
    currentL1
    currentL2
    currentL3
  }
}

The return looks something like this (and gets updated very frequently):

{
  "liveMeasurement": {
    "timestamp": "2022-01-14T17:19:40.000+01:00",
    "power": 2207,
    "powerProduction": 0,
    "powerFactor": 0.979,
    "voltagePhase1": 218,
    "voltagePhase2": 221,
    "voltagePhase3": 221,
    "currentL1": 1.98,
    "currentL2": 5.87,
    "currentL3": 3.02
  }
}

Or is there a major lack of values that would need to be provided? 🤔

@nmakel
Copy link
Owner

nmakel commented Mar 3, 2022

It feels like you're overcomplicating things. Given an API you should be able to retrieve its data using a library such as requests. This yields JSON/XML/CSV which should be simple to insert into the dictionary as documented in generic.py.
This method should be trivial to adapt to any existing API or device which speaks HTTP and returns JSON/XML/CSV.

There seems to be a Python library for Tibber (on GitHub) but to get realtime consumption, it's needed to have a graphql subscription. I don't know how to integrate that fully.. but you might want to look?

There is an API explorer on their developer page, where you can get a demo token and then paste following JSON:

subscription {
  liveMeasurement(homeId: "cc83e83e-8cbf-4595-9bf7-c3cf192f7d9c") {
    timestamp
    power
    powerProduction
    powerFactor
    voltagePhase1
    voltagePhase2
    voltagePhase3
    currentL1
    currentL2
    currentL3
  }
}

The return looks something like this (and gets updated very frequently):

{
  "liveMeasurement": {
    "timestamp": "2022-01-14T17:19:40.000+01:00",
    "power": 2207,
    "powerProduction": 0,
    "powerFactor": 0.979,
    "voltagePhase1": 218,
    "voltagePhase2": 221,
    "voltagePhase3": 221,
    "currentL1": 1.98,
    "currentL2": 5.87,
    "currentL3": 3.02
  }
}

Or is there a major lack of values that would need to be provided? thinking

It isn't obvious which values are absolutely required by the inverter to do what it needs to do. The voltage and current will also give you the power values, and I suspect you will need to get the cumulative import and export kWh from somewhere. The Tibber API is heavily focussed on pricing, which makes sense, but light on actual grid and quality data.

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