platypush.plugins.pihole

class platypush.plugins.pihole.PiholePlugin(server: Optional[str] = None, password: Optional[str] = None, api_key: Optional[str] = None, ssl: bool = False, verify_ssl: bool = True, **kwargs)[source]

Plugin for interacting with a Pi-Hole DNS server for advertisement and content blocking.

__init__(server: Optional[str] = None, password: Optional[str] = None, api_key: Optional[str] = None, ssl: bool = False, verify_ssl: bool = True, **kwargs)[source]
Parameters:
  • server – Default Pi-hole server IP address.
  • password – Password for the default Pi-hole server.
  • api_key – Alternatively to the password, you can also provide the server api_key, as retrieved from http://pi-hole-server/admin/scripts/pi-hole/php/api_token.php
  • ssl – Set to true if the host uses HTTPS (default: False).
  • verify_ssl – Set to False to disable SSL certificate check.
blacklist_add(domain: str, server: Optional[str] = None, password: Optional[str] = None, api_key: Optional[str] = None, ssl: bool = None)[source]

Add a domain to the blacklist.

Parameters:
  • domain – Domain name.
  • server – Server IP address (default: default configured server value).
  • password – Server password (default: default configured password value).
  • api_key – Server API key (default: default configured api_key value).
  • ssl – Set to True if the server uses SSL (default: False).
blacklist_remove(domain: str, server: Optional[str] = None, password: Optional[str] = None, api_key: Optional[str] = None, ssl: bool = None)[source]

Remove a domain from the blacklist.

Parameters:
  • domain – Domain name.
  • server – Server IP address (default: default configured server value).
  • password – Server password (default: default configured password value).
  • api_key – Server API key (default: default configured api_key value).
  • ssl – Set to True if the server uses SSL (default: False).
disable(server: Optional[str] = None, password: Optional[str] = None, api_key: Optional[str] = None, seconds: Optional[int] = None, ssl: bool = None)[source]

Disable a Pi-hole server.

Parameters:
  • seconds – How long the server will be disabled in seconds (default: None, indefinitely).
  • server – Server IP address (default: default configured server value).
  • password – Server password (default: default configured password value).
  • api_key – Server API key (default: default configured api_key value).
  • ssl – Set to True if the server uses SSL (default: False).
enable(server: Optional[str] = None, password: Optional[str] = None, api_key: Optional[str] = None, ssl: bool = None)[source]

Enable a Pi-hole server.

Parameters:
  • server – Server IP address (default: default configured server value).
  • password – Server password (default: default configured password value).
  • api_key – Server API key (default: default configured api_key value).
  • ssl – Set to True if the server uses SSL (default: False).
get_blacklist(server: Optional[str] = None, ssl: bool = None) → List[str][source]

Get the content of the blacklist.

Parameters:
  • server – Server IP address (default: default configured server value).
  • ssl – Set to True if the server uses SSL (default: False).
get_list(list_name: str, server: Optional[str] = None, ssl: bool = None) → List[str][source]

Get the content of a list stored on the server.

Parameters:
  • list_name – List name
  • server – Server IP address (default: default configured server value).
  • ssl – Set to True if the server uses SSL (default: False).
get_whitelist(server: Optional[str] = None, ssl: bool = None) → List[str][source]

Get the content of the whitelist.

Parameters:
  • server – Server IP address (default: default configured server value).
  • ssl – Set to True if the server uses SSL (default: False).
list_add(list_name: str, domain: str, server: Optional[str] = None, password: Optional[str] = None, api_key: Optional[str] = None, ssl: bool = None)[source]

Add a domain to a custom list stored on the server.

Parameters:
  • list_name – List name
  • domain – Domain name.
  • server – Server IP address (default: default configured server value).
  • password – Server password (default: default configured password value).
  • api_key – Server API key (default: default configured api_key value).
  • ssl – Set to True if the server uses SSL (default: False).
list_remove(list_name: str, domain: str, server: Optional[str] = None, password: Optional[str] = None, api_key: Optional[str] = None, ssl: bool = None)[source]

Remove a domain from a custom list stored on the server.

Parameters:
  • list_name – List name
  • domain – Domain name.
  • server – Server IP address (default: default configured server value).
  • password – Server password (default: default configured password value).
  • api_key – Server API key (default: default configured api_key value).
  • ssl – Set to True if the server uses SSL (default: False).
status(server: Optional[str] = None, password: Optional[str] = None, api_key: Optional[str] = None, ssl: bool = None) → platypush.message.response.pihole.PiholeStatusResponse[source]

Get the status and statistics of a running Pi-hole server.

Parameters:
  • server – Server IP address (default: default configured server value).
  • password – Server password (default: default configured password value).
  • api_key – Server API key (default: default configured api_key value).
  • ssl – Set to True if the server uses SSL (default: False).
Returns:

platypush.message.response.pihole.PiholeStatusResponse

whitelist_add(domain: str, server: Optional[str] = None, password: Optional[str] = None, api_key: Optional[str] = None, ssl: bool = None)[source]

Add a domain to the whitelist.

Parameters:
  • domain – Domain name.
  • server – Server IP address (default: default configured server value).
  • password – Server password (default: default configured password value).
  • api_key – Server API key (default: default configured api_key value).
  • ssl – Set to True if the server uses SSL (default: False).
whitelist_remove(domain: str, server: Optional[str] = None, password: Optional[str] = None, api_key: Optional[str] = None, ssl: bool = None)[source]

Remove a domain from the whitelist.

Parameters:
  • domain – Domain name.
  • server – Server IP address (default: default configured server value).
  • password – Server password (default: default configured password value).
  • api_key – Server API key (default: default configured api_key value).
  • ssl – Set to True if the server uses SSL (default: False).
class platypush.plugins.pihole.PiholeStatus[source]

An enumeration.