Skip to content

Query in InfluxDB sensor is now templatable#7634

Merged
balloob merged 1 commit into
home-assistant:devfrom
titilambert:influxdb_sensor
Jun 2, 2017
Merged

Query in InfluxDB sensor is now templatable#7634
balloob merged 1 commit into
home-assistant:devfrom
titilambert:influxdb_sensor

Conversation

@titilambert
Copy link
Copy Markdown
Contributor

Description:

Query in InfluxDB sensor is now templatable

Example entry for configuration.yaml (if applicable):

  - platform: influxdb
    queries:
      - name: influxdb_template_test
        field: 'value'
        group_function: 'mean'
        where: '"entity_id" = ''my_entity'' AND time > now() - {{ states.sensor.mysensor.state | int }}s'
        measurement: '"°C"'

Checklist:

  • Local tests with tox run successfully. Your PR cannot be merged unless tests pass
  • Tests have been added to verify that the new code works.

@mention-bot
Copy link
Copy Markdown

@titilambert, thanks for your PR! By analyzing the history of the files in this pull request, we identified @bestlibre and @fabaff to be potential reviewers.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

line too long (83 > 79 characters)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

undefined name 'TemplateError'

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

undefined name 'template'

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should only instantiate templates using voluptuous. So use cv.template as a validator and set the hass object on it if it is not None.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed !

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

undefined name 'formated_query'

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done !

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

local variable 'query_template' is assigned to but never used
undefined name 'formated_query'

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

blank line contains whitespace

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done!

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

undefined name 'formated_query'

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

undefined name 'TemplateError'

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

local variable 'query_template' is assigned to but never used
undefined name 'template'
undefined name 'formated_query'

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

blank line contains whitespace

@titilambert
Copy link
Copy Markdown
Contributor Author

Tests passed and all requests done !

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should render the template each time the sensor updates and we send a new query to influxdb, so add it in InfluxSensorData.

@titilambert
Copy link
Copy Markdown
Contributor Author

@balloob Changes done !

@balloob
Copy link
Copy Markdown
Member

balloob commented Jun 2, 2017

Top! Thanks 👍 🐬

@balloob balloob merged commit 613da30 into home-assistant:dev Jun 2, 2017
@balloob balloob mentioned this pull request Jun 2, 2017
@home-assistant home-assistant locked and limited conversation to collaborators Sep 4, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants