跳转至

即时股票行情-使用rest集成

操作步骤

  1. 获得聚合数据平台股票数据AppKey
  2. 测试聚合数据平台
  3. 配置sensor.rest
  4. 配置仅在开盘时间刷新数据
  5. 配置行情lovelace界面

参考

  • 聚合数据平台

https://www.juhe.cn/

  • json文本格式化与检查

https://jsonlint.com/

  • sensor.rest配置说明

https://www.home-assistant.io/integrations/sensor.rest/

  • 完整配置

    # configuration.yaml sensor: - platform: rest name: 青岛啤酒 resource: http://web.juhe.cn:8080/finance/stock/hs?gid=sh600600&key=d5ebb478eeea3dcda10e7e4c09cebd0c value_template: '{{ value_json.result[0].data.nowPri }}' scan_interval: 9999 json_attributes: - result

``` # automations.yaml - alias: 青岛啤酒股价更新 initial_state: true trigger: platform: time_pattern seconds: '/30'

condition:
  condition: or
  conditions:
    - condition: time
      after: '08:58:00'
      before: '11:02:00'
    - condition: time
      after: '12:58:00'
      before: '15:02:00'
action:
  - service: homeassistant.update_entity
    entity_id: sensor.qing_dao_pi_jiu

```

返回课程目录↩