『瀚思彼岸』» 智能家居技术论坛

 找回密码
 立即注册
查看: 474|回复: 9

[已解决] 怎样把api key显示在web后台

[复制链接]

8

主题

92

帖子

380

积分

中级会员

Rank: 3Rank: 3

积分
380
金钱
288
HASS币
0
发表于 2024-6-10 21:25:02 | 显示全部楼层 |阅读模式
本帖最后由 qq707432712 于 2024-6-13 18:13 编辑

小白最近在折腾铁通插排 通过ESPhome编译固件时 怎样能使api key在web后台显示 不然的话接入HA的时候 老是得去翻yaml文件 很是不方便 还有个问题 编译固件的时候 怎样设置成配网时 连接插排不需要密码
这是我在论坛下载的源码 希望有大佬能指点指点
1-common-component

text_sensor:
  - platform: version
    name: "sensor-Version"
    id: id_sensor_version
    hide_timestamp: true
  - platform: wifi_info
    ip_address:
      name: "sensor-IP"
      id: id_sensor_ip
    bssid:
      name: "sensor-BSSID"
      id: id_sensor_bssid
    mac_address:
      name: "sensor-MAC"
      id: id_sensor_mac
  - platform: template
    name: "sensor-Uptime"
    id: id_sensor_uptime
    entity_category: diagnostic
sensor:
  - platform: uptime
    id: id_sensor_uptime_raw
    update_interval: 15min
    internal: true
    on_raw_value:
      then:
        - text_sensor.template.publish:
            id: id_sensor_uptime
            state: !lambda |-
              int seconds = round(id(id_sensor_uptime_raw).raw_state);
              int days = seconds / (24 * 3600);
              seconds = seconds % (24 * 3600);
              int hours = seconds / 3600;
              seconds = seconds % 3600;
              int minutes = seconds /  60;
              seconds = seconds % 60;
              return (
                (days ? String(days) + "d " : "") +
                (hours ? String(hours) + "h " : "") +
                (minutes ? String(minutes) + "m " : "") +
                (String(seconds) + "s")
              ).c_str();
  - platform: wifi_signal
    name: "sensor-WifiSignal"
    id: id_sensor_wifisignal
    update_interval: 15min
  - platform: template
    name: "esp-Cpu Freq"
    id: id_esp_cpu_freq
    lambda: |-
      return ESP.getCpuFreqMHz();
    unit_of_measurement: "MHz"
    update_interval: 10s
  - platform: template
    name: "esp-Free Memory Byte"
    id: id_esp_free_memory_byte
    lambda: |-
      return ESP.getFreeHeap();
    filters:
      - multiply: 0.001
    unit_of_measurement: "KB"
    update_interval: 10s
  - platform: template
    name: "esp-Memory Frag"
    id: id_esp_memory_Frag
    lambda: |-
      return ESP.getHeapFragmentation();
    unit_of_measurement: "%"
    update_interval: 10s
binary_sensor:
  - platform: status
    name: "sensor-LinkStatus"
    id: id_sensor_linkstatus


1-common-esp8266-2m
#FRIENDLY NAMING
#Entity name is a combination of the [friendly name and component name]
#Entity ID is derived from the [entity name with the device name prepended]
#Example:
#
#esphome:
#   name: "livingroomdesk"
#   friendly_name: "Living room desk"
#
#sensor:
#   name: "Temperature"
#
#The entity will be named Living room desk Temperature and will default to having an entity ID of sensor.livingroomdesk_temperature.
#
#LEGACY NAMING
#Entity name is the component name
#Device name is not prepended to the entity name
#Entity ID is derived solely from the entity name
#Example:
#
#esphome:
#   name: "livingroomdesk"
#
#sensor:
#   name: "Temperature"
#
#The entity will be named Temperature and will default to having an entity_id of sensor.temperature.
#注释:使用esphome:friendly_name节点之后,在homeassistant中对esphome的name和id重新定义:
#  1.   Entity name的格式为[friendly_name] + ' ' + [各个组件的name]
#  2.   Entity id的格式为[esphome的name] + '_' + [各个组件的name]
#  3.   Device name的格式[friendly_name] + ' ' + [mac地址后6位]
#  3.   esphome的name名称中不能有'_'。
#  举例:
#如果yaml中如下配置:  
#  node_name: plug-lenovo
#  node_name_friendly: "Lenovo.SHD-SPL0-001"
#  esp设备的mac地址: 807d3a74dba8
#  name_add_mac_suffix: true ---node_name后面添加mac地址后6位
#  yaml中某一个组件(switch、sensor、light等)的name: switch-relay0
# 那么在homeassistant中:
#   Entity name: [Lenovo.SHD-SPL0-001 74dba8 switch-relay0]
#   Entity id: [switch.plug_lenovo_74dba8_switch_relay0]
#   Device name: [Lenovo.SHD-SPL0-001 74dba8 switch-relay0]
#因此如果使用name_add_mac_suffix: true的模式编译的固件,同时使用了friendly_name,就可以保证homeassistant中Entity id的唯一性。
#用途:批量删除同一型号的设备再重新添加,只要不改变esphome yaml中的节点名称和组件名称,Entity id不会变化,所有用到这个Entity id的自动化或者脚本都不需要变动,便于维护。
#如果不使用这种方式,删除再重新添加之后,Entity id是乱序的,homeassistant会给相同的esphome_id添加'_1', '_2', '_3'这样的后缀,设备多了就无法维护了。

esphome:
  name: ${node_name}
  friendly_name: ${node_name_friendly}
  project:
    name: ${node_project_name}
    version: ${node_project_version}
  name_add_mac_suffix: ${node_name_add_mac_suffix}
  min_version: ${node_build_min_version}
esp8266:
  board: esp_wroom_02
  restore_from_flash: false  

wifi:
  id: id_wifi
  ap:
    ssid: "${node_name}"
    password: !secret ap_password
    ap_timeout: 0s

captive_portal:

logger:
    level: INFO

api:
  encryption:
    key: !secret api_key
  #避免未接入homeassistant时,模块一直重启(默认15分钟重启一次)
  reboot_timeout: 0s

ota:
  password: !secret ota_password

web_server:
  port: 80
  include_internal: true
  version: 1

switch:
  - platform: restart
    name: "system-Restart"
    id: id_restart

  - platform: factory_reset
    name: "system-FactoryReset"
    id: id_factoryreset

cmcc-powerbord-sy7t609

###########################################################################################
#注意事项:
# 1.固件的编译环境为esphome-v2023.11.4,可正常编译运行;不想升级esphome版本,则需要修改min_version的值,尝试编译固件。
# 2.OTA升级固件之后,请长按电源键5秒,等待蓝灯闪烁,重置设备并重新配网,最好对插排断电10秒以上,避免出现奇怪的问题。
#固件功能:
#一.插排按钮:
# 1.实现智能模式与普通模式。
#   功能可配置,为normal或者smart模式,web界面或者homeassistant中下拉框选择。
#    normal: 普通模式,插排按钮按下之后全开或者全关
#    smart:  智能模式(此模式为默认模式),插排按钮按下之后只操作[主继电器]通断,不改变[从继电器]之前的状态
# 2.长按、双击、单击操作
#   长按:按住电源按钮5秒以上,插排会重置flash上的信息(包括插座记忆状态),并进入配网状态,
#   双击:双击电源键,从继电器接通或断开
#   单击:单击电源键,按下实现第[1]条功能配置的相应模式(智能模式/普通模式)
#二.指示灯
#   蓝灯常亮:wifi已连接
#   蓝灯熄灭:wifi未连接
#   蓝灯闪烁:ap配网模式
#   红灯闪烁/熄灭:esphome status_led light
#   白灯常亮:从继电器 真正通电
#   白灯熄灭:从继电器 真正断电
#三.断电记忆
#   记忆状态写入间隔1分钟,也就是说开关等组件状态发生变化,1分钟后才会被记录到flash,下次通电之后可恢复这个状态(可以配置成0s,所有状态变化立刻写入flash,但频繁的状态变化会缩短flash寿命。)
#四.计量功能
# 1.sy7t609计量芯片已驱动
#   (1)支持电压、电流、有功功率、无功功率、功率因数、电度量、频率、温度等esphome sensor。
#   (2)支持累计电度量清零、重置校准寄存器、打印寄存器原始数据的esphome action
# 2.yaml文件修改点
#   配置缺一不可:logger:[baud_rate:0]、uart:[xxxxx]、sensor:[platform: sy7t609]、external_components:[xxxx]]
# 3.sy7t609驱动组件与配置
#   (1)下载地址:https://github.com/shzlww/esphome_custom_components.git,空余时间写的,主要为了实现功能,基本没写代码注释。
#   (2)esphome的yaml中配置外部组件有两种方式:git和local。
#      (2.1)git模式直接用此yaml即可
#      (2.2)local模式需要下载zip源码包,解压后将components(注意是components,不是esphome_custom_components)整个目录复制到esphome的conf目录下
#   (3)编译之前,最好清理一下原来编译的中间文件:esphome网页端 - yaml文件 - 三个点 - Clean Build Files
#
#五.其他改动
# 1.新增功率power sensor的副本power median sensor,此副本采用median_filter(中值过滤器),可用于homeassistant中的能源统计,避免原始power sensor的数据异常抖动,导致能源统计错误,
#     之前使用pzem004t_v3的模块就遇到过上电启动后几秒内,采集到的数据都特别大,导致homeassistant中能源统计异常还没办法删除。目前的配置是:每采集5个,升序排序后上报中间的第三个值,然后丢弃最小值,如此反复。会和实际值有误差,但是大大降低了采集数据波动的影响。
# 2.新增esphome:friendly_name节点,使用esphome:friendly_name节点之后,在homeassistant中对esphome的name和id重新定义:
#     * Entity name的格式为[friendly_name] + ' ' + [各个组件的name]
#     * Entity id的格式为[esphome的name]+ '_' + [mac地址后6位] + '_' + [各个组件的name]
#     * Device name的格式[friendly_name] + ' ' + [mac地址后6位]
#   使用场景:当设备较多时,从homeassistant中批量新增或者删除设备会导致entity_id发生变化,导致配置的自动化失效,如果配置了esphome:friendly_name和 esphome:name_add_mac_suffix: true,就可以保证entity_id唯一,批量增删设备不影响自动化。
# 3.新增sensor:total_daily_energy,统计每日用电量(这是esphome模拟计算的,并且使用的第1条中的power median sensor来统计的,会和寄存器的值有误差,用于前端展示不需要很高的精度)
# 4.新增button/switch:button-清零每日电度量、button-清零累计电度量、button-重置校准寄存器、button-打印寄存器数据、switch-操作确认开关。
#  【使用这几个功能之前需要先打开switch-操作确认开关,然后再点击对应的button,防止误操作】
# 5.其他:新增sensor: 采集cpu频率、剩余内存容量、内存碎片占比、esphome版本号、IP、MAC、Uptime等诊断信息
# 6.新增电度量断电记忆功能,sy7t609的电度量是在内存中保存的,断电会丢失,因此使用esp的flash来保存电度量。
# 7.新增重置按钮,实现重置系统的同时,清零总电度量、每日电度量。系统默认的重置按钮保留。
#六.待完善部分(暂不实现)
# 1.由于这个计量芯片寄存器变量比较多,目前实现的基本够用,其他的都是高级功能,大部分人用不到--
#    --比如视在功率、反向有功电度量、设置采集精度、阈值报警、自动校准模式、自动上报模式(目前用的是主动轮询模式)等等非常多。
# 2.利用esphome的number组件,来配置各个校准寄存器的数据,进行手动校准。
# 3.利用sy7t609 MCU内置的自动校准来实现数据校准。原厂默认支持的是恒压220v、恒流1A的负载,来进行自动校准各个寄存器。
#七、测试
# 1.固件目前稳定运行了10小时,功能正常。
# 2.IGAIN寄存器的电流使用的UNI-T的万用表10A电流档校准的,有更高精度的电表可以自行修改源码,设置igain寄存器。校准公式:IGAIN_new = IGAIN_old * IRMS_TARGET / IRMS ,通俗讲就是[新igain=当前igain*设备实际电流/寄存器采集的电流]
############################################################################################
substitutions:
  button_pin: GPIO4
  relay_reset_pin: GPIO12
  relay_set_pin: GPIO0
  relay_latch_pin: GPIO15
  led_blue_pin: GPIO16
  led_red_pin: GPIO14
  led_white_pin: GPIO5
  #重要-批量部署到设备上之后,不要去修改node_name和各组件的name(sensor、switch、light等),会导致homeassistant中id变化,影响已有的自动化与脚本。
  #下面这三个键值与各组件的name,可以保证homeassistant中id的唯一性。批量删除设备再添加,homeassistant中的id也不会变化。
  node_name: "cmcc-powerboard"
  node_name_friendly: "CMCC.CMPOWER-W1"
  node_name_add_mac_suffix: "true"
  #可选填
  node_project_name: "CMCC.CMPOWER-W1"
  node_project_version: "v3.0.0(espressif-esp12s-sy7t609)"
  node_build_min_version: "2023.11.4"

packages:
  common: !include 1-common-esp8266-2m.yaml
  common-component: !include 1-common-component.yaml

esphome:
  on_boot:
    - priority: 0
      then:
        - output.turn_off: id_pin_relay_reset
        - output.turn_off: id_pin_relay_set
        - lambda: |-
            if(nullptr != esphome::captive_portal::global_captive_portal)
            {
              //配网模式,蓝色led闪烁
              if(esphome::captive_portal::global_captive_portal->is_active() && !id(id_wifi).is_connected())
              {
                id(id_led_blue).turn_off().perform();
                id(id_led_blue).turn_on().set_effect("fast").perform();
              }
            }

esp8266:
  restore_from_flash: true

preferences:
  flash_write_interval: 1min

web_server:
  version: 2
external_components:
  ####local mode####
  - source:
      type: local
      path: components
    components: [ sy7t609 ]
  ####git mode######
  # - source: github://shzlww/esphome_custom_components@20240103
  #   components: [ sy7t609 ]
wifi:
  #使用use_address对使用mac地址修饰esphome:name的设备进行ota
  #use_address: cmcc-powerboard-26faec.local
  on_connect:
    - light.turn_on:
        id: id_led_blue
        effect: "None"
  on_disconnect:
    - light.turn_off: id_led_blue

logger:
    level: INFO
    baud_rate: 0

output:
  #继电器触发使能引脚
  - platform: gpio
    id: id_pin_relay_latch
    pin:
      number: ${relay_latch_pin}
      inverted: true

  - platform: gpio
    id: id_pin_relay_set
    pin:
      number: ${relay_set_pin}
      inverted: true

  - platform: gpio
    id: id_pin_relay_reset
    pin:
      number: ${relay_reset_pin}
      inverted: true

  #白色led
  - platform: esp8266_pwm
    id: id_pin_led_white
    pin:
      number: ${led_white_pin}
      inverted: true

  #蓝色led
  - platform: esp8266_pwm
    id: id_pin_led_blue
    pin:
      number: ${led_blue_pin}
      inverted: true

  #红色led
  - platform: esp8266_pwm
    id: id_pin_led_red
    pin:
      number: ${led_red_pin}
      inverted: true

  - platform: template
    id: fake_out
    type: float
    write_action:
      - logger.log: "NoThing"

light:
  #白色led(分路继电器的状态)
  - platform: monochromatic
    name: light-Led White
    id: id_led_white
    output: id_pin_led_white
    restore_mode: ALWAYS_OFF
    default_transition_length: 0s
    internal: true

  #蓝灯常亮-wifi已连接
  #蓝灯灯闪烁-配网模式
  #红灯闪烁,蓝灯熄灭-wifi未连接
  #蓝色led(wifi状态)  
  - platform: monochromatic
    name: light-Led Blue
    id: id_led_blue
    output: id_pin_led_blue
    restore_mode: ALWAYS_OFF
    default_transition_length: 0s
    internal: true
    effects:
        #配网模式
      - pulse:
          name: "fast"
          transition_length: 0ms
          update_interval: 100ms

        #预留(未使用,可用作指示其他状态)
      - pulse:
          name: "slow"
          transition_length: 200ms
          update_interval: 500ms
  #红色led(wifi状态与配网状态)
  - platform: status_led
    name: light-Led Red
    id: id_led_red
    output: id_pin_led_red
    internal: true

#  红蓝灯合并(后期实现彩色status_led)
#  - platform: cwww
#    name: "light-CWWW Status Led "
#    cold_white: pin_led_blue
#    warm_white: pin_led_red
#    cold_white_color_temperature: 6536 K
#    warm_white_color_temperature: 2000 K
#    constant_brightness: true
#    restore_mode: ALWAYS_OFF
#    default_transition_length: 0s
#    effects:
#      - pulse:
#          name: "fast"
#          transition_length: 0ms
#          update_interval: 100ms

button:
  #实现一个电平反转,触发继电器动作
  - platform: output
    #name: button-Relay Trigger
    id: id_trigger_relay_latch
    output: id_pin_relay_latch
    duration: 10ms
    internal: true
  #重置计量芯片寄存器上的电度量
  - platform: template
    name: adv-ResetEnergyTotal
    id: id_button_reset_energy_total
    on_press:
      then:
        - if:
            condition:
              switch.is_on: id_switch_operate_confirm
            then:
              - globals.set:
                  id: id_energy_counter_persist
                  value: '0.0'
              - sy7t609.reset_energy: id_sensor_sy7t609
              - switch.turn_off: id_switch_operate_confirm
  #重置esp计算的的每日电度量
  - platform: template
    name: adv-ResetEnergyDaily
    id: id_button_reset_energy_daily
    on_press:
      then:
        - if:
            condition:
              switch.is_on: id_switch_operate_confirm
            then:
              - lambda: |-
                  id(id_total_daily_energy_median).publish_state_and_save(0.0f);
              - switch.turn_off: id_switch_operate_confirm
  #重置校准寄存器信息
  - platform: template
    name: adv-ResetCalibration
    id: id_button_reset_calibration
    on_press:
      then:
        - if:
            condition:
              switch.is_on: id_switch_operate_confirm
            then:
              - sy7t609.reset_calibration: id_sensor_sy7t609
              - switch.turn_off: id_switch_operate_confirm
  #打印调试信息
  - platform: template
    name: adv-PrintRegister
    id: id_button_debug
    on_press:
      then:
        - if:
            condition:
              switch.is_on: id_switch_operate_confirm
            then:
              - sy7t609.debug: id_sensor_sy7t609
              - switch.turn_off: id_switch_operate_confirm
switch:
  #重置系统(并且所有电度量)
  - platform: template
    name: "system-FactoryReset-WithEnergyCounter"
    id: id_factoryreset_with_energy_counter
    optimistic: true
    restore_mode: ALWAYS_OFF
    on_turn_on:
      then:
        - sy7t609.reset_energy: id_sensor_sy7t609
        - delay: 20ms   #确保uart命令可以执行成功
        - lambda: |-
            id(id_energy_counter_persist) = 0.0f;
            id(id_total_daily_energy_median).publish_state_and_save(0.0f);
        - switch.toggle: id_factoryreset

  - platform: template
    name: adv-Confirm
    id: id_switch_operate_confirm
    optimistic: true
    restore_mode: ALWAYS_OFF
    #插排按钮-逻辑开关
  - platform: template
    id: id_power_key_logic
    name: switch-Power Key
    optimistic: true
    restore_mode: ALWAYS_ON
    on_turn_on:
      then:
        - light.turn_on: id_led_white
        - script.execute: id_power_turn_on_relay
        - script.wait: id_power_turn_on_relay
    on_turn_off:
      then:
        - light.turn_off: id_led_white
        - script.execute: id_power_turn_off_relay
        - script.wait: id_power_turn_off_relay

#插排电源按钮
binary_sensor:
  - platform: gpio
    #name: button-Power Key Real
    id: id_power_key
    internal: true
    pin:
      number: ${button_pin}
      inverted: true
      mode:
        input: true
        pullup: true
    #插排电源按钮单击、长按功能
    on_multi_click:
    #长按5s以上,重置为出厂模式,进入配网状态
    - timing:
        - ON for at least 5s
      then:
        - logger.log: "Long press."
        - switch.turn_on: id_factoryreset_with_energy_counter
      invalid_cooldown: 0s
    #双击
    - timing:
        - ON for at most 0.5s
        - OFF for at most 0.5s
        - ON for at most 0.5s
        - OFF for at least 0.2s
      then:
        - logger.log: "double click."
      invalid_cooldown: 0s      
    #单击
    - timing:
        - ON for at most 0.3s
        - OFF for at least 0.2s
      then:
        - logger.log: "single click."
        - switch.toggle: id_power_key_logic
      invalid_cooldown: 0s

script:
  - id: id_power_turn_on_relay
    then:
      - button.press: id_trigger_relay_latch
      - output.turn_on: id_pin_relay_set
      - delay: 70ms
      - button.press: id_trigger_relay_latch
      - output.turn_off: id_pin_relay_set
  - id: id_power_turn_off_relay
    then:
      - button.press: id_trigger_relay_latch
      - output.turn_on: id_pin_relay_reset
      - delay: 70ms
      - button.press: id_trigger_relay_latch
      - output.turn_off: id_pin_relay_reset

time:
  - platform: homeassistant
    id: id_homeassistant_time
    timezone: "Asia/Shanghai"

uart:
  tx_pin: 1
  rx_pin: 3
  baud_rate: 9600
  stop_bits: 1
  data_bits: 8
  parity: NONE

sensor:
  - platform: sy7t609
    id: id_sensor_sy7t609
    power_factor:
      name: "energy-Power Factor"
      id: id_sensor_pf
    voltage:
      name: "energy-Voltage"
      id: id_sensor_voltage
    current:
      name: "energy-Current"
      id: id_sensor_current
    power:
      name: "energy-Power"
      id: id_sensor_power
    reactive_power:
      name: "energy-Reactive Power"
      id: id_sensor_reactive_power
    energy:
      name: "energy-Energy Counter"
      id: id_sensor_energy
    frequency:
      name: "energy-Frequency"
      id: id_sensor_frequency
    chip_temperature:
      name: "energy-Chip Temperature"
      id: id_sensor_chip_temperature
    update_interval: 3s

  - platform: total_daily_energy
    name: "energy-DailyEnergy"
    id: id_total_daily_energy_median
    power_id: id_energy_median_power
    accuracy_decimals: 2
    device_class: "energy"
    state_class: "total_increasing"
    icon: "mdi:counter"
    restore: true
    unit_of_measurement: Wh

  #功率传感器(power)的副本,使用中值滤波器,过滤掉异常抖动的数据,缺点就是需要缓存采集的数据,状态反馈慢。可用作homeassistant中能源统计的功率。
  #1.中值滤波是一种非线性数字滤波器技术,经常用于去除图像或者其它信号中的噪声。
  #2.检查输入信号中的采样并判断它是否代表了信号,使用奇数个采样组成的观察窗实现这项功能。
  #3.观察窗口中的数值进行排序,位于观察窗中间的中值作为输出。
  #4.然后丢弃最早的值,取得新的采样,重复上面的计算过程。
  - platform: copy
    name: energy-MedianPower
    id: id_energy_median_power
    source_id: id_sensor_power
    filters:
      - median:
          window_size: 5
          send_every: 3
          send_first_at: 3

  #电度量数据持久化存储到esp芯片的flash中,实现断电记忆电度量
  - platform: copy
    name: energy-Energy Counter(Persist)
    id: id_sensor_energy_counter_persist
    source_id: id_sensor_energy

#计量芯片sy7t609的电度量计数器是内存存储的,断电会丢失,因此使用esp的全局变量存储电度量
globals:
  - id: id_energy_counter_persist
    type: float
    restore_value: yes
    initial_value: '0.0'
  - id: id_energy_counter_lastvalue
    type: float
    restore_value: no
    initial_value: '0.0'



回复

使用道具 举报

10

主题

122

帖子

643

积分

高级会员

Rank: 4

积分
643
金钱
521
HASS币
0
发表于 2024-6-11 13:26:06 | 显示全部楼层
配置文件保留api:就可以了,自家局域网使用没必要API加密
api:

回复

使用道具 举报

8

主题

92

帖子

380

积分

中级会员

Rank: 3Rank: 3

积分
380
金钱
288
HASS币
0
 楼主| 发表于 2024-6-11 19:13:04 | 显示全部楼层
qxdnzx 发表于 2024-6-11 13:26
配置文件保留api:就可以了,自家局域网使用没必要API加密

可以把api弄到web后台吗 之前刷过一个固件 后台就能显示apikey 自己弄的固件就没有
回复

使用道具 举报

0

主题

16

帖子

122

积分

注册会员

Rank: 2

积分
122
金钱
106
HASS币
0
发表于 2024-6-12 01:41:54 | 显示全部楼层
回复

使用道具 举报

8

主题

92

帖子

380

积分

中级会员

Rank: 3Rank: 3

积分
380
金钱
288
HASS币
0
 楼主| 发表于 2024-6-12 07:40:04 | 显示全部楼层

老鸟勿喷 我是小白 麻烦大佬详细说明下 需要在那个yaml文件里怎样配置 谢谢
回复

使用道具 举报

0

主题

16

帖子

122

积分

注册会员

Rank: 2

积分
122
金钱
106
HASS币
0
发表于 2024-6-12 23:06:30 | 显示全部楼层
本帖最后由 ganguotu 于 2024-6-12 23:18 编辑

我也是新手,之前也不了解这个插排,刚才看了一下,你用的配置文件是这个帖子的,https://bbs.hassbian.com/thread-23734-1-1.html,20240103版本的,没用最新版是不是?
按照你当前用的版本,可以试一下我写的这个:
1.api key在web后台显示在 1-common-component.yaml 第四行的 text_sensor: 下新增一组:platform: template
text_sensor:
  - platform: template
    name: "api-key"
    id: id_api_key
    filters:
      - lambda: return {"your-api-key"};
  - platform: version
    name: "sensor-Version"
    id: id_sensor_version
    hide_timestamp: true

2.配网时,插排热点不设置密码
在 1-common-esp8266-2m.yaml 注释掉第64行的 wifi.ap.password
wifi:
  id: id_wifi
  ap:
    ssid: "${node_name} hotspot"
    # password: !secret ap_password
    ap_timeout: 0s












回复

使用道具 举报

0

主题

16

帖子

122

积分

注册会员

Rank: 2

积分
122
金钱
106
HASS币
0
发表于 2024-6-12 23:15:27 | 显示全部楼层
ganguotu 发表于 2024-6-12 23:06
我也是新手,之前也不了解这个插排,刚才看了一下,你用的配置文件是这个帖子的,https://bbs.hassbian.com ...

这破编辑器代码块渲染太拉了,第一个代码块是:
text_sensor:
  - platform: template
    name: "api-key"
    id: id_api_key
    filters:
      - lambda: return {"your-api-key"};

  - platform: version
    name: "sensor-Version"
    id: id_sensor_version
    hide_timestamp: true
绿色是新增的
回复

使用道具 举报

8

主题

92

帖子

380

积分

中级会员

Rank: 3Rank: 3

积分
380
金钱
288
HASS币
0
 楼主| 发表于 2024-6-12 23:19:19 | 显示全部楼层
ganguotu 发表于 2024-6-12 23:06
我也是新手,之前也不了解这个插排,刚才看了一下,你用的配置文件是这个帖子的,https://bbs.hassbian.com ...

谢谢大佬按照您的方法 WiFi密码搞定了 apikey听取了前面一个大佬的意见 去掉了 确实自己局域网里面没必要加密
回复

使用道具 举报

0

主题

16

帖子

122

积分

注册会员

Rank: 2

积分
122
金钱
106
HASS币
0
发表于 2024-6-12 23:47:17 | 显示全部楼层
qq707432712 发表于 2024-6-12 23:19
谢谢大佬按照您的方法 WiFi密码搞定了 apikey听取了前面一个大佬的意见 去掉了 确实自己局域网里面没必要 ...

我也搞糊涂了,话说不是只有第一次接入HA的时候需要api-key吗,而且ESPHome设备没接入的的时候HA也看不见配置的 text-sensor 呀,总结就是没什么用
回复

使用道具 举报

8

主题

92

帖子

380

积分

中级会员

Rank: 3Rank: 3

积分
380
金钱
288
HASS币
0
 楼主| 发表于 2024-6-13 07:37:56 | 显示全部楼层
ganguotu 发表于 2024-6-12 23:47
我也搞糊涂了,话说不是只有第一次接入HA的时候需要api-key吗,而且ESPHome设备没接入的的时候HA也看不见 ...

对啊 就是在第一次接入HA的时候需要key 要是设备web后台有显示的话 可以去后台复制一下 不然得翻secrets文件
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

Archiver|手机版|小黑屋|Hassbian

GMT+8, 2024-7-27 08:19 , Processed in 0.174868 second(s), 31 queries .

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表