Skip to content

Malaczynski.eu Posts

0x0000011b printer error

If you are having problem in windows 10 to connect remote printer and error number 0x0000011b appears then to fix it you need to uninstall latest system update KB5005565.

Restart MM form HA

From time to time the photo module in MagicMirror hangs. I used to restart it manually by logging into the Raspberry and using the command “pm2 restart mm”. Now I want to make it so that it automatically restarts when I scan the NFC tag stuck to the back of the monitor.

So I divided big problem to smaller ones:
1. Restart MM,
2. Connection HA to MM machine,
3. Automation when HA apk scan tag,
4. Stick the NFC tag to the monitor xD

  1. Restart MM – Easy
pm2 restart mm

2. Connection HA to MM mashine

HA needs to let MM know to shut down for a while, so I guess the easiest way to do this is with mqtt broker.
I have used before Mosquitto, so I will use it.

MM site:
I created 2 files in my home directory: restartmm.sh and restartmm.py

restartmm.sh:

#!/usr/bin/env python

sleep 20
python /home/pi/restartmm.py &
restartmm.py basen on mqtt-screen-power project:

mqtt_host = "192.168.xxx.xxx"
mqtt_port = 1883
mqtt_topic = "/screen/restart"
mqtt_username = "xxxxxxxx"
mqtt_password = "xxxxxxxx"
power_on_command = "pm2 restart mm"
power_off_command = " "


import paho.mqtt.client as mqtt
import subprocess


def on_connect(client, userdata, flags, rc):
    # The callback for when the client receives a CONNACK response from the server.
    print("Connected with result code "+str(rc))

    # Subscribing in on_connect() means that if we lose the connection and
    # reconnect then subscriptions will be renewed.
    client.subscribe(mqtt_topic)


def on_message(client, userdata, msg):
    # The callback for when a PUBLISH message is received from the server.
    print(msg.topic+" "+str(msg.payload))
    if str(msg.payload) == "ON":
        subprocess.Popen(power_on_command,
                         shell=True, stdout=subprocess.PIPE)
    else:
        subprocess.Popen(power_off_command,
                         shell=True, stdout=subprocess.PIPE)


client = mqtt.Client()
client.on_connect = on_connect
client.on_message = on_message

client.username_pw_set(mqtt_username, mqtt_password)
client.connect(mqtt_host, mqtt_port, 60)

# Blocking call that processes network traffic, dispatches callbacks and
# handles reconnecting.
# Other loop*() functions are available that give a threaded interface and a
# manual interface.
client.loop_forever()

Both files chown is 755. Autostart with command “crontab -e” – “@reboot sh /home/XXXXX/restartmm.sh”

HA site:

HA configuration.yaml

switch:
  - platform: mqtt
    name: "MM restart"
    command_topic: "/screen/restart"

automations.yaml:

- alias: turn_off_restart_mm
  trigger:
    platform: state
    entity_id: switch.mm_restart
    to: 'on'
    for:
      seconds: 1
  action:
    service: switch.turn_off
    entity_id: switch.mm_restart

3. Automation when HA apk scan tag,

HA automations.yaml:

- alias: mm_tag
  initial_state: true
  trigger:
  - platform: tag
    tag_id: 7275ecff-27a1-4c4d-a7fd-69647998dbf8
  action:
  - service: switch.turn_on
    entity_id: switch.mm_restart

4. Stick the NFC tag to the monitor. Formality.

Changing the hours of light in HA automations

I wanted the lights above my kitchen counter to light up faster in the evening and later in the morning, I did it this way:

- alias: Kitchen_leds_on
  initial_state: true
  trigger:
    platform: state
    entity_id: binary_sensor.motion_sensor_158d00031c90e3
    from: 'off'
    to: 'on'
  condition:
    condition: or
    conditions:
      - condition: numeric_state
        entity_id: 'sensor.illumination_34ce00fb6930'
        below: 100
      - condition: time
        after: '19:00:00'
      - condition: sun
        after: sunset
        after_offset: '-01:00:00'
      - condition: sun
        before: sunrise
        before_offset: '01:00:00'
  action:
    service: light.turn_on
    entity_id: light.kitchen_leds

Change drive to ssd

What is the easiest and fastest way to speed up your computer? Yes, changing the drive from hdd to ssd. This can be done in 3 tasks:

  1. buy a drive
  2. copy the data
  3. replace the drive
  1. Buy a drive
    Based on those smarter than me ie https://polecanelaptopy.blogspot.com/ I personally currently advise the Crucial MX500. You can buy a drive bay right away, so you can connect the drive for cloning and then you can use the old drive as a kind of flash drive.
  2. Copy the data
    Connect the drive in the pocket to the computer, start the system and the program ReflectDLHF. It’s free for non-commercial use and you can clone entire partitions from a large capacity to a smaller one.
  3. Replace the drive
    There is nothing to explane here. Search in google how to open your laptop – “replace drive in xxx” and follow the instructions.

If something goes wrong, then most likely the boot sector of the partition on the disk was already screwed up. You can play around with command line recovery some example links:

https://www.partitionwizard.com/clone-disk/bootrec-fixboot-access-is-denied.html

https://www.diskpart.com/windows-10/fixboot-access-denied-windows-10.html

https://support.microsoft.com/en-gb/topic/use-bootrec-exe-in-the-windows-re-to-troubleshoot-startup-issues-902ebb04-daa3-4f90-579f-0fbf51f7dd5d

If that doesn’t help then I recommend a clean install, just remember that the new disks must be in GPT (GUID Partition Table) and not MBR (Master Boot Record). That is, if Windows 10 isntalation crashes at the disk selection stage and underneath you see the message “Windows can’t be installed on drive 0 partition 2. (Show details)” “Windows cannot be installed on this disk, The selected disk has an MBR partition table. On EFI systems, Windows can only be installed to GPT disks.” you need to do this:

https://docs.microsoft.com/en-us/windows-server/storage/disk-management/change-an-mbr-disk-into-a-gpt-disk

Excel Search by Multiple Criteria

If you have a list of horizontal data and you want to turn it into vertical data then you need to use the index() function. As in the example below.

First, prepare a list of two non-repeating values, in my case “Nazwa” and “Kwota”. Then a list of recurring values to help with the search, I search by the “Etap” column.

The formula in the “Adres” column looks like this:

=WYSZUKAJ.PIONOWO(H2;A2:F10;2;0)
=VLOOKUP(H2;A2:F10;2;0)

Nothing special. The real magic begins after this column. Index() function supported by Match().

=INDEKS($A$2:$F$10;PODAJ.POZYCJĘ($H2&K$1&$I2;$A$2:$A$10&$C$2:$C$10&$F$2:$F$10;0);5)
=INDEX($A$2:$F$10;MATCH($H2&K$1&$I2;$A$2:$A$10&$C$2:$C$10&$F$2:$F$10;0);5)

Remember to confirm the index() function using the key combination Crtl+Shift+Enter.

The system doesn’t recognise the monitor

If you have problem wiIf you have a problem with your monitor, one day everything looks normal, the next day the screen resolution is 800×600 and the device manager defines your monitor as a “Standard PnP monitor”, this means you probably have a problem with the cable connecting the GPU to the monitor. 

Magic Mirror on Raspberry Pi 3B+

 

 

To have such an information monitor, you need to have some unnecessary things, like a monitor and a raspberry, and buy a monitor holder and an hdmi-dvi adapter. I had nothing, so I bought parts. For the monitor I went to a computer store and asked about an old monitor, they gave me a 17″ for free.

 

 

 

Steps in few words:

  1. Install Raspberry Pi OS with desktop
  2. Install MagicMirror
  3. Install modules:
    • MMM-homeassistant-sensors – sensors from Home Assistant (temp, pressure, humidity, pm2.5, etc.)
    • MMM-Spotify – shows some music playing on Spotify
    • MMM-Wallpaper – based on reddit or bing wallpaper changer
    • MMM-GooglePhotos – shows your albums
    • MMM-HTMLBox – shows weather from meteo.pl
    • MMM-SystemStats – shows rpi stats
  4. Autostart MagicMirror https://github.com/MichMich/MagicMirror/wiki/Auto-Starting-MagicMirror

If you don’t have money for a big memory card or you use a recycled one, you have to watch the memory so that MagicMirror logs don’t eat all the memory. I solved this by installing logrorate.

https://github.com/keymetrics/pm2-logrotate

with this settings:

https://dannnb.medium.com/pm2-large-log-files-and-how-to-remove-them-4bffb30e99dc

WordPress on Mikr.us v1

What requirements does WordPress have?

PHP version 7.4 or greater.
MySQL version 5.6 or greater OR MariaDB version 10.1 or greater.
Wsparcie HTTPS

https://pl.wordpress.org/about/requirements/

On older versions it will also work, but it is not recommended.

In the mikr.us panel, we check that the system we have installed is Ubuntu 16.

WordPress instalation

Using the link:
https://websiteforstudents.com/install-wordpress-on-ubuntu-16-04-lts-with-nginx-mariadb-and-php-7-1-support/   
we do the following:

Step 1.

Step 2 is skipped. We do not install the database, we will use a shared database, the access data is in the mikr.us panel. InstruBazy danych nie instalujemy, będziemy korzystać z bazy współdzielonej, dane dostępowe znajdują się w panelu mikr.usa. Manual: 
https://www.facebook.com/groups/mikrusy/learning_content/?filter=2830942186953036&post=256041555449185

Step 3. Install PHP 7.4 using the instructions at:
https://computingforgeeks.com/how-to-install-php-on-ubuntu/
Ad-on modules and final configuration take from the first ling changing 7.1 to 7.4

Step 4. Nope

Step 5 – 9. We follow the instructions. We get the data for database configuration from panel. And in nginx configuration change
unix:/var/run/php/php7.1-fpm.sock
to
unix:/var/run/php/php7.4-fpm.sock

That’s it, wordpress works and it’s great. Only the address is weak, because it looks like this: http://[1080:0:0:0:8:800:200C:417A].

If we have a domain then we can redirect it to mikr.us using the “Cloudflare i Mikrus” instructions:
https://www.facebook.com/groups/mikrusy/learning_content/?filter=2830942186953036&post=1155889001448056