碳排放强度
非官方测试版翻译
本页面由 PageTurner AI 翻译(测试版)。未经项目官方认可。 发现错误? 报告问题 →
功能
使用 Carbon Intensity API 的数据,以 gCO2/kWh 为单位显示当前和预测的碳排放强度。
备注
请注意,目前该模块仅提供英国的数据。未来可能会支持其他国家。
示例配置
注意
该 API 可能响应较慢。建议将 http_timeout 属性设置为较大的值(例如 5000)。
- json
- yaml
- toml
{
"type": "carbonintensity",
"style": "powerline",
"powerline_symbol": "",
"foreground": "#000000",
"background": "#ffffff",
"background_templates": [
"{{if eq \"very low\" .Index}}#a3e635{{end}}",
"{{if eq \"low\" .Index}}#bef264{{end}}",
"{{if eq \"moderate\" .Index}}#fbbf24{{end}}",
"{{if eq \"high\" .Index}}#ef4444{{end}}",
"{{if eq \"very high\" .Index}}#dc2626{{end}}"
],
"template": " CO₂ {{ .Index.Icon }}{{ .Actual.String }} {{ .TrendIcon }} {{ .Forecast.String }} ",
"options": {
"http_timeout": 5000
}
}
type: carbonintensity
style: powerline
powerline_symbol:
foreground: "#000000"
background: "#ffffff"
background_templates:
- '{{if eq "very low" .Index}}#a3e635{{end}}'
- '{{if eq "low" .Index}}#bef264{{end}}'
- '{{if eq "moderate" .Index}}#fbbf24{{end}}'
- '{{if eq "high" .Index}}#ef4444{{end}}'
- '{{if eq "very high" .Index}}#dc2626{{end}}'
template: " CO₂ {{ .Index.Icon }}{{ .Actual.String }} {{ .TrendIcon }} {{
.Forecast.String }} "
options:
http_timeout: 5000
type = "carbonintensity"
style = "powerline"
powerline_symbol = ""
foreground = "#000000"
background = "#ffffff"
background_templates = [ "{{if eq \"very low\" .Index}}#a3e635{{end}}", "{{if eq \"low\" .Index}}#bef264{{end}}", "{{if eq \"moderate\" .Index}}#fbbf24{{end}}", "{{if eq \"high\" .Index}}#ef4444{{end}}", "{{if eq \"very high\" .Index}}#dc2626{{end}}" ]
template = " CO₂ {{ .Index.Icon }}{{ .Actual.String }} {{ .TrendIcon }} {{ .Forecast.String }} "
[options]
http_timeout = 5000
选项
| Name | Type | Default | Description |
|---|---|---|---|
http_timeout | int | 20 | Timeout (in milliseconds) for HTTP requests. The default is 20ms, but you may need to set this to as high as 5000ms to handle slow API requests. |
模板 (信息)
默认模板
CO₂ {{ .Index.Icon }}{{ .Actual.String }} {{ .TrendIcon }} {{ .Forecast.String }}
属性
| Name | Type | Description |
|---|---|---|
.Forecast | Number | The forecast carbon intensity in gCO2/kWh. Equal to 0 if no data is available. |
.Actual | Number | The actual carbon intensity in gCO2/kWh. Equal to 0 if no data is available. |
.Index | Index | A rating of the current carbon intensity. Possible values are "very low", "low", "moderate", "high", or "very high". Equal to "??" if no data is available. |
.TrendIcon | string | An icon representation of the predicted trend in carbon intensity based on the Actual and Forecast values. Possible values are "↗", "↘", or "→". |
Number
| Name | Type | Description |
|---|---|---|
.String | string | string representation of the value |
Index
| Name | Type | Description |
|---|---|---|
.Icon | string | icon representation of the value |