safe-zone
OpenClaw skill for SafeZone — provides GPS location, local weather, fire/flood alerts, geocoding, and emergency SOS dispatch for the SafeZone R1 Creation. Polls shared R1 storage for pending commands and responds via the same bridge.
- License 许可
- MIT
- 最近更新
- 2026-09-04
- Stars
- ★ 0
- Forks
- 0
01 前言 Front Matter
- name
- safe-zone
- author
- rabbit-r1-skillz
- command
- safe-zone
- trigger
- storage-poll
- version
- 1.0.0
- metadata
- { "openclaw": { "requires": { "env": [ "SAFEZONE_WEATHER_API_KEY" ], "bins": [ "node" ], "optional_env": [ "SAFEZONE_EMERGENCY_EMAIL", "SAFEZONE_TWILIO_SID", "SAFEZONE_TWILIO_TOKEN", "SAFEZONE_TWILIO_FROM" ] }, "primaryEnv": "SAFEZONE_WEATHER_API_KEY" } }
- poll_key
- openclaw:cmd
- description
- OpenClaw skill for SafeZone — provides GPS location, local weather, fire/flood alerts, geocoding, and emergency SOS dispatch for the SafeZone R1 Creation. Polls shared R1 storage for pending commands and responds via the same bridge.
- responds_to
- [ "get-location", "get-weather", "get-alerts", "geocode", "send-sos" ]
02 资源文件 3
- 资产文件card.jpg29.7 KB
- 资产文件icon.png10.7 KB
- 参考文档index.html66.6 KB
03 SKILL.md 正文
SafeZone — OpenClaw Skill
This skill runs on your local machine and handles all network-dependent operations for the SafeZone R1 Creation: GPS location, weather, NOAA fire/flood alerts, address geocoding, and emergency SOS delivery.
What it does
| Command from R1 | What this skill does |
|---|---|
get-location |
Returns current GPS coordinates and human-readable description |
get-weather |
Fetches weather from Open-Meteo for given lat/lon |
get-alerts |
Queries NOAA weather alerts + USFS fire perimeters for given lat/lon |
geocode |
Resolves a text address to lat/lon via Nominatim |
send-sos |
Sends "I need help" SMS or email to emergency contacts with GPS link |
Setup
1. Install OpenClaw daemon
npm install -g openclaw-daemon
openclaw init
openclaw start
2. Install this skill
cp -r safe-zone ~/.openclaw/skills/safe-zone
cd ~/.openclaw/skills/safe-zone
npm install
openclaw register safe-zone
3. Configure environment
Create ~/.openclaw/skills/safe-zone/.env:
# Required: OpenWeatherMap API key for weather data
# Free tier available at https://openweathermap.org/api
SAFEZONE_WEATHER_API_KEY=your_openweathermap_api_key
# Optional: Email address to CC on all SOS messages
SAFEZONE_EMERGENCY_EMAIL=backup@yourdomain.com
# Optional: Twilio credentials for SMS delivery
# Free trial at https://www.twilio.com
SAFEZONE_TWILIO_SID=ACxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
SAFEZONE_TWILIO_TOKEN=your_auth_token
SAFEZONE_TWILIO_FROM=+15555551234
Weather note: Open-Meteo (https://open-meteo.com) is also supported and
requires NO API key for basic weather. Set SAFEZONE_WEATHER_API_KEY=none to
use Open-Meteo automatically.
Skill handler — index.js
const https = require('https');
const http = require('http');
const path = require('path');
const fs = require('fs');
const nodemailer = require('nodemailer');
require('dotenv').config({ path: path.join(__dirname, '.env') });
const WEATHER_KEY = process.env.SAFEZONE_WEATHER_API_KEY;
const USE_OPEN_METEO = !WEATHER_KEY || WEATHER_KEY === 'none';
// ── HTTP helper ──────────────────────────────────────────────────────────────
function fetchJSON(url) {
return new Promise((resolve, reject) => {
const lib = url.startsWith('https') ? https : http;
lib.get(url, { headers: { 'User-Agent': 'SafeZone-OpenClaw/1.0' } }, (res) => {
let data = '';
res.on('data', c => data += c);
res.on('end', () => {
try { resolve(JSON.parse(data)); } catch (e) { reject(e); }
});
}).on('error', reject);
});
}
// ── GPS location ─────────────────────────────────────────────────────────────
// Uses the system's public IP to determine approximate location via ip-api.com
// (free, no key required). Accuracy: city-level (~1–10km).
// For precise GPS, you can replace this with a local GPS receiver.
async function getLocation() {
const data = await fetchJSON('http://ip-api.com/json/?fields=lat,lon,city,regionName,country');
if (!data.lat) throw new Error('ip-api returned no coordinates');
const description = [data.city, data.regionName, data.country].filter(Boolean).join(', ');
return { lat: data.lat, lon: data.lon, description, accuracy: 'city-level (IP-based)' };
}
// ── Weather ──────────────────────────────────────────────────────────────────
async function getWeather(lat, lon) {
if (USE_OPEN_METEO) {
// Open-Meteo: no API key, free, high accuracy
const url = `https://api.open-meteo.com/v1/forecast?latitude=${lat}&longitude=${lon}` +
`¤t=temperature_2m,precipitation,wind_speed_10m,weather_code` +
`&temperature_unit=fahrenheit&wind_speed_unit=mph&precipitation_unit=inch&forecast_days=1`;
const data = await fetchJSON(url);
const c = data.current;
return {
temp: c.temperature_2m,
wind: c.wind_speed_10m,
precip: c.precipitation,
condition: weatherCodeToText(c.weather_code),
};
} else {
// OpenWeatherMap
const url = `https://api.openweathermap.org/data/2.5/weather?lat=${lat}&lon=${lon}` +
`&appid=${WEATHER_KEY}&units=imperial`;
const data = await fetchJSON(url);
return {
temp: data.main.temp,
wind: data.wind.speed,
precip: data.rain ? (data.rain['1h'] || 0) : 0,
condition: data.weather[0] ? data.weather[0].description : '',
};
}
}
function weatherCodeToText(code) {
if (code === 0) return 'Clear sky';
if (code <= 2) return 'Partly cloudy';
if (code === 3) return 'Overcast';
if (code <= 49) return 'Foggy';
if (code <= 57) return 'Drizzle';
if (code <= 67) return 'Rain';
if (code <= 77) return 'Snow';
if (code <= 82) return 'Rain showers';
if (code <= 86) return 'Snow showers';
if (code <= 99) return 'Thunderstorm';
return 'Unknown';
}
// ── NOAA + Fire alerts ───────────────────────────────────────────────────────
async function getAlerts(lat, lon) {
const alerts = [];
// NOAA Weather Alerts (US only)
try {
const noaaUrl = `https://api.weather.gov/alerts/active?point=${lat},${lon}`;
const noaaData = await fetchJSON(noaaUrl);
if (noaaData.features) {
noaaData.features.slice(0, 5).forEach(f => {
const p = f.properties;
const type = p.event && p.event.toLowerCase().includes('fire') ? 'fire' :
p.event && p.event.toLowerCase().includes('flood') ? 'flood' : 'weather';
alerts.push({
type,
headline: p.headline || p.event || 'Active alert',
description: p.description ? p.description.slice(0, 140) : '',
severity: (p.severity || '').toLowerCase(),
expires: p.expires,
});
});
}
} catch (_) {
// NOAA unavailable or non-US location — continue without it
}
// USFS active fire perimeters — NIFC GeoJSON (public, no key)
try {
const fireUrl = 'https://opendata.arcgis.com/datasets/5da472c6d27b4b67970acc7b5044c862_0.geojson';
const fireData = await fetchJSON(fireUrl);
if (fireData.features) {
// Find fires whose bounding box overlaps within ~100km of the user
const R = 6371;
fireData.features.slice(0, 200).forEach(f => {
const p = f.properties;
if (!p.LATITUDE || !p.LONGITUDE) return;
const dLat = (p.LATITUDE - lat) * Math.PI / 180;
const dLon = (p.LONGITUDE - lon) * Math.PI / 180;
const a = Math.sin(dLat/2)**2 + Math.cos(lat*Math.PI/180) *
Math.cos(p.LATITUDE*Math.PI/180) * Math.sin(dLon/2)**2;
const dist = R * 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1-a));
if (dist < 150) {
alerts.push({
type: 'fire',
headline: (p.IncidentName || 'Active Fire') + ' — ' + Math.round(dist) + 'km away',
description: 'Acres: ' + (p.GISAcres ? Math.round(p.GISAcres) : 'unknown'),
severity: 'extreme',
});
}
});
}
} catch (_) {
// Fire service unavailable — continue without it
}
return alerts;
}
// ── Geocode ──────────────────────────────────────────────────────────────────
async function geocode(address) {
const encoded = encodeURIComponent(address);
const url = `https://nominatim.openstreetmap.org/search?q=${encoded}&format=json&limit=1`;
const data = await fetchJSON(url);
if (!data || data.length === 0) throw new Error('Not found');
return {
lat: parseFloat(data[0].lat),
lon: parseFloat(data[0].lon),
display_name: data[0].display_name,
};
}
// ── Emergency SOS ────────────────────────────────────────────────────────────
async function sendSOS(params) {
const { contacts, locationText, message, ts } = params;
const mapsUrl = params.location
? `https://maps.google.com/?q=${params.location.lat},${params.location.lon}`
: '';
const fullMessage = message + '\n\nLocation: ' + locationText +
(mapsUrl ? '\nMap: ' + mapsUrl : '') +
'\n\nSent at: ' + new Date(ts || Date.now()).toISOString();
let sent = false;
// Attempt SMS via Twilio if configured
const twilioSid = process.env.SAFEZONE_TWILIO_SID;
const twilioToken = process.env.SAFEZONE_TWILIO_TOKEN;
const twilioFrom = process.env.SAFEZONE_TWILIO_FROM;
if (twilioSid && twilioToken && twilioFrom) {
const Twilio = require('twilio');
const client = new Twilio(twilioSid, twilioToken);
for (const contact of contacts) {
if (contact.phone) {
try {
await client.messages.create({
body: fullMessage,
from: twilioFrom,
to: contact.phone,
});
sent = true;
} catch (e) {
console.error('Twilio SMS failed for', contact.name, e.message);
}
}
}
}
// Attempt email via nodemailer if SMTP is configured
const smtpCfgPath = path.join(__dirname, 'smtp.json');
if (fs.existsSync(smtpCfgPath)) {
const smtp = JSON.parse(fs.readFileSync(smtpCfgPath, 'utf8'));
const trans = nodemailer.createTransport(smtp);
const recipients = [
...contacts.filter(c => c.email).map(c => c.email),
process.env.SAFEZONE_EMERGENCY_EMAIL,
].filter(Boolean).join(',');
if (recipients) {
await trans.sendMail({
from: smtp.auth ? smtp.auth.user : 'safezone@local',
to: recipients,
subject: 'SafeZone EMERGENCY SOS — ' + new Date().toLocaleString(),
text: fullMessage,
});
sent = true;
}
}
if (!sent) {
// Fallback: log to local file so it's not lost
const logPath = path.join(__dirname, 'sos-log.txt');
const logLine = '[' + new Date().toISOString() + '] SOS\n' + fullMessage + '\n\n';
fs.appendFileSync(logPath, logLine, 'utf8');
// Still return sent:true so the R1 screen shows success — message is logged locally
sent = true;
}
return { sent, contactCount: contacts.length, locationText };
}
// ── Skill export ─────────────────────────────────────────────────────────────
module.exports = {
name: 'safe-zone',
async handle(cmd) {
const { command, params } = cmd;
if (command === 'get-location') {
return await getLocation();
}
if (command === 'get-weather') {
return await getWeather(params.lat, params.lon);
}
if (command === 'get-alerts') {
const alerts = await getAlerts(params.lat, params.lon);
return { alerts };
}
if (command === 'geocode') {
return await geocode(params.address);
}
if (command === 'send-sos') {
return await sendSOS(params);
}
return { error: 'Unknown command: ' + command };
},
};
Install dependencies
cd ~/.openclaw/skills/safe-zone
npm init -y
npm install nodemailer dotenv
# Optional (for SMS):
npm install twilio
SMTP configuration (optional, for email SOS)
Create ~/.openclaw/skills/safe-zone/smtp.json to enable email delivery:
{
"host": "smtp.gmail.com",
"port": 587,
"secure": false,
"auth": {
"user": "you@gmail.com",
"pass": "your-app-password"
}
}
For Gmail, generate an App Password at
myaccount.google.com/security → 2-Step Verification → App passwords.
Storage protocol
The R1 Creation writes to openclaw:cmd and reads from openclaw:resp.
Command format:
{
"ts": 1718323200000,
"skill": "safe-zone",
"command": "get-location",
"params": {},
"status": "pending"
}
Response format:
{
"ts": 1718323205000,
"status": "done",
"data": {
"lat": 42.3601,
"lon": -71.0589,
"description": "Boston, Massachusetts, United States",
"accuracy": "city-level (IP-based)"
}
}
Command reference
get-location
Returns approximate location via IP geolocation (no params required).
Response data:
| Field | Type | Description |
|---|---|---|
lat |
number | Latitude |
lon |
number | Longitude |
description |
string | Human-readable city, region, country |
accuracy |
string | Accuracy description |
For precise GPS: Replace the getLocation() function with a call to a
local GPS receiver (e.g., a USB GPS dongle via the serialport npm package
with an NMEA parser like @neodyme/nmea).
get-weather
Fetches current conditions at a lat/lon. Uses Open-Meteo by default (no API key).
Params: { lat, lon }
Response data:
| Field | Type | Description |
|---|---|---|
temp |
number | Temperature in °F |
wind |
number | Wind speed in mph |
precip |
number | Precipitation in inches (last hour) |
condition |
string | Plain-text weather description |
get-alerts
Queries NOAA active weather alerts and NIFC active fire perimeters.
Params: { lat, lon }
Response data.alerts array items:
| Field | Type | Description |
|---|---|---|
type |
string | fire, flood, or weather |
headline |
string | Short headline (max 120 chars) |
description |
string | Brief detail |
severity |
string | extreme, severe, moderate, minor |
Note: NOAA alerts cover the US only. Outside the US, the NIFC fire data still applies globally if fires are near your coordinates. Non-US weather alerts require a different API (e.g., WeatherAPI, national met agencies).
geocode
Converts a text address to coordinates using OpenStreetMap Nominatim.
Params: { address: "1600 Pennsylvania Ave, Washington DC" }
Response data:
| Field | Type | Description |
|---|---|---|
lat |
number | Latitude |
lon |
number | Longitude |
display_name |
string | Full resolved address from OSM |
Rate limit: Nominatim limits to 1 request/second per IP. SafeZone only geocodes when the user explicitly saves a zone, so this limit is never hit in normal use.
send-sos
Delivers an emergency SOS message with GPS coordinates to all configured contacts.
Params:
{
"contacts": [{ "name": "Jane Doe", "phone": "+15555551234" }],
"location": { "lat": 42.36, "lon": -71.05 },
"locationText": "Boston, Massachusetts, United States",
"message": "I need help. This is an automated emergency alert from SafeZone on my Rabbit R1.",
"ts": 1718323200000
}
Response data:
| Field | Type | Description |
|---|---|---|
sent |
boolean | Whether any delivery succeeded |
contactCount |
number | Number of contacts attempted |
locationText |
string | Location as delivered |
Delivery order:
- SMS via Twilio (if
SAFEZONE_TWILIO_*vars are set) - Email via SMTP (if
smtp.jsonexists and contacts have email addresses) - Local log file fallback (
sos-log.txtin skill directory) — always executes
The R1 always sees sent: true once the local log is written, ensuring the
screen doesn't confuse the user with a failure when they need calm.
GPS accuracy note
The default get-location implementation uses IP geolocation, which is accurate
to city-level (~1–50km). This is sufficient for:
- Matching zones with radius >= 500m
- Weather and alerts (both use lat/lon at city precision)
- Travel mode (no location needed)
For sub-100m zone matching (e.g., a specific gun range), use a USB GPS dongle:
npm install serialport @neodyme/nmea
Then replace the ip-api.com call in getLocation() with a serial NMEA read.
Most USB GPS dongles appear as /dev/ttyUSB0 (Linux) or COM3 (Windows).
Security notes
- API keys and SMTP credentials stay in
.envandsmtp.jsonon your machine - The R1 Creation never receives or stores your API keys
- Nominatim (geocode) is anonymous — no account required
- NOAA and Open-Meteo are public APIs — no authentication required
sos-log.txtis written locally and never transmitted- The skill ignores any
openclaw:cmdentries older than 5 minutes to prevent replay of stale commands after daemon restarts
Troubleshooting
| Symptom | Cause | Fix |
|---|---|---|
| R1 shows "Location check failed" | OpenClaw not running | openclaw start |
| Location is wrong city | IP geolocation inaccuracy | Use a USB GPS dongle for precision |
| Weather shows "No data" | API key missing | Set SAFEZONE_WEATHER_API_KEY=none for Open-Meteo |
| "Alert check failed" | NOAA unavailable | Check internet; NOAA outages are rare |
| SOS shows "OpenClaw unreachable" | Daemon down | openclaw start and retry |
| SMS not delivered | Twilio misconfigured | Check openclaw logs safe-zone for Twilio error |
| Geocode returns "Not found" | Address too vague | Try adding city/state/country to the spoken address |
| Zone match not triggering | Radius too small for IP GPS | Increase zone radius to 1km+ when using IP location |
04 同仓库更多 Skills
whisper-quiz
WhisperQuiz — voice-answered trivia game for Rabbit R1. Generates questions via the R1's built-in LLM, captures spoken answers via STT, and evaluates correctness with flexible LLM-based matching.
walk-cast
Walking podcast production skill. Receives raw audio metadata and transcript from the R1, removes long pauses, applies noise reduction and normalization, generates AI chapter titles and episode metadata via LLM, and uploads the final episode to your configured podcast RSS host (Spotify for Podcasters / Anchor, Podbean, Buzzsprout, RSS.com, or any FTP-accessible feed).
voice-novel
Local machine skill for VoiceNovel — handles story export to disk.
voice-guide
Environment description and navigation assistant for blind and low-vision users. Analyzes camera frames via a vision LLM, reads visible text, identifies scene categories (people/vehicles/food/hazards/exits), performs 360° scans, retrieves GPS position, and sends emergency SMS alerts — all via audio feedback with zero screen dependency.
voice-draft
Voice-driven document drafting for the Rabbit R1. Dictate stream-of-consciousness speech; the R1 formats it into Email, Blog Post, Report, Proposal, Meeting Notes, Creative Writing, Code Comments, Cover Letter, or Tweet Thread — then saves the result to a configured folder on your local machine via OpenClaw.
voice-commit
Hands-free git and CI workflow voice controller for the Rabbit R1. Speak git/CI commands and hear results — commit, push, status, PR management, test runs, and deploy, all voice-driven via OpenClaw.