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

[sensor/sma] SMA Solar Inverter sensor #5118

Merged
merged 3 commits into from
Jan 9, 2017

Conversation

kellerza
Copy link
Member

@kellerza kellerza commented Dec 31, 2016

Description:
This is a sensor for an SMA solar inverter with WebConnect.

There are 4 predefined sensors, but new sensor keys can be added in the custom section. These values can found by inspecting the local web interface's traffic.

Currently tested on Sunnyboy 1.5 (should be ok for 2.5)

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

Example entry for configuration.yaml (if applicable):

sensor sma:
  - platform: sma
    host: 192.168.88.199
    password: !secret sma_password
    group: installer
    sensors:
      current_consumption: [total_consumption]
      current_power: 
      total_yield: 
      some_new_sensor:
    custom:
      some_new_sensor:
        key: 6100_40263ZZZ
        unit: kW

Checklist:

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

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

  • Local tests with tox run successfully. Your PR cannot be merged unless tests pass
  • New dependencies have been added to the REQUIREMENTS variable (example).
  • New dependencies are only imported inside functions that use them (example).
  • New dependencies have been added to requirements_all.txt by running script/gen_requirements_all.py.
  • New files were added to .coveragerc.

@mention-bot
Copy link

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

@kellerza
Copy link
Member Author

@pvizeli this sensor need to close it's session on EVENT_HOMEASSISTANT_STOP. It uses async and the shared aiohttp session.

Unfortunately the session gets closed before the sensor gets time to send it's "logout" request. This raises the following exception

Any ideas how we can keep the session open until all components that rely on it successfully closes?

@pvizeli
Copy link
Member

pvizeli commented Jan 5, 2017

@kellerza create you own session without auto cleanup and cleanup self after close. See on helpers/aiohttp_client

@pvizeli
Copy link
Member

pvizeli commented Jan 5, 2017

I will change that the default session close with connector, so you code will work. I make a PR for that at morning.

@pvizeli pvizeli mentioned this pull request Jan 6, 2017
6 tasks
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.

Looks good. Only a short comment and I merge it.

yield from asyncio.wait(tasks, loop=hass.loop)

secs = range(0, 60, config.get(CONF_SCAN_INTERVAL, 5))
async_track_utc_time_change(hass, async_sma, second=secs)
Copy link
Member

Choose a reason for hiding this comment

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

We have a new helpers with timedelta support and now CONF_SCAN_INTERVAL is also a timedelta.

@pvizeli pvizeli merged commit e6a9b64 into home-assistant:dev Jan 9, 2017
@kellerza kellerza deleted the sma_sensor branch January 9, 2017 20:38
@home-assistant home-assistant locked and limited conversation to collaborators Apr 30, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants