#------------------------------------------- # @CCOSTAN # Original Repo : https://github.com/CCOSTAN/Home-AssistantConfig # PiHole ad Blocking Related Packages # https://www.vcloudinfo.com/2019/03/revisiting-the-pi-on-pi-day-with-home-assistant.html # YouTube Video - https://youtu.be/woA88DFlH5c #------------------------------------------- sensor: - platform: pi_hole host: 192.168.10.11:80 location: admin ssl: false verify_ssl: false monitored_conditions: - ads_blocked_today - ads_percentage_today - dns_queries_today - domains_being_blocked - queries_cached - queries_forwarded - unique_clients - unique_domains - platform: template sensors: carlopihole: friendly_name: 'Carlo-PiHole' entity_id: [] value_template: "{{ 'Online' if is_state('device_tracker.carlopihole', 'home') else 'Offline' }}" # Pi-Hole switch switch: - platform: command_line switches: pihole_temp_disable: command_on: "curl -X GET 'http://192.168.10.11/admin/api.php?enable&auth='" command_off: "curl -X GET 'http://192.168.10.11/admin/api.php?disable=3600&auth='" # command_state: "curl -X GET 'http://192.168.10.11/admin/api.php?status'| grep enabled" # value_template: "{{ value_json.status == 'enabled' }} #------------------------------------------- group: pihole: entities: - sensor.carlopihole - sensor.pi_hole_version - sensor.pi_hole_dns_unique_clients - sensor.pi_hole_dns_queries_today - sensor.pi_hole_ads_blocked_today - sensor.pi_hole_ads_percentage_today - sensor.pi_hole_ads_percentage_blocked_today - switch.pihole_temp_disable #------------------------------------------- automation: - alias: PiHole Daily stats Tweet! trigger: platform: time at: '23:50:00' action: - delay: '00:{{ range(0,5) | random | int }}{{ range(0,9) | random | int }}:00' - service: script.tweet_engine_image data_template: tweet: > {{ [ "I blocked {{states.sensor.pi_hole_ads_blocked_today.state}} ads. That is {{states.sensor.pi_hole_ads_percentage_blocked_today.state}}% of my internet traffic.", "Today was a good day! Why, you ask? Because I blocked {{states.sensor.pi_hole_ads_blocked_today.state}} ads via Pi-Hole!", ] | random + " #PiHole #Security Status:({{states.sensor.carlopihole.state}})"}} image: >- {{ [ "/config/www/custom_ui/floorplan/images/branding/servers.png", "/config/www/custom_ui/floorplan/images/branding/servers2.png", "/config/www/custom_ui/floorplan/images/branding/servers3.png", "/config/www/custom_ui/floorplan/images/branding/servers4.png" ] | random }} - alias: PiHole Daily Client Tweet! trigger: platform: time at: '04:30:00' action: - delay: '0{{ (range(1, 5)|random|int) }}:{{ range(0,5) | random | int }}{{ range(0,9) | random | int }}:00' - service: script.tweet_engine_image data_template: tweet: > {{ [ "There are currently {{states.sensor.pi_hole_dns_unique_clients.state}} clients on my network.", "As reported by #Ubiquiti Routers, There are {{states.sensor.pi_hole_dns_unique_clients.state}} clients on my network.", ] | random + "#Security https://github.com/CCOSTAN/Home-AssistantConfig#networking"}} image: >- {{ [ "/config/www/custom_ui/floorplan/images/branding/servers.png", "/config/www/custom_ui/floorplan/images/branding/servers2.png", "/config/www/custom_ui/floorplan/images/branding/servers3.png", "/config/www/custom_ui/floorplan/images/branding/servers4.png" ] | random }}