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

Add sensor platform for SolarEdge Monitoring API #18846

Merged
merged 16 commits into from
Dec 19, 2018

Conversation

GidoHakvoort
Copy link
Contributor

@GidoHakvoort GidoHakvoort commented Nov 30, 2018

Description:

Pull request in home-assistant.io with documentation (if applicable): home-assistant/home-assistant.io#7735

Example entry for configuration.yaml (if applicable):

sensor:
  - platform: solaredge
    api_key: YOUR_API_KEY
    site_id: YOUR_SITE_ID
    name: SolarEdge
    monitored_conditions:
      - currentPower
      - lastDayData
      - lastMonthData
      - lastYearData

Checklist:

  • The code change is tested and works locally.
  • Local tests pass with tox. Your PR cannot be merged unless tests pass
  • There is no commented out code in this PR.

If user exposed functionality or configuration variables are added/changed:

If the code communicates with devices, web services, or third-party tools:

  • New dependencies have been added to the REQUIREMENTS variable (example).
  • New dependencies are only imported inside functions that use them (example).
  • New or updated dependencies have been added to requirements_all.txt by running script/gen_requirements_all.py.
  • New files were added to .coveragerc.

If the code does not interact with devices:

  • Tests have been added to verify that the new code works.

Copy link
Member

@pvizeli pvizeli left a comment

Choose a reason for hiding this comment

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

homeassistant/components/sensor/solaredge.py Outdated Show resolved Hide resolved
homeassistant/components/sensor/solaredge.py Outdated Show resolved Hide resolved
homeassistant/components/sensor/solaredge.py Outdated Show resolved Hide resolved
homeassistant/components/sensor/solaredge.py Outdated Show resolved Hide resolved
@GidoHakvoort
Copy link
Contributor Author

@pvizeli Thanks, should be fixed

homeassistant/components/sensor/solaredge.py Outdated Show resolved Hide resolved
homeassistant/components/sensor/solaredge.py Outdated Show resolved Hide resolved
homeassistant/components/sensor/solaredge.py Outdated Show resolved Hide resolved
homeassistant/components/sensor/solaredge.py Outdated Show resolved Hide resolved
homeassistant/components/sensor/solaredge.py Outdated Show resolved Hide resolved
homeassistant/components/sensor/solaredge.py Outdated Show resolved Hide resolved
homeassistant/components/sensor/solaredge.py Outdated Show resolved Hide resolved
homeassistant/components/sensor/solaredge.py Outdated Show resolved Hide resolved
homeassistant/components/sensor/solaredge.py Outdated Show resolved Hide resolved
Added async_update to sensor class
Added Throttle to SolarEdge data update
Added CONF_NAME to platform settings
Added credentials check for api
Minor code style changes
@Mariusthvdb
Copy link
Contributor

HI,

great to see this is being developed. Please allow me to ask while you're still at it, if you will also be adding the Inventory sensor, next to the planned Overview sensors:
fyi, this is how these are/(were with json) extracted, maybe you can add them, since they require the same site id and key:

- platform: jsonrest
  resource: !secret se_inventory_resource
  method: GET
  name: SolarEdge Inventory
  scan_interval: 3600

- platform: jsonrest
  resource: !secret se_overview_resource
  method: GET
  name: SolarEdge Overview
  scan_interval: 3600

- platform: template
  sensors:
    solaredge_overview_last_updated:
      friendly_name: Last updated
      value_template: "{{ states.sensor.solaredge_overview.attributes.overview.lastUpdateTime | timestamp_custom ('%H:%M') }}"
    solaredge_overview_lifetime:
      friendly_name: Lifetime
      value_template: '{{ (states.sensor.solaredge_overview.attributes.overview.lifeTimeData.energy | float / 1000000) | round(2) }}'
      unit_of_measurement: 'MWh'
    solaredge_overview_last_year:
      friendly_name: Last year
      value_template: '{{ (states.sensor.solaredge_overview.attributes.overview.lastYearData.energy | float / 1000) | round(1) }}'
      unit_of_measurement: 'kWh'
    solaredge_overview_last_month:
      friendly_name: Last month
      value_template: '{{ (states.sensor.solaredge_overview.attributes.overview.lastMonthData.energy | float / 1000) | round(1) }}'
      unit_of_measurement: 'kWh'
    solaredge_overview_last_day:
      friendly_name: Last day
      value_template: '{{ (states.sensor.solaredge_overview.attributes.overview.lastDayData.energy | float / 1000) | round(1) }}'
      unit_of_measurement: 'kWh'
    solaredge_overview_current_power:
      friendly_name: Current power
      value_template: '{{ (states.sensor.solaredge_overview.attributes.overview.currentPower.power | float / 1000) | round(2) }}'
      unit_of_measurement: 'kW'

    solaredge_inventory_name:
      friendly_name: Name
      value_template: '{{states.sensor.solaredge_inventory.attributes.Inventory.inverters[0].name}}'
    solaredge_inventory_manufacturer:
      friendly_name: Mnf
      value_template: '{{states.sensor.solaredge_inventory.attributes.Inventory.inverters[0].manufacturer}}'
    solaredge_inventory_model:
      friendly_name: Model
      value_template: '{{states.sensor.solaredge_inventory.attributes.Inventory.inverters[0].model}}'
    solaredge_inventory_communication:
      friendly_name: Comm
      value_template: '{{states.sensor.solaredge_inventory.attributes.Inventory.inverters[0].communicationMethod}}'
    solaredge_inventory_dsp1:
      friendly_name: Dsp1
      value_template: '{{states.sensor.solaredge_inventory.attributes.Inventory.inverters[0].dsp1Version}}'
    solaredge_inventory_dsp2:
      friendly_name: Dsp2
      value_template: '{{states.sensor.solaredge_inventory.attributes.Inventory.inverters[0].dsp2Version}}'
    solaredge_inventory_cpu:
      friendly_name: Cpu
      value_template: '{{states.sensor.solaredge_inventory.attributes.Inventory.inverters[0].cpuVersion}}'
    solaredge_inventory_sn:
      friendly_name: Sn
      value_template: '{{states.sensor.solaredge_inventory.attributes.Inventory.inverters[0].SN}}'
    solaredge_inventory_optimizers:
      friendly_name: Opt
      value_template: '{{states.sensor.solaredge_inventory.attributes.Inventory.inverters[0].connectedOptimizers}}'

maybe even consider site-details and equipment-list?
thanks.

@GidoHakvoort
Copy link
Contributor Author

Hi @Mariusthvdb,

Thanks, nice suggestion, I will look into it. For the site details I could add an additional sensor which will be updated once a day (SolarEdge has a daily query limit of 300 requests). Details such as site id, name, status, peak power, etc. could then be added as attributes to a sensor (e.g. solaredge_site_details). For the inventory, I might be able to separate this per equipment type (e.g. meters, sensors, gateways, etc). This might however be a bit more difficult as these are lists. If you have any suggestions, let me know.

Updated platform setup
homeassistant/components/sensor/solaredge.py Outdated Show resolved Hide resolved
homeassistant/components/sensor/solaredge.py Outdated Show resolved Hide resolved
homeassistant/components/sensor/solaredge.py Outdated Show resolved Hide resolved
homeassistant/components/sensor/solaredge.py Outdated Show resolved Hide resolved
homeassistant/components/sensor/solaredge.py Outdated Show resolved Hide resolved
homeassistant/components/sensor/solaredge.py Outdated Show resolved Hide resolved
homeassistant/components/sensor/solaredge.py Outdated Show resolved Hide resolved
homeassistant/components/sensor/solaredge.py Outdated Show resolved Hide resolved
homeassistant/components/sensor/solaredge.py Outdated Show resolved Hide resolved
homeassistant/components/sensor/solaredge.py Outdated Show resolved Hide resolved
Correct import for PLATFORM_SCHEMA
Correct return statements
Remove initial update call
Copy link
Member

@MartinHjelmare MartinHjelmare left a comment

Choose a reason for hiding this comment

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

Looks good! Can be merged when build passes.

@GidoHakvoort
Copy link
Contributor Author

Thanks @MartinHjelmare, I've also been looking at the suggestions of @Mariusthvdb and have some ideas on how to integrate these sensors as well. Will add them in a later update of the platform.

@MartinHjelmare MartinHjelmare merged commit 258fe1f into home-assistant:dev Dec 19, 2018
@ghost ghost removed the in progress label Dec 19, 2018
@GidoHakvoort GidoHakvoort deleted the solaredge branch December 19, 2018 09:08
dshokouhi pushed a commit to dshokouhi/home-assistant that referenced this pull request Dec 25, 2018
* Adding sensor for SolarEdge Monitoring API support

* Adding support for Rova garbage calendar

* Update solaredge to pass lint and flake8

* Added solaredge.py to .coveragerc

* Added extend for Voluptuous schema

* Fixed styling issues

* Removed rova.py for later feature

* Replaced API requests with python pip package

* Fixed styling issues

* Updated to new async syntax
Added async_update to sensor class
Added Throttle to SolarEdge data update
Added CONF_NAME to platform settings
Added credentials check for api
Minor code style changes

* Remove unnecessary debug logging

* Updated dict keys

* Added SCAN_INTERVAL
Updated platform setup

* Remove DOMAIN variable
Correct import for PLATFORM_SCHEMA

* Change some debug to error messages
Correct return statements
Remove initial update call

* Fix pylint and flake8 errors
@balloob balloob mentioned this pull request Jan 10, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants