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

Provide an example to import data from CSV #7

Open
arthurzenika opened this issue Mar 29, 2023 · 3 comments
Open

Provide an example to import data from CSV #7

arthurzenika opened this issue Mar 29, 2023 · 3 comments

Comments

@arthurzenika
Copy link

Issue #3 talks about having an UI for importing CSV. Maybe a step forward would be to have some example code for people at ease with python to start manipulating / inserting data using this custom_component ? (am trying to figure out how ideenergy is using this module)

@beanonymous
Copy link

beanonymous commented Jul 20, 2023

After revewing the code I noted that the function "async_update_historical" is some what important to relaying the data to HA in the file "sensor.py" but suspect that the real work is undertaken in file "api.py".

Based off the only function in that file "fetch" it appears to generate random data as what I can see generating in HA

@ldotlopez any chance you can provide a dummy example of the way you want the CSV data loaded into the sensor?

@pafnow
Copy link

pafnow commented Jul 20, 2023

Interested as well !

@ldotlopez
Copy link
Owner

Hi,

Historical sensors doesn't support importing from CSV (but it's feature I want to add).

@beanonymous, you are right, api.py just generates random (but stable) data, it simulates an external data provider.

The simplified schema is:

In order to import CSV data we need to define "how":

  • import csv data into HistoricalSensor.historical_states and wait to HistoricalSensor.async_write_ha_historical_states to handle it?
  • or wrap HistoricalSensor.async_write_ha_historical_states directly to import CSV data?
  • or any other way

However, CSV data format should be very simple:
timestamp-or-ISO-8601 (UTC), value

Value needs to be parsed to native type in some second phase.

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

4 participants