Skip to content

Commit

Permalink
Add SSL verification control
Browse files Browse the repository at this point in the history
  • Loading branch information
amaximus committed Aug 10, 2023
1 parent 63fac6b commit 2b55d3a
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 7 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ Define sensor with the following configuration parameters:<br />
| name | **Y** | `pollen_hu` | name of the sensor |
| all_dominant | **Y** | `False` | gather all dominant pollens. By the default it will show the first dominant pollen even if there are others too. |
| pollens | **Y** | `` | list of pollen names to filter on. |
| ssl | **Y** | `true` | control SSL verification. This is useful when CA store update with new root/intermediate certificates is problematic. WARNING: setting this to `false` is a security breach. |
---

#### Example
Expand Down
2 changes: 1 addition & 1 deletion custom_components/pollen_hu/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"name": "Pollen Information Hungary",
"documentation": "https://github.com/amaximus/pollen_hu",
"issue_tracker": "https://github.com/amaximus/pollen_hu/issues",
"version": "0.4.0",
"version": "0.5.0",
"dependencies": [],
"codeowners": ["@amaximus"],
"iot_class": "cloud_polling",
Expand Down
11 changes: 8 additions & 3 deletions custom_components/pollen_hu/sensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,26 +19,30 @@
CONF_ATTRIBUTION = "Data provided by antsz.hu"
CONF_NAME = 'name'
CONF_POLLENS = 'pollens'
CONF_SSL = 'ssl'

DEFAULT_ALLDOMINANT = False
DEFAULT_ICON = 'mdi:blur'
DEFAULT_NAME = 'Pollen HU'
DEFAULT_SSL = True

SCAN_INTERVAL = timedelta(hours=1)

PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
vol.Optional(CONF_NAME, default=DEFAULT_NAME): cv.string,
vol.Optional(CONF_ALLDOMINANT, default=DEFAULT_ALLDOMINANT): cv.boolean,
vol.Optional(CONF_POLLENS, default=[]): vol.All(cv.ensure_list, [cv.string]),
vol.Optional(CONF_SSL, default=DEFAULT_SSL): cv.boolean,
})

async def async_setup_platform(hass, config, async_add_devices, discovery_info=None):
name = config.get(CONF_NAME)
alldominant = config.get(CONF_ALLDOMINANT)
pollens = config.get(CONF_POLLENS)
ssl = config.get(CONF_SSL)

async_add_devices(
[PollenHUSensor(hass, name, alldominant, pollens )],update_before_add=True)
[PollenHUSensor(hass, name, alldominant, pollens, ssl)],update_before_add=True)

async def async_get_pdata(self):
pjson = {"pollens": []}
Expand Down Expand Up @@ -78,16 +82,17 @@ async def async_get_pdata(self):

class PollenHUSensor(Entity):

def __init__(self, hass, name, alldominant, pollens):
def __init__(self, hass, name, alldominant, pollens, ssl):
"""Initialize the sensor."""
self._hass = hass
self._name = name
self._alldominant = alldominant
self._state = None
self._pdata = []
self._pollens = pollens
self._ssl = ssl
self._icon = DEFAULT_ICON
self._session = async_get_clientsession(hass)
self._session = async_get_clientsession(hass, ssl)

@property
def extra_state_attributes(self):
Expand Down
1 change: 1 addition & 0 deletions info.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ Define sensor with the following configuration parameters:<br />
| name | **Y** | `pollen_hu` | name of the sensor |
| all_dominant | **Y** | `False` | gather all dominant pollens. By the default it will show the first dominant pollen even if there are others too. |
| pollens | **Y** | `` | list of pollen names to filter on. |
| ssl | **Y** | `true` | control SSL verification. This is useful when CA store update with new root/intermediate certificates is problematic. WARNING: setting this to `false` is a security breach. |
---

#### Example
Expand Down
6 changes: 3 additions & 3 deletions tracker.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"pollen_hu": {
"version": "0.4.0",
"updated_at": "2023-07-10",
"version": "0.5.0",
"updated_at": "2023-08-10",
"visit_repo": "https://github.com/amaximus/pollen_hu",
"changelog": "https://github.com/amaximus/pollen_hu/releases/0.4.0"
"changelog": "https://github.com/amaximus/pollen_hu/releases/0.5.0"
}
}

0 comments on commit 2b55d3a

Please sign in to comment.