Compare commits

...

2 commits

Author SHA1 Message Date
5b66f4718f autohuttli: add the PM6006 device
All checks were successful
continuous-integration/drone/push Build is passing
2024-10-28 18:45:25 +00:00
45eb71a6ba autohuttli: move the site common code to a include 2024-10-28 18:45:02 +00:00
4 changed files with 171 additions and 48 deletions

1
.gitignore vendored
View file

@ -6,3 +6,4 @@ __pycache__/
build/
tmp.*
drone/
*~

View file

@ -18,48 +18,10 @@ esp32:
sdkconfig_options:
CONFIG_ESP32S3_DEFAULT_CPU_FREQ_160: y
external_components:
- source:
type: local
path: components
logger:
http_request:
timeout: 30s
verify_ssl: false
api:
encryption:
key: !secret api_key
ota:
- platform: esphome
- platform: http_request
update:
- platform: http_request
id: auto_update
source: "https://juju.nz/michaelh/assets/esphome/${project_name}.json"
interval:
- startup_delay: 4hours
interval: 10min
then:
- update.perform: auto_update
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
power_save_mode: "HIGH"
# Connect to the first AP found.
fast_connect: true
time:
- platform: homeassistant
id: homeassistant_time
timezone: Europe/Zurich
binary_sensor:
- platform: gpio
id: button
@ -69,16 +31,6 @@ binary_sensor:
inverted: true
name: "Button"
switch:
- platform: restart
name: "Restart"
- platform: template
name: "Update"
icon: "mdi:update"
turn_on_action:
then:
- update.perform: auto_update
light:
- platform: esp32_rmt_led_strip
id: led
@ -89,3 +41,5 @@ light:
rmt_channel: 0
chipset: ws2812
name: "LED"
<<: !include base.yaml

51
base.yaml Normal file
View file

@ -0,0 +1,51 @@
external_components:
- source:
type: local
path: components
logger:
http_request:
timeout: 30s
verify_ssl: false
api:
encryption:
key: !secret api_key
ota:
- platform: esphome
- platform: http_request
update:
- platform: http_request
id: auto_update
source: "https://juju.nz/michaelh/assets/esphome/${project_name}.json"
interval:
- startup_delay: 4hours
interval: 10min
then:
- update.perform: auto_update
wifi:
ssid: !secret wifi_ssid
password: !secret wifi_password
power_save_mode: "HIGH"
# Connect to the first AP found.
fast_connect: true
time:
- platform: homeassistant
id: homeassistant_time
timezone: Europe/Zurich
switch:
- platform: restart
name: "Restart"
- platform: template
name: "Update"
icon: "mdi:update"
turn_on_action:
then:
- update.perform: auto_update

117
pm6006.yaml Normal file
View file

@ -0,0 +1,117 @@
substitutions:
device_name: PM6006 Amplifier
device_id: pm6006
project_name: juju.pm6006
extra_version: ""
project_version: "0.2${extra_version}"
esphome:
name: ${device_id}
name_add_mac_suffix: true
project:
name: "${project_name}"
version: "${project_version}"
platform: esp8266
board: modwifi
status_led:
pin:
number: GPIO1
inverted: True
binary_sensor:
- platform: gpio
name: "PM6006 power sense"
id: pm6006_power_sense
pin:
number: 15
remote_transmitter:
pin:
number: GPIO13
carrier_duty_percent: 100%
switch:
- platform: template
name: "PM6006 power"
icon: "mdi:power"
lambda: |-
if (id(pm6006_power_sense).state) {
return true;
} else {
return false;
}
turn_on_action:
if:
condition:
binary_sensor.is_off: pm6006_power_sense
then:
- remote_transmitter.transmit_rc5:
address: 0x10
command: 0x0C
# Needs to be sent twice to reliably wake up.
repeat: 2
- delay: 500ms
- if:
# However, sometimes it turns on then off. Turn on again if so.
condition:
binary_sensor.is_off: pm6006_power_sense
then:
- remote_transmitter.transmit_rc5:
address: 0x10
command: 0x0C
repeat: 2
turn_off_action:
if:
condition:
binary_sensor.is_on: pm6006_power_sense
then:
- remote_transmitter.transmit_rc5:
address: 0x10
command: 0x0C
repeat: 2
- delay: 500ms
- if:
# However, sometimes it doesn't turn off.
condition:
binary_sensor.is_on: pm6006_power_sense
then:
- remote_transmitter.transmit_rc5:
address: 0x10
command: 0x0C
repeat: 2
- platform: template
name: "PM6006 volume up"
icon: "mdi:volume-plus"
turn_on_action:
remote_transmitter.transmit_rc5:
address: 0x10
command: 16
turn_off_action:
remote_transmitter.transmit_rc5:
address: 0x10
command: 16
- platform: template
name: "PM6006 volume down"
icon: "mdi:volume-minus"
turn_on_action:
remote_transmitter.transmit_rc5:
address: 0x10
command: 17
turn_off_action:
remote_transmitter.transmit_rc5:
address: 0x10
command: 17
- platform: template
name: "PM6006 mute"
icon: "mdi:volume-mute"
turn_on_action:
remote_transmitter.transmit_rc5:
address: 0x10
command: 13
turn_off_action:
remote_transmitter.transmit_rc5:
address: 0x10
command: 13
<<: !include base.yaml