Comments (7)
This would probably be a good way for me to learn both Python and guts of ES, so I'd love to give it a go but don't take this as a "cool someone else is doing it", if I thought I had the capacity to currently do this, I wouldn't have created this ticket in the first place ;)
This is clearly not urgent and much more of a nice to have, but I'm not a huge fan of the pull method and I would rather stream my data to HASS than to read from a database.
from homeassistant-elasticsearch.
Hey @wickedsun, thanks for opening this issue.
This is an interesting idea. How do you envision this working with a query that returns multiple hits, or multiple buckets in an aggregation?
For queries that return a single hit, I could see something like this working:
elastic:
query_sensors:
- name: sensor_1
query: '{"query": { "terms": {...} }}'
field: 'my.document.field'
Where my.document.field
represents a field in the document returned by the query
from homeassistant-elasticsearch.
How do you envision this working with a query that returns multiple hits, or multiple buckets in an aggregation?
That's a good question. My use case may be very specific. My thought was using geolocation from ElasticSearch to do geofencing since I have stuff going straight to Elastic. Then I thought "hey wait that'd be nice to do geofencing with", and short of rewriting the script to send to MQTT as well as ES, I don't think I can do it.
My guess would be that people who use Elastic for HASS would also like to be able to do this as usually you're going to be putting a lot more data into it other than HASS with no way of tying it into HASS.
For queries that return a single hit, I could see something like this working:
I'd also add a time constraint so that you can do last (non-empty) value only or X minutes average. I can see a scenario where someone might want to turn off the AC if the average over the last 15minutes is lower than X rather that the absolute current value, for example. Obviously this would need buckets/aggregation.
Honestly for what I want to do, last geolocation values would do the trick, but the possibilities with this would be pretty awesome since ES is very powerful.
from homeassistant-elasticsearch.
I'd also add a time constraint so that you can do last (non-empty) value only or X minutes average.
Is this something that you could solve with Elasticsearch's date math, or am I mis-understanding?
Honestly for what I want to do, last geolocation values would do the trick, but the possibilities with this would be pretty awesome since ES is very powerful.
Maybe we just take the top hit (hits.hits[0]
) as the sensor value, and log a warning if more than one hit is returned? Alternatively, the component could enforce a size: 1
for document queries. A similar constraint could be placed for aggregations, but I haven't given that a ton of thought yet.
from homeassistant-elasticsearch.
My knowledge of ES is pretty bare, but I'll try answering.
It does look like date math would solve that part as you could do "now-X".
Let me explain clearly what I'm trying to do here. I'm getting readings from my car's location every ~4 seconds and this is dumped into ES. I wanted to use that for geofencing since... I already have it so why go through the trouble of setting up something on my phone like OwnTrack when I can just track my car.
I saw that there was a SQL sensor and figured there must be a ES sensor too, then. To my surprise there wasn't, hence this ticket.
from homeassistant-elasticsearch.
I was also surprised to find there wasn't an ES component, hence this one 😄. I started this one with the opposite problem though -- getting data from HASS into ES, rather than from ES to HASS. That being said, I don't see why this can't accomplish both.
I have a couple of other enhancements I'd like to work on before tackling this, so I likely won't get to this right away. PRs are welcome if you're handy with Python. I'm not a strong Python dev by any means...this was my first and only real project with the language.
from homeassistant-elasticsearch.
I think this might be best served by a separate device-type integration where you can add "devices" which are just elasticsearch queries
from homeassistant-elasticsearch.
Related Issues (20)
- Indexing failures with existing datastreams HOT 1
- Stop accessing `hass.components.hassio`
- Split out async_migrate_entry HOT 3
- Entity/Domain Inclusion/Exclusion precedence is not consistent / slightly broken HOT 5
- [Draft] Preparing for Home Assistant Inclusion HOT 2
- Achieve 100% code coverage of config flow
- Add deprecation notice for legacy index support HOT 1
- Use elasticsearchv8 library HOT 4
- Performance profiling HOT 5
- Remove Elasticsearch v7 Support and no-auth option HOT 3
- Improve Test Coverage to 97+% HOT 1
- Meet requirements for Platinum-level Integrations HOT 1
- Separate configuration for polling vs event tracking settings HOT 2
- Identify and resolve any remaining HASS deprecation warnings
- Investigate removing YAML config HOT 1
- ES and Kibana bootstrapping fails in certain Docker configurations
- Publishing All States doesn't fire if there are no state/attribute changes in the queue
- Cache sanitized datastream and attribute names HOT 1
- Consider removing some core attributes that duplicate other fields
- Strict dynamic mapping is going to cause issues HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from homeassistant-elasticsearch.