test pyscript

<!DOCTYPE html>
<html lang="zh">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <!-- 引入 PyScript -->
    <link rel="stylesheet" href="https://pyscript.net/alpha/pyscript.css" />
    <script defer src="https://pyscript.net/alpha/pyscript.js"></script>

    <title>First PyScript Application</title>
    <style>
        py-script {
            width: 100%;
            height: 100%;
            font-size: 20px;
            text-align: center;
            position: absolute;
        }
    </style>
</head>

<body>
    <py-script>
        print('Hello PyScript!')
    </py-script>

</body>

</html>

pyscript参考

https://blog.csdn.net/Moelimoe/article/details/126077302?spm=1001.2101.3001.6650.1&utm_medium=distribute.pc_relevant.none-task-blog-2%7Edefault%7ECTRLIST%7ERate-1-126077302-blog-124733591.pc_relevant_multi_platform_featuressortv2dupreplace&depth_1-utm_source=distribute.pc_relevant.none-task-blog-2%7Edefault%7ECTRLIST%7ERate-1-126077302-blog-124733591.pc_relevant_multi_platform_featuressortv2dupreplace&utm_relevant_index=2

编译pico固件

Building MicroPython From Source
The prebuilt binary which can be downloaded from the MicroPython section of the documentation should serve most
use cases, but you can build your own MicroPython firmware from source if you’d like to customise its low-level
aspects.
 TIP
If you have already downloaded and installed a prebuilt MicroPython UF2 file, you can skip ahead to Chapter 2 to
start using your board.
 IMPORTANT
These instructions for getting and building MicroPython assume you are using Raspberry Pi OS running on a
Raspberry Pi 4, or an equivalent Debian-based Linux distribution running on another platform.
It’s a good idea to create a pico directory to keep all pico-related checkouts in. These instructions create a pico directory
at /home/pi/pico.
$ cd ~/
$ mkdir pico
$ cd pico
Raspberry Pi Pico Python SDK
1.2. Installing MicroPython on Raspberry Pi Pico 4
Then clone the micropython git repository. These instructions will fetch the latest version of the source code.
$ git clone -b master https://github.com/micropython/micropython.git
Once the download has finished, the source code for MicroPython should be in a new directory called micropython. The
MicroPython repository also contains pointers (submodules) to specific versions of libraries it needs to run on a
particular board, like the SDK in the case of RP2040. We need to fetch these submodules too:
$ cd micropython
$ make -C ports/rp2 submodules
 NOTE
The following instructions assume that you are using a Raspberry Pi Pico. Some details may differ if you are building
firmware for a different RP2040-based board. The board vendor should detail any extra steps needed to build
firmware for that particular board. The version we’re building here is fairly generic, but there might be some
differences like putting the default serial port on different pins, or including extra modules to drive that board’s
hardware.
To build the RP2040 MicroPython port, you’ll need to install some extra tools. To build projects you’ll need CMake, a
cross-platform tool used to build the software, and the GNU Embedded Toolchain for Arm, which turns MicroPython’s C
source code into a binary program RP2040’s processors can understand. build-essential is a bundle of tools you need
to build code native to your own machine — this is needed for some internal tools in MicroPython and the SDK. You can
install all of these via apt from the command line. Anything you already have installed will be ignored by apt.
$ sudo apt update
$ sudo apt install cmake gcc-arm-none-eabi libnewlib-arm-none-eabi build-essential
First we need to bootstrap a special tool for MicroPython builds, that ships with the source code:
$ make -C mpy-cross
We can now build the port we need for RP2040, that is, the version of MicroPython that has specific support for our
chip.
$ cd ports/rp2
$ make
If everything went well, there will be a new directory called build-PICO (ports/rp2/build-PICO relative to the micropython
directory), which contains the new firmware binaries. The most important ones are:
firmware.uf2 A UF2 binary file which can dragged onto the RPI-RP2 drive that pops up once your Raspberry Pi
Pico is in BOOTSEL mode. The firmware binary you can download from the documentation page
is a UF2 file, because they’re the easiest to install.
Raspberry Pi Pico Python SDK
1.3. Building MicroPython From Source 5
firmware.elf A different type of binary file, which can be loaded by a debugger (such as gdb with openocd) over
RP2040’s SWD debug port. This is useful for debugging either a native C module you’ve added to
MicroPython, or the MicroPython core interpreter itself. The actual binary contents is the same
as firmware.uf2.
You can take a look inside your new firmware.uf2 using picotool, see the Appendix B in the Getting started with
Raspberry Pi Pico book for details of how to use picotool, e.g.
$ picotool info -a build-PICO/firmware.uf2
File build-PICO/firmware.uf2:
Program Information
 name: MicroPython
 version: v1.18-412-g965747bd9
 features: USB REPL
  thread support
 frozen modules: _boot, rp2, _boot_fat, ds18x20, onewire, dht, uasyncio,
  uasyncio/core, uasyncio/event, uasyncio/funcs, uasyncio/lock,
  uasyncio/stream, neopixel
 binary start: 0x10000000
 binary end: 0x1004ba24
 embedded drive: 0x100a0000-0x10200000 (1408K): MicroPython
Fixed Pin Information
 none
Build Information
 sdk version: 1.3.0
 pico_board: pico
 boot2_name: boot2_w25q080

https://datasheets.raspberrypi.com/pico/raspberry-pi-pico-python-sdk.pdf

homeassistant mqtt 参考

https://www.home-assistant.io/docs/mqtt/discovery/

https://www.bilibili.com/read/cv12453670/

https://www.wenjiangs.com/doc/home-assistant-component-mqtt

https://blog.csdn.net/qq_25886111/article/details/108880860

开关
switch:
  - platform: mqtt
    name: "Bedroom Switch"
    state_topic: "home/bedroom/switch1"
    command_topic: "home/bedroom/switch1/set"
    availability_topic: "home/bedroom/switch1/available"
    payload_on: "ON"
    payload_off: "OFF"
    optimistic: false
    qos: 0
    retain: true

变量说明:

name (可选): 名称,英文。默认 MQTT Switch
state_topic (必填): 获取设备值的MQTT topic
command_topic (必填): The MQTT topic to publish commands to change the switch state.
availability_topic (可选): 获取设备 birth&LWT 信息的 MQTT topic。如未指明,则设备的可用状态默认为 available;如指明,则设备的可用状态默认为 available。
payload_on (可选): 代表开启的值,默认 ON
payload_off (可选): 代表开启的值,默认 OFF
payload_available (可选): 代表设备在线状态的值, 如 ‘online’,默认为 ON
payload_not_available (可选): 代表设备离线状态的值, 如 ‘offline’,默认为 OFF
optimistic (可选): 设备是否在理想模式,如果 state_topic 没有定义,默认为 true
qos (可选): 最大 QoS 值,默认 0
retain (可选): 信息发布是否带 retain 标记
value_template (可选): 定制数据生成的模板

树莓派开机自动启动全屏网页

cd /home/pi/.config/
mkdir autostart
cd /autostart
sudo nano my.desktop

autostart文件夹中储存的是自启动文件

在新建的my.desktop文件中编辑:

[Desktop Entry]
Type = Application
Exec = chromium-browser "要打开的网页" -kiosk

[Desktop Entry] 文件头:Desktop Entry文件是Linux 桌面系统中标准的程序启动配置描述方式。
Exec 执行的命令:chromium-browser用浏览器打开 -kiosk选项 则是全屏打开(Ctrl+F4退出全屏)

不加载桌面全屏启动chromium浏览器

编辑/etc目录下的profile文件。

sudo nano /etc/profile

#在这个文件的顶部 输入chromium可执行文件的绝对路径,正常为:

/usr/lib/chromium-browser/chromium-browser  --disable-popup-blocking --no-first-run --disable-desktop-notifications  --kiosk --incognito "http://www.baidu.com/"

#其中kiosk为全屏选项

树莓派无桌面系统(RaspberryPI Lite)启动自动打开Chromium-Browser的具体方法

树莓派禁止熄屏

步骤

1.打开lightdm.conf

sudo nano /etc/lightdm/lightdm.conf
2.修改lightdm.conf

找到 [SeatDefaults] 段下的 ’xserver-command’, 取消注释 , 修改如下:

xserver-command=X

修改为

xserver-command=X -s 0 -dpms
-s # –设置屏幕保护不启用
dpms 关闭电源节能管理
3.重启

reboot